Barrel Distortion Correction and Calculating the volume of masks: Difference between pages

From MIPAV
(Difference between pages)
Jump to navigation Jump to search
MIPAV>Olga Vovk
mNo edit summary
 
m (1 revision imported)
 
Line 1: Line 1:
== Background ==
You can calculate the volume of painted voxels, or mask, in an image and view the information about the volume on the Data page of the Output window.<br />


Barrel distortion occurs when the magnification at the center of the lens is greater than at the edges. Fish eye lenses, which take hemispherical views, produce this type of distortion as a result of a hemispherical scene being projected onto a flat surface.  
'''To calculate the volume of masks'''<br />
1 Open an image, and paint the voxels in a desired area of the image.<br />
2 Follow the instructions for manually creating a mask in "Generating masks", "Segmenting Images Using Contours and Masks," <br />
3 ''Do not'' commit the paint, which permanently merges the paint layer with the image layer.<br />
4 Click the Calculate Volume of Paint icon, in the Paint toolbar. <br />
The region grow information (how many voxels or pixels are painted) and the volume of all painted voxels appear on the Data page of the Output window (Figure 9).<br />


Most commonly, barrel distortion appears when using  zoom lenses. This is even more common for lenses with large zoom ranges, or wide angle zoom lenses.  
'''To view the information'''<br />
1 Select the Output window.<br />
2 Select the Data tab on the Output window to view the information. The Data page of the Output window (Figure 9) appears.<br />


Two types of distortion you will see are barrel and pincushion. Barrel distortion has a “bulging” effect, while pincushion distortion is a “sucking” effect that distorts images in an inward sense. Barrel distortion is like wrapping your image around a ball. If you look at it straight on, the center will be bulged out. Pincushion is like pressing your image into a bowl. If you look directly into the bowl, the center will look squeezed.
{| border="1" cellpadding="5"
|+ '''Figure 9. Data page in the Output window (left) listing the region grow and volume information from the painted voxels in the image (right)'''
|-
| rowspan="1" colspan="2" |
[[Image:exampleVolumeOutputWindow.jpg]]
|}


A higher quality lens can be used to correct for distortion; however, this will greatly rise the cost of the image capture system. A cost effective alternative to an expensive lens system is to algorithmically correct for barrel distortion using the presented method.
'''To save the information'''<br />
1 Select File &gt; Save Messages in the Output window. <br />
The Save dialog box opens.<br />
2 Specify a name for the messages file and select a location for storing it. <br />
3 Click Save. The software saves the file and places it in the specified location.<br />


Barrel distortion is primarily radial in nature, therefore it can be corrected using a relatively simple model compensating for the most of the distortion.


The correcting function M(a,b,c,d,r_corr) is a third order polynomial. It relates the distance of a pixel from the center of the source image (r_src) to the corresponding distance in the corrected image (r_corr):


==== Equation 1====
[[Generating graphs]]
 
M = a *r3_corr + b * r2_corr + c * r_corr + d
 
and
 
r_src = (a * r3_corr + b * r2_corr + c * r_corr + d) * r_corr
 
Where r_src and r_corr are specified in units of the min((xDim-1)/2, (yDim-1)/2).
 
Parameters in equation 1 are as follows:
 
* a, b and c describe distortion of the image
* d describes the linear scaling of the image
 
Correcting using a affects only the outermost pixels of the image, while b correction is more uniform. Using negative values for a, b, and c shifts distant points away from the center. This counteracts barrel distortion, and forms the basis for the above corrections.
 
Using positive values for a, b, and c shifts distant points towards the center. This counteracts pincushion distortion which is opposite to barrel distortion. See Figure 2.
 
Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d values scales the image by that amount. See [http://mipav.cit.nih.gov/documentation/HTML%20Algorithms/BarrelDistortionCorrection.html Figure 2].
 
==== Correcting pincushion and/or barrel distortion ====
 
Finally, you may correct pincushion and barrel distortions simultaneously in the same image: if the outer regions exhibit barrel distortion, and the inner parts pincushion, you should use negative a and positive b values. If you do not want to scale the image, you should set d so that a +b + c + d = 1.
 
== Image types ==
 
The algorithm can be applied to RGB and gray 2D images.
 
== Barrel Distortion Correction dialog box ==
 
[[File:BarrelDistDB.jpg|400px|thumb|right|The Barrel/Pincushion Distortion Correction dialog box]]
 
* '''a, b, c, d''' - Correcting using a affects only the outermost pixels of the image. b and c parameters should be used for more uniform correction.
* Using negative values for a, b, and c shifts distant points away from the center of the image. This negates barrel distortions.
* Using positive values for a, b, and c shifts distant points towards the center. This negates pincushion distortions.
* Using d=1, and a=b=c=0 leaves the image as it is. Choosing other d values scales the image by that amount.
* '''Set d=1-a-b-c''' - Activate this option if you do not want to scale the image, e.g. you set d so that a +b + c + d = 1.
* '''OK''' - Applies the parameters that you specified to the image.
* '''Cancel''' - Disregards any changes you made in this dialog box and closes the dialog box.
* '''Help''' - Displays online help for this dialog box.
 
== Applying barrel distortion correction algorithm ==
 
* Open an image of interest.
* Select Algorithms > Transformation tools > Barrel Distortion Correction. The Barrel/Pincushion Distortion Correction dialog box opens.
* Complete the dialog box and click OK.
 
The corrected image appears in a new image frame.
 
[[Category:Help:Stub]]
[[Category:Help:Algorithms]]

Latest revision as of 16:28, 9 February 2024

You can calculate the volume of painted voxels, or mask, in an image and view the information about the volume on the Data page of the Output window.

To calculate the volume of masks
1 Open an image, and paint the voxels in a desired area of the image.
2 Follow the instructions for manually creating a mask in "Generating masks", "Segmenting Images Using Contours and Masks,"
3 Do not commit the paint, which permanently merges the paint layer with the image layer.
4 Click the Calculate Volume of Paint icon, in the Paint toolbar.
The region grow information (how many voxels or pixels are painted) and the volume of all painted voxels appear on the Data page of the Output window (Figure 9).

To view the information
1 Select the Output window.
2 Select the Data tab on the Output window to view the information. The Data page of the Output window (Figure 9) appears.

Figure 9. Data page in the Output window (left) listing the region grow and volume information from the painted voxels in the image (right)

ExampleVolumeOutputWindow.jpg

To save the information
1 Select File > Save Messages in the Output window.
The Save dialog box opens.
2 Specify a name for the messages file and select a location for storing it.
3 Click Save. The software saves the file and places it in the specified location.


Generating graphs