Search code examples
matlabimage-processingtomography-reconstruction

Implementation of Radon transform in Matlab, output size


Due to the nature of my problem, I want to evaluate the numerical implementations of the Radon transform in Matlab (i.e. different interpolation methods give different numerical values).

while trying to code my own Radon, and compare it to Matlab's output, I found out that my radon projection sizes are different than Matlab's.

So a bit of intuition of how I compute the amount if radon samples needed. Let's do the 2D case.


The idea is that the maximum size would be when the diagonal (in a rectangular shape at least) part is proyected in the radon transform, so diago=sqrt(size(I,1),size(I,2)). As we dont wan nothing out, n_r=ceil(diago). n_r should be the amount of discrete samples of the radon transform should be to ensure no data is left out.

I noticed that Matlab's radon output is always even, which makes sense as you would want a "ray" through the rotation center always. And I noticed that there are 2 zeros in the endpoints of the array in all cases.

So in that case, n_r=ceil(diago)+mod(ceil(diago)+1,2)+2;

However, it seems that I get small discrepancies with Matlab.

A MWE:

 % Try: 255,256
 pixels=256;
 I=phantom('Modified Shepp-Logan',pixels);

 rd=radon(I,pi/4);
 size(rd,1)

 s=size(I);
 diagsize=sqrt(sum(s.^2));
 n_r=ceil(diagsize)+mod(ceil(diagsize)+1,2)+2

rd=

   367


n_r =

   365

As Matlab's Radon transform is a function I can not look into, I wonder why could it be this discrepancy.


Solution

  • I took another look at the problem and I believe this is actually the right answer. From the "hidden documentation" of radon.m (type in edit radon.m and scroll to the bottom)

    Grandfathered syntax

    R = RADON(I,THETA,N) returns a Radon transform with the projection computed at N points. R has N rows. If you do not specify N, the number of points the projection is computed at is:

       2*ceil(norm(size(I)-floor((size(I)-1)/2)-1))+3
    

    This number is sufficient to compute the projection at unit intervals, even along the diagonal.

    I did not try to rederive this formula, but I think this is what you're looking for.