我正在研究使用中心切片定理进行家庭作业的过滤反投影算法,虽然我理解了纸上的理论,但我在 Matlab 中遇到了实现它的问题。我被提供了一个骨架来完成它,但有一个步骤我认为我可能会误解。这是我所拥有的:
function img = sampleFBP(sino,angs)
% This step is necessary so that frequency information is preserved: we pad
% the sinogram with zeros so that this is ensured.
sino = padarray(sino, floor(size(sino,1)/2), 'both');
% diagDim should be the length of an individual row of the sinogram - don't
% hardcode this!
diagDim = size(sino, 2);
% The 2DFT (2D Fourier transform) of our image will start as a matrix of
% all zeros.
fimg = zeros(diagDim);
% Design your 1-d ramp filter.
rampFilter_1d = abs(linspace(-1, 1, diagDim))';
rowIndex = 1;
for nn = angs
% Each contribution to the image's 2DFT will also begin as all zero.
imContrib = zeros(diagDim);
% Get the current row of the sinogram - use rowIndex.
curRow = sino(rowIndex,:);
% Take the 1D Fourier transform the current row - be careful, as it's
% necessary to perform ifftshift and fftshift as Matlab tends to
% place zero-frequency components of a spectrum at the edges.
fourierCurRow = fftshift(fft(ifftshift(curRow)));
% Place the Fourier-transformed sino row and place it at the center of
% the next image contribution. Add the ramp filter in Fourier domain.
imContrib(floor(diagDim/2), :) = fourierCurRow;
imContrib = imContrib * fft(rampFilter_1d);
% Rotate the current image contribution to be at the correct angle on
% the 2D Fourier-space image.
imContrib = imrotate(imContrib, nn, 'crop');
% Add the current image contribution to the running representation of
% the image in Fourier space!
fimg = fimg + imContrib;
rowIndex = rowIndex + 1;
end
% Finally, just take the inverse 2D Fourier transform of the image! Don't
% forget - you may need an fftshift or ifftshift here.
rcon = fftshift(ifft2(ifftshift(fimg)));
我输入的正弦图只是 Shepp-Logan 体模从 0 到 179 度的氡函数的输出。现在运行代码会给我一个黑色图像。我想我在将行的 FT 添加到图像的循环中遗漏了一些东西。根据我对中心切片定理的理解,我认为应该发生的是:
初始化一个与 2DFT 大小相同的数组(即 diagDim x diagDim)。这就是傅立叶空间。
从单个角度取一行与线积分信息相对应的正弦图,并对其应用一维傅立叶变换
根据中心切片定理,该线积分的 FT 是一条通过傅立叶域的线,该线以对应于投影角度的角度穿过原点。因此,为了模拟这一点,我取该线积分的 FT 并将其放在我创建的 diagDim x diagDim 矩阵的中心行
接下来,我将创建的一维斜坡滤波器的 FT 与线积分的 FT 相乘。傅里叶域中的乘法等效于空间域中的卷积,因此这将线积分与滤波器进行卷积。
现在我将整个矩阵旋转投影的角度。这应该给我一个 diagDim x diagDim 矩阵,其中单行信息以一定角度穿过中心。Matlab在旋转时增加了矩阵的大小,但由于正弦图在开始时被填充,没有信息丢失,矩阵仍然可以添加
如果将所有这些带有一条通过中心的线的空矩阵加在一起,它应该会给我完整的 2D FT 图像。所需要做的就是取逆 2D FT,原始图像应该是结果。
如果我遇到的问题是概念性的,如果有人能指出我搞砸的地方,我将不胜感激。如果相反,这是一个 Matlab 的东西(我对 Matlab 还是有点陌生),我会很高兴了解我错过了什么。