资源简介

可以计算两个三维图像的互信息值,用于配准

资源截图

代码片段和文件信息

function fx=PV_MI(AABBx);

[rowAAcolumnAAhighAA]=size(AA);
[rowBBcolumnBBhighBB]=size(BB);
AA=AA+1;
BB=BB+1;%全部加1,避免为0时,作为下标时出错

Numab=zeros(256256);
Numa=zeros(1256);
Numb=zeros(1256);
count=0;
for vi=1:highBB
            for vj=1:columnBB
                for vk=1:rowBB
                    vkm=vk*2.590723;
                    vjm=vj*2.590723;
                    vim=vi*8.000000;
                [xxmyymzzm]=transformation(vkmvjmvimx);
                xx=xxm/1.250000;
                yy=yym/1.250000;
                zz=zzm/4.000000;
               if xx>1&xx1&yy1&vk                   count=count+1;
               end
                
             
                grayvaluex=BB(vkvjvi);
                if xx<1|xx>rowAA|yy<1|yy>columnAA|zz<1|zz>highAA
        %if ptA(vivj)<1&ptB(vivj)<1      %出界点处理
            %Numab(FBB(11))=Numab(FBB(11))+1;
        %elseif ptA(vivj)<1&ptB(vivj)>columnBB
            %Numab(FBB(1columnBB))=Numab(FBB(1columnBB))+1;
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %出界处理一
               % Numab(grayvaluex1)=Numab(grayvaluex1)+1;
                %Numa(grayvaluex)=Numa(grayvaluex)+1;
                %Numb(1)=Numb(1)+1;
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %出界处理二
            %1xx xia chu jie
                if xx<1&yy>=1&yy<=columnAA&zz>=1&zz<=highAA
                   grayvaluey=AA(1round(yy)round(zz));
                   Numab(grayvaluexgrayvaluey)=Numab(grayvaluexgrayvaluey)+1; 
                   Numa(grayvaluex)=Numa(grayvaluex)+1;
                   Numb(grayvaluey)=Numb(grayvaluey)+1;
                end
            %2xx shang chu jie
                if xx>rowAA&yy>=1&yy<=columnAA&zz>=1&zz<=highAA
                   grayvaluey=AA(rowAAround(yy)round(zz));
                   Numab(grayvaluexgrayvaluey)=Numab(grayvaluexgrayvaluey)+1; 
                   Numa(grayvaluex)=Numa(grayvaluex)+1;
                   Numb(grayvaluey)=Numb(grayvaluey)+1;
                end
           %3yy xia chu jie
                if yy<1&xx>=1&xx<=rowAA&zz>=1&zz<=highAA
                   grayvaluey=AA(round(xx)1round(zz));
                   Numab(grayvaluexgrayvaluey)=Numab(grayvaluexgrayvaluey)+1; 
                   Numa(grayvaluex)=Numa(grayvaluex)+1;
                   Numb(grayvaluey)=Numb(grayvaluey)+1;
                end
            %4yy shang chu jie
                if yy>columnAA&xx>=1&xx<=rowAA&zz>=1&zz<=highAA
                   grayvaluey=AA(round(xx)columnAAround(zz));
                   Numab(grayvaluexgrayvaluey)=Numab(grayvaluexgrayvaluey)+1; 
                   Numa(grayvaluex)=Numa(grayvaluex)+1;
                   Numb(grayvaluey)=Numb(grayvaluey)+1;
                end
            %5zz xia chu jie
                if xx>=1&xx<=rowAA&yy>=1&yy<=columnAA&zz<1
                   grayvaluey=AA(round(xx)round(yy

评论

共有 条评论