Filters (Spatial): Adaptive Noise Reduction and Filters (Spatial): Gaussian Blur: Difference between pages

From MIPAV
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
This algorithm reduces noise without blurring the edges by replacing a pixel value with a weighted sum of all local pixels reached by following a path with small pixel intensity values between neighboring pixels.
This algorithm blurs an image or the VOI of the image with a Gaussian function at a user-defined scale sigma (standard deviation [SD]). In essence, convolving a Gaussian function produces a similar result to applying a low-pass or smoothing filter. A'' low-pass filter'' attenuates high-frequency components of the image (i.e., edges) and passes low-frequency components. This results in the blurring of the image. ''Smoothing filters'' are typically used for noise reduction and for blurring. The standard deviation of the Gaussian function controls the amount of blurring. A large standard deviation (i.e., > 2) significantly blurs, while a small standard deviation (i.e., 0.5) blurs less. If the objective is to achieve noise reduction, a rank filter (median) might be more useful in some circumstances.
 
Advantages to convolving the Gaussian function to blur an image include:
 
* Structure is not added to the image.
* It, as well as the Fourier Transform of the Gaussian, can be analytically calculated.
* By varying the SD, a Gaussian scale space can easily be constructed.


=== Background ===
=== Background ===


The Adaptive Noise Reduction algorithm is a port to Adaptive Noise Removal Filter, a software program. This program first transforms ''RGB'' color space into ''YCrCb'' color space. When the filtering is complete, it then transforms the ''YCrCb'' color space into ''RGB'' color space. Hence, all of the color operations occur in ''YCrCb'' space. However, the program does not transform black-and-white images into another space.
The radially symmetric Gaussian, in an ''n''-dimensional space, is:''''
 
Equation 10 <div align "left"> </div><br />
 
[[File:FiltersSpatialGaussianBlur5.jpg]]
 
where [[Image:FiltersSpatialGaussianBlur6.jpg]] (referred to as the ''scale''), is the standard deviation of the Gaussian and is a free parameter that describes the width of the operator (and thus the degree of blurring) and ''n'' indicates the number of dimensions.
 
Geometric measurements of images can be obtained by spatially convolving (shift-invariant and linear operation) a Gaussian neighborhood operator with an image, ''I'', where [[Image:FiltersSpatialGaussianBlur7.jpg]] represents an ''n''-dimensional image. The convolution process produces a weighted average of a local neighborhood where the width of the neighborhood is a function of the scale of the Gaussian operator. The scale of the Gaussian controls the resolution of the resultant image and thus the size of the structures that can be measured. A scale-space for an image [[Image:FiltersSpatialGaussianBlur8.jpg]]of increasingly blurred images can be defined by L:nx''[[Image:FiltersSpatialGaussianBlur9.jpg]] [[Image:FiltersSpatialGaussianBlur10.jpg]]'' and ''[[Image:FiltersSpatialGaussianBlur11.jpg]]'' where [[Image:xcirclenm.jpg]] represents convolution.
 
The following is the calculation of the full-width half max (FWHM) of the Gaussian function.


In "Frequently Asked Questions About Color," Charles Poynton reveals that the ''RGB''-to-''YCrCb'' and ''YCrCb''-to-''RGB'' conversion equations used in Adaptive Noise Removal Filter differ significantly from standard ones. First, the program creates an edge graph or pixel neighbor graph using a weakly median-filtered version of the ''YCrCb'' space. A weakly median-filter version means that median filtering only occurs if the pixel is not on an edge in ''Y'', ''Cr'', or ''Cb'' space. The edge graph is an array of arrays with the first array having a length equal to the number of pixels in the image and the second array having eight edge weights. The eight edge weights are calculated from the intensity differences between the center pixel and one of the eight neighboring pixels:
<div>


{| border="1" cellpadding="5"
|+
|-
|
<math>
<math>
E =\sqrt{((dYwY)^2 + (dRwR)^2 + (dBwB)^2)}
G(x, \sigma) = \frac {1}{\sqrt {2\pi\sigma^2}}e^{-\frac {x^2} {2\sigma^2}}
</math>
</math>
**converting color;<br />


where ''E'' is the edge weight; ''dY'', ''dR'', and ''dB'' are the ''Y'', ''Cr'', and ''Cb'' differences; and ''wY'', ''wR'', and ''wB'' are the ''Y'', ''Cr'', and ''Cb'' weights derived from the ''Y'', ''Cr'', and ''Cb'' radiuses. A bigger relative radius results in a smaller weight for radiuses &gt;= 0.1, which is typically the case.
<math>
ln 0.5 \frac {1}{\sqrt {2\pi \sigma^2}} = ln \left ( \frac {1}{\sqrt {2\pi\sigma^2}}e^{-\frac {x^2} {2\sigma^2}} \right )
</math>


After the edge graph is created, the program filters the ''Y'', ''Cr,'' and ''Cb'' spaces separately. It uses the selected pixel as the center of a square with ''L'' = 2''R'' 1 where ''L'' = sides of length, ''R'' = range, and range = (int)(radius 0.999).
<math>
ln0.5 + ln \left ( \frac {1}{\sqrt {2\pi\sigma^2}} \right ) =ln \left ( \frac {1}{\sqrt {2\pi\sigma^2}} \right ) + ln \left (e^{-\frac {x^2} {2\sigma^2}} \right )
</math>


The ''enhancePixel ''function returns the filtered pixel value at every pixel in the image. If neighboring pixels are connected to the center pixel via a low-cost path, queue elements corresponding to these neighboring pixels are added to the priority queue. If no queue element is retrieved from the queue, then the original pixel value is passed unchanged. If elements are retrieved from the queue, then those ''Y, Cr,'' or ''Cb'' pixel values that retrieved queue elements are put into a weighted sum. The weight is derived from an index into the filter array given by the queue element key times the invFilterLen. The filter array is generated with a Gaussian function.
<math>
 
-0.693 = - \frac {x^2} {2\sigma^2}
Each queue element has a value, a baseKey, and a key. The ''value'' gives the location within the local [[Image:FiltersSpatialAdaptiveNoiseReduction8.jpg]] local square where ''R'' = range. The ''baseKey'' has a sum of the edgeGraph values over the low-cost path from the center pixel to the selected pixel, and ''key'' is equal to the sum of baseKey and the distMap value for the selected pixel. The distMap value at a given position inside the local square is equal to the edge preservation strength times the distance from the center pixel. A key is only added to the queue if key &lt; maxDistance:''''
</math>


<math>
<math>
M = (int)(Rd(S+512))
1.18\sigma = x
</math>
</math>


where ''M'' = maxDistance, ''Rd'' = radius, and ''S'' = edge preservation strength.
|}


The priority queue is implemented as a binary heap and the binary heap is implemented as an array. A binary heap is a nearly full binary tree (only the bottom level may not be complete). This binary heap has the property that for every node other than a leaf, its key value is less than or equal to that of its children. In a binary heap the item of highest priority is always at the root of the tree or at node 0. When the highest priority item at the root is removed, the item of highest priority among the remainder moves into the root position. The children of node ''i'' are at [[Image:FiltersSpatialAdaptiveNoiseReduction10.jpg]] and [[Image:FiltersSpatialAdaptiveNoiseReduction11.jpg]]. The parent of node ''i'' is at <math>
(int) \left ( \frac {i-1}{2} \right )
</math>.


The filter radius can be separately adjusted for each ''Y, Cr,'' and ''Cb'' channel for color images. For black-and-white images only, the ''Y'' filter radius can be adjusted. A larger radius removes more noise but loses more detail.
Figure 2 shows the Gaussian function. The dotted lines indicate the standard deviation of 1. The FWHM is indicated by the solid lines. For a Gaussian with a standard deviation equal to 1 ([[Image:FiltersSpatialGaussianBlur13.jpg]]), the FWHM is 2.36.


<div>
<div>


{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
|+ <div>'''Figure 1. Adaptive Noise Reduction processing''' </div>
|+ <div>'''Figure 1. Gaussian Blur algorithm processing''' </div>
|-
|-
|
|
<div><div><center>[[Image:exampleAdaptiveNoiseReduction.jpg]]</center></div> </div>
<div><div align="left">[[Image:GaussianBlurProcessing2.jpg]]</div> </div>
|}
|}


  </div>
  </div>


The edge preservation strength can be adjusted. Larger values preserve more edges but sacrifice smoothness in low-contrast areas. Very large values may cause banding.
Figure 1 shows a Gaussian scale-space of the sagittal view of a MR head image. The original image is shown in the upper left ([[Image:FiltersSpatialGaussianBlur14.jpg]]). Varying ''s'' from 0.5 to 5.5 in steps of 0.5 blurs the other images (from left to right and top to bottom).
 
<div>
 
{| border="1" cellpadding="5"
|+ <div>'''Figure 2. Gaussian function''' </div>
|-
|
<div><div align="left">[[Image:GaussianFunction3.jpg]]</div> </div>
|}


To speed the filtering on color images, you can select the Filter ''Cr'' and ''C''b at halv''e''d dimensions check box. When run, the algorithm shrinks the Cr and'' Cb'' spaces by a factor of 2, generates an edge table for the shrunken space, filters the image, and then expands the filtered ''Cr'' and ''Cb'' spaces to their original dimensions. Although the algorithm runs faster, it also loses some details.
</div>


The New image option causes MIPAV to place the resulting image in a new image window. The Replace image option causes MIPAV to place the changed image in the same window.
Note that as the scale increases, small-scale features are suppressed. For example, at small scales the individual folds of the brain are quite defined, but, as the scale increases, these folds diffuse together resulting in the formation of a region one might define as the brain.


==== Image types ====
==== Image types ====


You can apply this algorithm to all image data types except Complex and to 2D, 2.5D, 3D, and 4D images.


 
* By default, the resultant image is a float type image.
You can apply this algorithm to both color and black-and-white 2D images.
* By selecting Process each slide independently (2.5D) in the Gaussian Blur dialog box, you can achieve 2.5D blurring (each slice of the volume is blurred independently) of a 3D dataset (Figure 1).


==== Special notes ====
==== Special notes ====
Line 61: Line 92:
==== References ====
==== References ====


Refer to the following references for more information:
See the following references for more information about this algorithm:


Karlis Freivalds, "Adaptive Noise Removal Filter," a software program, University of Latvia, Institute of Mathematics and Computer Science, at http://www.gradetools.com/karlisf.
J. J. Koenderink, "The Structure of Images," ''Biol Cybern'' 50:363-370, 1984.


Charles Poynton, "Frequently Asked Questions About Color," at http://www.poynton.com.
J. J. Koenderink and A. J. van Doorn, "Receptive Field Families," ''Biol Cybern'' 63:291-298, 1990.


=== Applying the Adaptive Noise Reduction algorithm ===
Tony Lindeberg, "Linear Scale-Space I: Basic Theory," ''Geometry-Driven Diffusion in Computer Vision'', Bart M. Ter Har Romeney, ed. (Dordrecht, The Netherlands: Kluwer Academic Publishers, 1994), pp. 1-38.


R. A. Young, "The Gaussian Derivative Model for Machine Vision: Visual Cortex Simulation," ''Journal of the Optical Society of America'', GMR-5323, 1986.
=== Applying the Gaussian Blur algorithm ===


To run this algorithm, complete the following steps:
To run this algorithm, complete the following steps:


# Open an image.
# Select Algorithms &gt; Filter &gt; Gaussian Blur. The Gaussian Blur dialog box opens (Figure 3).
# Perform, as an option, any image processing, such as improving the contrast, on the image.
# Select Algorithms &gt; Filters (spatial) &gt; Adaptive noise reduction. The Adaptive Noise Reduction dialog box opens.
# Complete the information in the dialog box.
# Complete the information in the dialog box.
# Click OK. The algorithm begins to run.
# Click OK.
 
; A pop-up window appears with the status. A series of status messages appear in the window.
; When the algorithm finishes running, the pop-up window closes.
; Depending on whether you selected New image or Replace image, the results appear in a new window or replace the image to which the algorithm was applied.
 
<div>


; The algorithm begins to run, and a pop-up window appears with the status. The following message appears: "Blurring Image."
; When the algorithm finishes running, the pop-up window closes, and the results appear in either a new window or replace the image to which the algorithm was applied.
{| border="1" cellpadding="5"
{| border="1" cellpadding="5"
|+ <div>'''Figure 2. Adaptive Noise Reduction dialog box''' </div>
|+ <div>'''Figure 3. Gaussian Blur dialog box ''' </div>
|-
|
<div>'''X Dimension''' </div>
|
<div>Indicates the standard deviation (SD) of Gaussian in the ''X'' direction. </div>
| rowspan="8" colspan="1" |
<div><br /> </div><div><br /> </div><div><br /> </div><div><div align="left">[[Image:dialogboxGaussianBlur.jpg]]</div> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div><div><br /> </div>
|-
|
<div>'''Y Dimension''' </div>
|
<div>Indicates the SD of Gaussian in the ''Y'' direction. </div>
|-
|-
|
|
<div>'''Y radius''' </div>
<div>'''Z Dimension''' </div>
|
|
<div>Specifies the local square used for ''Y'' space filtering, which is approximately [[Image:FiltersSpatialAdaptiveNoiseReductionlz.jpg]]in size.  </div><div>As the radius increases, the algorithm removes more noise, but loses more detail. The default value is 2.0. </div>
<div>Indicates the SD of Gaussian in the ''Z'' direction. </div>
| rowspan="2" colspan="1" |
<div><div><center>[[Image:dialogboxAdaptiveNoiseReduction.jpg]]</center></div> </div><div> </div>
|-
|-
|
|
<div>'''Cr radius''' </div>
<div>'''Use image resolutions to normalize Z scale''' </div>
|
|
<div>Specifies the local square used for ''Cr ''space filtering (only available for color), which is approximately <div align="left">[[Image:FiltersSpatialAdaptiveNoiseReduction3.jpg]]</div> in size. </div><div>As the radius increases, the algorithm removes more noise, but loses more detail. The default value is 4.0. </div>
<div>Normalizes the Gaussian to compensate for the difference if the voxel resolution is less between slices than the voxel resolution in-plane. This option is selected by default. </div>
|-
|-
|
|
<div>'''Cb radius''' </div>
<div>'''Process each slice independently (2.5D)''' </div>
| rowspan="1" colspan="2" |
|
<div>Specifies the local square used for ''Cb'' space filtering, which is approximately [[Image:FiltersSpatialAdaptiveNoiseReduction4.jpg]]in size. As the radius increases, the algorithm removes more noise but loses more detail. The default value is 5.0. </div>
<div>Blurs each slice of the dataset independently of adjacent slices. </div>
|-
|
<div>'''Process red channel''' </div>
|
<div>Applies the algorithm to the red channel only. </div>
|-
|-
|
|
<div>'''Edge preservation strength''' </div>
<div>'''Process green channel''' </div>
| rowspan="1" colspan="2" |
|
<div>Specifies a value for preserving edges. Larger values preserve more edges but sacrifice smoothness in low-contrast areas. Very large values may cause banding.  </div><div>For color images, the default value is 3072.0. For black-and-white images, the default value is [[Image:FiltersSpatialAdaptiveNoiseReduction5.jpg]] where ''IMx'' is image maximum and ''IMn'' is image minimum. </div>
<div>Applies the algorithm to the green channel only. </div>
|-
|-
|
|
<div>'''Filter Cr and Cb at halved dimensions''' </div>
<div>'''Process blue channel''' </div>
| rowspan="1" colspan="2" |
|
<div>Causes the algorithm to run faster but with some loss of detail. For color images, the default value is enabled; for other images, the default value is disabled. </div>
<div>Applies the algorithm to the blue channel only. </div>
|-
|-
|
|
Line 122: Line 165:
<div>'''Replace image''' </div>
<div>'''Replace image''' </div>
| rowspan="1" colspan="2" |
| rowspan="1" colspan="2" |
<div>Replaces the original source image with the results of the algorithm. </div>
<div>Replaces the current active image with the results of the algorithm. </div>
|-
|
<div>'''Whole image''' </div>
| rowspan="1" colspan="2" |
<div>Applies the algorithm to the whole image. </div>
|-
|
<div>'''VOI region(s)''' </div>
| rowspan="1" colspan="2" |
<div>Applies the algorithm to the volumes (regions) delineated by the VOIs. </div>
|-
|-
|
|
<div>'''OK''' </div>
<div>'''OK''' </div>
| rowspan="1" colspan="2" |
| rowspan="1" colspan="2" |
<div>Applies the algorithm according to the specifications in this dialog box. </div>
<div>Applies the algorithm according to the specifications in this dialog box. </div>
|-
|-
|
|
<div>'''Cancel ''' </div>
<div>'''Cancel''' </div>
| rowspan="1" colspan="2" |
| rowspan="1" colspan="2" |
<div>Disregards any changes you made in this dialog box and closes the dialog box. </div>
<div>Disregards any changes that you made in this dialog box and closes the dialog box. </div>
|-
|-
|
|
Line 139: Line 192:
<div>Displays online help for this dialog box. </div>
<div>Displays online help for this dialog box. </div>
|}
|}
</div>


[[Category:Help]]
[[Category:Help]]
[[Category:Help:Algorithms]]
[[Category:Help:Algorithms]]

Latest revision as of 16:28, 9 February 2024

This algorithm blurs an image or the VOI of the image with a Gaussian function at a user-defined scale sigma (standard deviation [SD]). In essence, convolving a Gaussian function produces a similar result to applying a low-pass or smoothing filter. A low-pass filter attenuates high-frequency components of the image (i.e., edges) and passes low-frequency components. This results in the blurring of the image. Smoothing filters are typically used for noise reduction and for blurring. The standard deviation of the Gaussian function controls the amount of blurring. A large standard deviation (i.e., > 2) significantly blurs, while a small standard deviation (i.e., 0.5) blurs less. If the objective is to achieve noise reduction, a rank filter (median) might be more useful in some circumstances.

Advantages to convolving the Gaussian function to blur an image include:

  • Structure is not added to the image.
  • It, as well as the Fourier Transform of the Gaussian, can be analytically calculated.
  • By varying the SD, a Gaussian scale space can easily be constructed.

Background

The radially symmetric Gaussian, in an n-dimensional space, is:'

Equation 10


FiltersSpatialGaussianBlur5.jpg

where FiltersSpatialGaussianBlur6.jpg (referred to as the scale), is the standard deviation of the Gaussian and is a free parameter that describes the width of the operator (and thus the degree of blurring) and n indicates the number of dimensions.

Geometric measurements of images can be obtained by spatially convolving (shift-invariant and linear operation) a Gaussian neighborhood operator with an image, I, where FiltersSpatialGaussianBlur7.jpg represents an n-dimensional image. The convolution process produces a weighted average of a local neighborhood where the width of the neighborhood is a function of the scale of the Gaussian operator. The scale of the Gaussian controls the resolution of the resultant image and thus the size of the structures that can be measured. A scale-space for an image FiltersSpatialGaussianBlur8.jpgof increasingly blurred images can be defined by L:nxFiltersSpatialGaussianBlur9.jpg FiltersSpatialGaussianBlur10.jpg and FiltersSpatialGaussianBlur11.jpg where Xcirclenm.jpg represents convolution.

The following is the calculation of the full-width half max (FWHM) of the Gaussian function.


Figure 2 shows the Gaussian function. The dotted lines indicate the standard deviation of 1. The FWHM is indicated by the solid lines. For a Gaussian with a standard deviation equal to 1 (FiltersSpatialGaussianBlur13.jpg), the FWHM is 2.36.

Figure 1. Gaussian Blur algorithm processing
GaussianBlurProcessing2.jpg

Figure 1 shows a Gaussian scale-space of the sagittal view of a MR head image. The original image is shown in the upper left (FiltersSpatialGaussianBlur14.jpg). Varying s from 0.5 to 5.5 in steps of 0.5 blurs the other images (from left to right and top to bottom).

Figure 2. Gaussian function
GaussianFunction3.jpg

Note that as the scale increases, small-scale features are suppressed. For example, at small scales the individual folds of the brain are quite defined, but, as the scale increases, these folds diffuse together resulting in the formation of a region one might define as the brain.

Image types

You can apply this algorithm to all image data types except Complex and to 2D, 2.5D, 3D, and 4D images.

  • By default, the resultant image is a float type image.
  • By selecting Process each slide independently (2.5D) in the Gaussian Blur dialog box, you can achieve 2.5D blurring (each slice of the volume is blurred independently) of a 3D dataset (Figure 1).

Special notes

None.

References

See the following references for more information about this algorithm:

J. J. Koenderink, "The Structure of Images," Biol Cybern 50:363-370, 1984.

J. J. Koenderink and A. J. van Doorn, "Receptive Field Families," Biol Cybern 63:291-298, 1990.

Tony Lindeberg, "Linear Scale-Space I: Basic Theory," Geometry-Driven Diffusion in Computer Vision, Bart M. Ter Har Romeney, ed. (Dordrecht, The Netherlands: Kluwer Academic Publishers, 1994), pp. 1-38.

R. A. Young, "The Gaussian Derivative Model for Machine Vision: Visual Cortex Simulation," Journal of the Optical Society of America, GMR-5323, 1986.

Applying the Gaussian Blur algorithm

To run this algorithm, complete the following steps:

  1. Select Algorithms > Filter > Gaussian Blur. The Gaussian Blur dialog box opens (Figure 3).
  2. Complete the information in the dialog box.
  3. Click OK.
The algorithm begins to run, and a pop-up window appears with the status. The following message appears
"Blurring Image."
When the algorithm finishes running, the pop-up window closes, and the results appear in either a new window or replace the image to which the algorithm was applied.
Figure 3. Gaussian Blur dialog box
X Dimension
Indicates the standard deviation (SD) of Gaussian in the X direction.



DialogboxGaussianBlur.jpg













Y Dimension
Indicates the SD of Gaussian in the Y direction.
Z Dimension
Indicates the SD of Gaussian in the Z direction.
Use image resolutions to normalize Z scale
Normalizes the Gaussian to compensate for the difference if the voxel resolution is less between slices than the voxel resolution in-plane. This option is selected by default.
Process each slice independently (2.5D)
Blurs each slice of the dataset independently of adjacent slices.
Process red channel
Applies the algorithm to the red channel only.
Process green channel
Applies the algorithm to the green channel only.
Process blue channel
Applies the algorithm to the blue channel only.
New image
Shows the results of the algorithm in a new image window.
Replace image
Replaces the current active image with the results of the algorithm.
Whole image
Applies the algorithm to the whole image.
VOI region(s)
Applies the algorithm to the volumes (regions) delineated by the VOIs.
OK
Applies the algorithm according to the specifications in this dialog box.
Cancel
Disregards any changes that you made in this dialog box and closes the dialog box.
Help
Displays online help for this dialog box.