Wednesday, August 29, 2012

Learning Tomography: Managing Borders




How to manage borders in sinogram computation ?




1. Borders

When computing a sinogram, the problem of the border arises. Indeed, during the image rotation, the function Image > Transform > Rotate... fills the empty space by the current background color as shown in Fig. 1. Thus, the various projections are not calculated from the same number of pixels. Which strategy is the best?

Fig.1: During the sinogram creation, the empty space generated by the rotation is filled with the current background color (here, black by default).

1.1- Black background color
The simplest method is to set a black background color (0,0,0) as shown before using the following javascript method:

IJ.setBackgroundColor(0,0,0);

1-2- Use of the  average as background value.
This is a two-step procedure. First, you need to compute the image statistics and then convert the mean value into a 8-bit value (range 0.. 255).
var stats = imp.getStatistics();
var avg=stats.mean/(stats.max - stats.min) *255;
IJ.setBackgroundColor(avg,avg,avg);
Fig.2: Rotation with background color set to the average of input image.
Note: In the JavaScript sinogram.js, I implemented this approach, by default.
1-3- Use of a circular mask
In this case, you apply a circular mask to the original data, then compute the sinogram with a black background color.

To conclude, the influence of the background value for the sinogram computation is clearly visible in the example of Fig. 3.

Fig.3: Influence of the borders. Top left: Original image: 3 black beads and a white background. 2D reconstructions with sinogram calculated with a black background (top middle) and with the average (top right), respectively. Top middle: The artifact appears as a four-leaf-clover shadow corresponding to the influence of the corners during the reconstruction.


2- Reconstruction of the corners


If you want to reconstruct the whole area of the input image specially the corners, you have to compute a larger image whose size is equal to imageWidth * √2 before calculating the sinogram. In that case, the "average" method seen previously works correctly, but there are other more sophisticated alternatives...

2-1- Creation of a seamless image
First, an image composed of 9 tiles corresponding to combinations of vertically and/or horizontally flips is created as shown in Fig.4...

Fig.4: Montage to build the seamless image

... and then, this montage is cropped to a square of dimension equal to the image diagonal ( = imgWidth * √2 ) and is used for the sinogram computation (Fig. 5A).
Fig.5: A) Seamless image used to compute the sinogram. The size of this image is 266x266 pixels (=188 * √2). B) 2D reconstruction image computed from sinogram of (A) which is cropped to the original image size (ie 188x188 pixels). C) Final reconstruction. The whole area was correctly reconstructed.
+++ IJ JavaScript snippet +++ +++ end of IJ JavaScript snippet +++

2-2- Circular border
W o r k   i n   P r o g r e s s
Fig.6: Circular border composed of several dilations of the original image.


I personally think that the "average"  and "circular mask" methods have the best ratio speed/efficiency because in most cases, you don't bother about the corners as far as the sample is well centered.

Other crazybiocomputing posts

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


No comments:

Post a Comment