Info

This question is closed. Reopen it to edit or answer.

how to reduce computation time for this code to 1 minutes

1 view (last 30 days)
clc ;clear;close all;
tic;
out2 = fopen('recon4.raw','wb'); % file handle for writing
In = fopen('sinogram2.raw','rb'); % file handle for read
Ps=100;
res=163.5;
det=1120; %detector size by micro
order = det/2;
H1 = linspace(0, 0.5, order+1);
H1 = [H1 H1(end-1:-1:2)];
pixel=100;
Sd=432039; %sourc to detector by micro
So= 332338; %sourc to isocenter in micro
Sd=Sd/pixel; %sourc to detector by pixel
So=So/(3*pixel); %sourc to isocenter in pixel
p=(det/2)+12;
Fov=floor(det/(Sd/So));
ima=zeros(512,5);
ima22=ima;
[m,n]=size(ima);
data=-log(fread(In,[ det 360],'float')); % data reading part
data=data';
cx=(n)/2;
cy=(m)/2;
Y=fft(data,[],2);
z=bsxfun(@times,Y,H1);
A=real(ifft(z,[],2));
ima=zeros(512,512);
u=1:m;
v=1:n;
X=cx-u;
Y=(So-cx)+v;
D=zeros(m,n);Fd=zeros(m,n); wy1=zeros(m,n); wy2=zeros(m,n);
toc
for i=1:m
for j=1:n
D(i,j)=p-((X(1,i)/Y(1,j))*Sd);
Fd(i,j)=floor(D(i,j));
wy1(i,j)=(Fd(i,j)+1)-D(i,j);
wy2(i,j)= 1-wy1(i,j);
end
end
tic
for L=1:1:360
ddata=A(L,:)./m;
for i=1:m/2
for j=1:n/2
if (D(i,j)) >1 && (D(i,j)) <det
ima(i,j)=((ddata(1 ,Fd(i,j) )*wy1(i,j))+(ddata(1 ,Fd(i,j)+1 )*wy2(i,j)));
end
end
end
ima22=ima22+rotatscal(ima,L,1);
imagesc((ima22)); axis image; colormap gray;
title(L);
pause(0.0001);
end
toc;
% ima22=flipud(ima22);
% ima22=fliplr(ima22);
[Y,I] = min(ima22, [], 2);
ima22(sub2ind(size(ima22), 1:length(I), I')) = 0;
imshow(ima22,[min(min(ima22)) max(max(ima22))]);
fwrite(out2,ima22,'float');
% ima22=fliplr(ima22);
% imagesc(ima22); axis image; colormap gray;
fclose all;

Answers (1)

Matt J
Matt J on 25 May 2013
Maybe by using IRADON or IFANBEAM?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!