Monday, January 14, 2013

Learning Tomography: Advanced DFR Implementation



The Direct Fourier Reconstruction (DFR) implementation previously published (Part II:  [Link]) works correctly. However, the polar to cartesian conversion is not very efficient because there are missing pixels in the 2D Fourier space. Modifying the source code can easily fixed this problem...


The basic implementation is not perfect because when the 2D Fourier space is filled by the 1D-FT of each sinogram row, some pixels are not filled as shown in Fig. 1 displaying the coverage of the 2D Fourier space.

Fig.1: Fill of the 2D Fourier space. As shown in the red zoomed area (B), missing pixels (displayed in black) are never filled by the values of the 1D-FTs during the polar to cartesian conversion.
Thus, to be sure that all the pixels of the Fourier space are correctly filled, we must modify the filling algorithm. Rather than scanning each value of sinogram and computing the X,Y-coordinates of the 2D-Fourier space, it is better (and more flexible) to invert the process by calculating the polar coordinates of the sinogram from the cartesian coordinates of the 2D-Fourier space (Fig.2).

 << Figure >>

The synopsis written in pseudo-code now becomes...

for x=0 to 2DFT_space.height
  for y=0 to
2DFT_space.width
    {radius,theta
} = compute_polar_coordinates_from(x,y)
    value = getInterpolatedPixel(radius,theta,
FT_sinogram)
    2DFT_space.setPixel(x,y,value)
  end for
end for


The conversion of the cartesian coordinate (x,y) to polar (ρ,θ) is defined by the following formula:
ρ = √(x2+y2) with ρ ∈ [0; +maxRadius]
θ = atan2(y,x) with θ ∈ ]-π; π]
Finally, we have to check that the polar coordinates (ρ,θ) are comprised in the range [0;width[ and [0,height[ of the sinogram, respectively.

The corresponding lines of code are ...

   var theta = -Math.atan2(yc,xc) * DEG;
   var rad = Math.sqrt(xc * xc + yc * yc);
   if (theta < 0 ) {
     rad = -rad;
     theta=Math.min(theta+180.0,180.0);
   }



Finally, the new JavaScript implementation is ...

+++ IJ JavaScript snippet: FourierRec.js +++ +++ End of IJ JavaScript snippet +++

Thanks to this new implementation, it is now possible to improve the type of interpolation scheme.

To be continued...


<< Previous: Zero padding
Next:Better interpolation scheme >>

Other crazybiocomputing posts

Further readings are available in ...
  • Learning Tomography Series  [Link]
  • Image Processing TOC [Link]
  •  

No comments:

Post a Comment