フィルター逆投影再構成アルゴリズムの研究ファントムグラフを例にとり、フィルターを構築し、画像を再構築します

%%%%%%%%% projection.m %%%%%%%%%%%%

晴れ;
すべてクリア;
M = 256;
N = 256;
I =ファントム(M、N);
図1);
imshow(I);

nDetectors = 512;
nViews = 360;
Projection = zeros(nViews、nDetectors);


長さ= 20;
重量= 20;
phyRatoDig = M /長さ;

stepBeam = 2 * pi / nViews;%回転角ステップ
focalDistance_phy = 40;
detecDistance_phy = 40;
focusDistance_dig = FocalDistance_phy * phyRatoDig;
detecDistance_dig = detecDistance_phy * phyRatoDig;
diameter = sqrt(M * N + M * N);


detecLength = 41.3;
detecLength_dig = detecLength * phyRatoDig;
detecResolution = 512;
unitDis = detecLength /(detecResolution-1);
yDetector =([1:detecResolution] -1)* unitDis-detecLength / 2;

gamma = atan(yDetector /(focalDistance_phy + detecDistance_phy));

sample = 0.5;%光線に沿ったステップのステップ長、つまり、サンプリング間隔
sample_times = floor(sqrt((detecDistance_dig + FocalDistance_dig)^ 2 +(detecLength_dig / 2)^ 2)/ sample);
disp( 'projection ')
for fanNum = 1:nViews;
    if(rem(fanNum、10)== 0)
        disp(' Current Sample ')
        fanNum
    end
    beta =(fanNum-1)* stepBeam;
    sourceX = focusDistance_dig * cos(pi / 2 + beta);%極座標で光線源の座標を計算します(負の値を含めることができます)
    sourceY = focusDistance_dig * sin(pi / 2 + beta);
           raynum = 1の場合:nDetectors deltaX
             = 0;
             deltaY = 0;
             value = 0 ; 
             gamaTemp = gamma(1、raynum);
             full_angle = beta + gamaTemp;
                 if(full_angle <0)
                    full_angle = full_angle + 2 * pi;
                終了
                if(full_angle> 2 * pi) 
                    full_angle = full_angle-2 * pi;
                end
                if(full_angle> = 0 && full_angle <pi / 2)
                
                    flagX = 1;
                    flagY = -1;
                else
                    if(full_angle> = pi / 2 && full_angle <pi)
                   
                    flagX = 1;
                    flagY = 1;
                    
                    else
                        if(full_angle> = pi && full_angle <3 * pi / 2)
                
                     flagX = -1;

                    
                        else
                            if(full_angle> = 3 * pi / 2 && full_angle <2 * pi)
                
                           flagX = -1;
                           flagY = -1;
                            end
                        end
                    end
                end
                
                x_delta = abs(sin(full_angle));
                 y_delta = abs(cos(full_angle) );
                 deltaX = flagX * x_delta;%xおよびy方向の成長を包括的に検出
                 deltaY = flagY * y_delta;
                 for k = 1:sample_times 
                      pixel = 0;%光線経路上の点の投影値
                      x = sourceX + k * deltaX * sample + N / 2;
                     y = sourceY + k * deltaY * sample + N / 2;
                    if(x> = 1 && x <= M && y> = 1 && y <= N)
                     
                         ix = floor(x);
                         x = x-ix;
                         iy = floor(y);
                         y = y-iy;
                        if((ix + 1 +(iy + 1)* N)> =(M * N))
                            ピクセル= I(iy、ix);
                        else
                            pixel = x *(I(iy、ix + 1)-I(iy、ix))+ y *(I(iy + 1、ix)-I(iy、ix))+(I(iy + 1、 ix + 1)+ I(iy、ix)-I(iy + 1、ix)-I(iy + 1、ix + 1))* x * y + I(iy、ix);
                        エンド
                      
                    エンド
                      値=値+ピクセル;

             
        終了
        投影(fanNum、raynum)=値;
        end        
end
showimge(projection、360,512、min(min(projection))、max(max(projection)));

D-022

おすすめ

転載: blog.csdn.net/ccsss22/article/details/115274040