Problem :
I am facing following error message:
Index in position 1 is invalid. Array indices must be positive integers or logical values.
My code is as follows:
clc;
close all;
clear;
PD=phantom('Modified Shepp-Logan');
padimage = [2,2];
PD= padarray(PD,padimage);
subplot(2,3,1)
imagesc(PD);
colormap('gray');
title('Circle Phantom')
xlabel('X')
ylabel('Y')
freq = 2;
thetas = 0:freq:180;
gtheta = length(thetas);
gl = size(PD,1);
sinogram = zeros(gl,gtheta);
for i = 1:length(thetas)
tmpImage = imrotate(PD,-thetas(i),'bilinear','crop');
sinogram(:,i) = sum(tmpImage);
end
subplot(2,3,2)
imagesc(sinogram);
title('Circle Sinogram');
xlabel('l');
ylabel('\theta');
thetas=0;
Fl = size(sinogram,1);
Ftheta = length(thetas);
thetas = (pi/180)*thetas;
g0 = zeros(Fl,Fl);
Fmid = ceil(Fl/2);
[x,y] = meshgrid(ceil(-Fl/2):ceil(Fl/2-1));
for i = 1:Ftheta
rotCoords = Fmid+round(x*sin(thetas(i)) + y*cos(thetas(i)));
rotCoords=floor(abs(rotCoords));
g0 = g0 + sinogram(rotCoords,i)./Ftheta;
end
subplot(2,3,3);
imagesc(g0);
title('Simple backprojection')
xlabel('X')
ylabel('Y')
The error message is occurring as follow:
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Can anybody tell me why the issue is here?