function backProjImg = backProj(Sinogram,theta)
%%https://www.clear.rice.edu/elec431/projects96/DSP/filters.html
%For the paper on the process
%Modified 
%limiting the size of the picture
ParaProj = size(Sinogram,1);
AngProj  = length(theta); 

theta = (pi/180)*theta;

%making the back projection 
backProjImg = zeros(ParaProj,ParaProj);

%
midindex = floor(ParaProj/2) + 1;

[X,Y] = meshgrid(ceil(-ParaProj/2):ceil(ParaProj/2-1));

%making each projection 
for i = 1:AngProj
    %rotating the image
    rotation = round(midindex + X*sin(theta(i)) + Y*cos(theta(i)));
    j   = find((rotation > 0) & (rotation <= ParaProj));
    newCoords = rotation(j);
    
    backProjImg(j) = backProjImg(j) + Sinogram(newCoords,i)./AngProj;
   %let's draw the image out
    imagesc(backProjImg)
    drawnow
end
