还有吗,我想要MIT的图像重建的Matlab反投影代码
时间: 2023-06-16 13:05:07 浏览: 73
MIT图像重建的Matlab反投影代码如下:
```matlab
function [recon_img, proj_geom] = backproj(recon_matrix, proj_geom)
% function [recon_img, proj_geom] = backproj(recon_matrix, proj_geom)
% Backproject a sinogram into an image.
%
% Input:
% recon_matrix - The sinogram of the object to be reconstructed.
% proj_geom - Structure that defines the geometry of the
% projection data. See create_proj_geom for details.
%
% Output:
% recon_img - The reconstructed image.
% proj_geom - Same as input, but with additional fields added
% containing information about the image and grid.
%
% J. Bian (jb696@cornell.edu), last update: 2019-12-18
% check input
if ~isfield(proj_geom, 'filter') || isempty(proj_geom.filter)
proj_geom.filter = 'ram-lak';
end
% backprojection
if strcmpi(proj_geom.filter, 'none')
% unfiltered backprojection
recon_img = iradon(recon_matrix, proj_geom.angles, 'linear', 'none', proj_geom.recon_size);
else
% apply filter
if strcmpi(proj_geom.filter, 'ram-lak')
freqs = 0 : (proj_geom.n_channels-1)/proj_geom.width : (proj_geom.n_channels-1)/2;
freqs = [-freqs(end:-1:2) freqs];
filt = abs(freqs);
filt = filt/max(filt);
elseif strcmpi(proj_geom.filter, 'shepp-logan')
freqs = 0 : (proj_geom.n_channels-1)/proj_geom.width : (proj_geom.n_channels-1)/2;
filt = abs(freqs) .* [ones(1, floor(proj_geom.n_channels/4)) zeros(1, ceil(proj_geom.n_channels/2)) ones(1, floor(proj_geom.n_channels/4))];
filt = filt/max(filt);
elseif strcmpi(proj_geom.filter, 'cosine')
freqs = 0 : (proj_geom.n_channels-1)/proj_geom.width : (proj_geom.n_channels-1)/2;
filt = abs(freqs) .* cos(pi/2*abs(freqs)/max(freqs));
filt = filt/max(filt);
elseif strcmpi(proj_geom.filter, 'hamming')
freqs = 0 : (proj_geom.n_channels-1)/proj_geom.width : (proj_geom.n_channels-1)/2;
filt = abs(freqs) .* (0.54 + 0.46*cos(pi*abs(freqs)/max(freqs)));
filt = filt/max(filt);
elseif strcmpi(proj_geom.filter, 'hann')
freqs = 0 : (proj_geom.n_channels-1)/proj_geom.width : (proj_geom.n_channels-1)/2;
filt = abs(freqs) .* (1 + cos(pi*abs(freqs)/max(freqs))) / 2;
filt = filt/max(filt);
else
error(['Unsupported filter: ' proj_geom.filter]);
end
% filter and backproject
n_angles = length(proj_geom.angles);
n_channels = size(recon_matrix, 2);
proj_geom.n_channels = n_channels;
if proj_geom.recon_size(1) == n_channels
% square image
filt_matrix = repmat(filt, [n_angles 1]);
filt_matrix = [filt_matrix(:, end:-1:2) filt_matrix];
filt_matrix = repmat(filt_matrix, [1 proj_geom.recon_size(1)]);
proj_geom.grid_spacing = proj_geom.width/proj_geom.recon_size(1);
recon_img = iradon(recon_matrix .* filt_matrix, proj_geom.angles, 'linear', 'none', proj_geom.recon_size);
elseif proj_geom.recon_size(1) == n_channels/2+1
% cylindrical image
filt_matrix = repmat(filt, [n_angles 1]);
filt_matrix = [filt_matrix filt_matrix(:, end-1:-1:1)];
filt_matrix = repmat(filt_matrix, [1 proj_geom.recon_size(1)]);
proj_geom.grid_spacing = proj_geom.width/proj_geom.recon_size(1);
recon_img = iradon(recon_matrix .* filt_matrix, proj_geom.angles, 'linear', 'none', proj_geom.recon_size, 'Filter', 'none');
recon_img = recon_img(:, end:-1:1);
else
error('Invalid reconstruction size.');
end
end
% set up the grid
proj_geom.grid_offset = -proj_geom.width/2;
proj_geom.grid = proj_geom.grid_offset + proj_geom.grid_spacing*(0:proj_geom.recon_size(1)-1);
proj_geom.grid2D = proj_geom.grid;
proj_geom.grid2D = repmat(proj_geom.grid2D, [proj_geom.recon_size(2) 1]);
proj_geom.grid2D = permute(proj_geom.grid2D, [2 1]);
proj_geom.grid2D = flipud(proj_geom.grid2D);
proj_geom.grid2D = reshape(proj_geom.grid2D, [1 proj_geom.recon_size(1) proj_geom.recon_size(2)]);
proj_geom.grid2D = repmat(proj_geom.grid2D, [proj_geom.recon_size(1) 1 1]);
proj_geom.grid3D = zeros([proj_geom.recon_size 3]);
proj_geom.grid3D(:, :, 1) = proj_geom.grid2D;
proj_geom.grid3D(:, :, 2) = flipud(proj_geom.grid2D);
proj_geom.grid3D(:, :, 3) = -proj_geom.width/2;
end
```
请注意,此代码需要输入一个名为`proj_geom`的结构体,该结构体定义了投影数据的几何形状和重建图像的几何形状。您可以使用`create_proj_geom`函数来创建这个结构体。
此代码还使用了MATLAB的`iradon`函数,该函数可以通过反向投影将投影数据转换为图像。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)