Welcome to the Harris Geospatial documentation center. Here you will find reference guides and help documents.


  >  Docs Center  >  Using ENVI  >  Convolution and Morphology Filters

ENVI

Convolution and Morphology Filters

Convolution and Morphology Filters

Use Convolutions and Morphology to apply convolution filters or morphology filters to image data.

Note about Data Type Conversions


The original data type will be converted as follows for most filters. The numbers in parentheses are the ranges of pixel values:

  • Byte (0 to 255) converts to signed integer (-32,768 to 32,768)
  • Unsigned integer (0 to 65,535) converts to signed integer (-32,768 to 32,768)
  • Unsigned long integer (0 to 4,294,967,296) converts to long integer (-2,147,483,648 to 2,147,483,647)

For the Roberts and Median filters, the data type is always set to signed integer.

You may need to rescale the original data to signed integer or long integer before applying filters, to avoid data-wrapping issues.

Convolution Filters


Convolution filters produce output images in which the brightness value at a given pixel is a function of some weighted average of the brightness of the surrounding pixels. Convolution of a user-selected kernel with the image array returns a new, spatially filtered image. You can select the kernel size and values, producing different types of filters. Standard convolution filters include:

  • High Pass: Removes the low frequency components of an image while retaining the high frequency (local variations). It can enhance edges between different regions as well as to sharpen an image. It uses a kernel with a high central value, typically surrounded by negative weights. ENVI’s default high pass filter uses a 3x3 kernel with a value of 8 for the center pixel and values of -1 for the exterior pixels. High pass filters can only have odd kernel dimensions. (You can also write a script to apply a high pass filter to a raster, using ENVIHighPassFilterTask.)
  • Low Pass: Preserves the low frequency components of an image, which smoothes it. ENVI’s low pass filter contains the same weights in each kernel element, replacing the center pixel value with an average of the surrounding values. The default kernel size is 3x3. (You can also write a script to apply a low pass filter to a raster, using ENVILowPassFilterTask.)
  • Laplacian: A second derivative edge enhancement filter that operates without regard to edge direction. Laplacian filtering emphasizes maximum values within the image by using a kernel with a high central value typically surrounded by negative weights in the north-south and east-west directions and zero values at the kernel corners. ENVI’s default Laplacian filter uses a 3x3 kernel with a value of 4 for the center pixel and values of -1 for the north-south and east-west pixels. All Laplacian filters must have odd kernel sizes. (You can also write a script to apply a low pass filter to a raster, using ENVILaplacianFilterTask.)
  • Directional: A first derivative edge enhancement filter that selectively enhances image features having specific direction components (gradients). The sum of the directional filter kernel elements is zero. The result is that areas with uniform pixel values are zeroed in the output image, while those that are variable are presented as bright edges. (You can also write a script to apply a low pass filter to a raster, using ENVIDirectionalFilterTask.)
  • Gaussian Low Pass: Used for image smoothing. It uses a kernel defined by a 2D Gaussian function with standard deviation N/8. (You can also write a script to apply a low pass filter to a raster, using ENVIGaussianLowPassFilterTask.)
  • Gaussian High Pass: Uses unsharp masking to enhance local image variations. It operates by subtracting a low pass (Gaussian Low Pass) version of the image to enhance the high frequency components. (You can also write a script to apply a low pass filter to a raster, using ENVIGaussianHighPassFilterTask.)
  • Median: Smooths an image, while preserving edges larger than the kernel dimensions (good for removing speckling noise). ENVI’s Median filter replaces each center pixel with the median value (not to be confused with the average) within the neighborhood specified by the filter size. The default is a 3x3 kernel. (You can also write a script to apply a Median filter to a raster, using ENVIMedianFilterTask.) The resulting image will be cast to an integer data type.
  • Sobel: A non-linear edge enhancement, special case filter that uses an approximation of the true Sobel function, and is a preset 3x3, non-linear edge enhancement operator. The size of the filter cannot be changed and no kernel editing is possible. (You can also write a script to apply a Sobel filter to a raster, using ENVISobelFilterTask.)
  • Roberts: A non-linear edge detector filter similar to the Sobel. It is a special case filter that uses a preset 2x2 approximation of the true Roberts function, a simple, 2D differencing method for edge-sharpening and isolation. The size of the filter cannot be changed and no kernel editing is possible. (You can also write a script to apply a Roberts filter to a raster, using ENVIRobertsFilterTask.) The resulting image will be cast to an integer data type.
  • User-Defined Convolution: You can define custom convolution kernels (including rectangular rather than square filters) by selecting and editing a user kernel. (You can also write a script to apply a user-defined convolution filter to a raster with ENVIRasterConvolutionTask.)

Mathematical morphology filtering is a non-linear method of processing digital images on the basis of shape. Its primary goal is the quantification of geometrical structures.

Reference

Haralick, Sternberg, and Zhuang, Image Analysis Using Mathematical Morphology, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. PAMI-9, No. 4, July 1987, pp. 532-550.

  1. From the Toolbox, select Filter > Convolutions and Morphology. The Convolutions and Morphology Tool dialog appears.
  2. From the Convolutions and Morphology Tool dialog buttons, select Convolutions > filter_type. The dialog parameters that are available vary with your filter type selection.
  3. If you select Directional, enter the filter angle when the Directional Filter Angle dialog appears. North (up) is zero degrees and the other angles are measured in the counterclockwise direction.

  4. Specify the Kernel Size. Some specialized filters have default sizes that cannot be changed, such as Sobel and Roberts.
  5. The kernel sizes are in odd-number increments. Left-click to increase/decrease the value by 2, middle-click to increase/decrease the value by 10, and right-click to set the kernel size back to 3x3.

    By default, the kernel size is set to a square kernel. To change to a non-square kernel, deselect Options > Square kernel from the Convolutions and Morphology Tool dialog menu bar. The Low Pass (average) and Median filters are always square. You can also edit individual kernels.

  6. Enter an add back value in the Image Add Back (0-100%) field. Adding back part of the original image to the convolution filter results helps preserve the spatial context and is typically done to sharpen an image. The Image Add Back value is the percentage of the original image that is included in the final output image. For example, if you enter 40%, then 40% of the original image is added to 60% of the convolution filter image to produce the final result.
  7. Select Quick Apply or Apply to File to apply filter results.

Edit, Save, and Restore Kernels

You can edit, save, and restore kernel values in the Convolutions and Morphology Tool dialog.

  • To edit a kernel value, double-click within the Editable Kernel field to change, enter a new value, then press Enter.
  • To save kernel values, select File > Save Kernel, enter a filename, then click OK.
  • To restore a save kernel file, select File > Restore Kernel and select the desired file.

Apply Filter Results to Files

You can apply the filter results to a file.

  1. Click Apply to File. The Convolution Input File dialog appears.
  2. Select an input band and perform optional spatial subsetting, then click OK. The Convolution Parameters dialog appears.
  3. Select output to File or Memory.
  4. Click OK. ENVI adds the resulting output to the Layer Manager.

Morphology Filters


Morphological kernels used in ENVI are just the structuring element and should not be confused with convolution kernels. Morphology filter types include the following:

  • Dilate: Commonly known as fill, expand, or grow, it fills holes smaller than the structural element (kernel) in a binary or gray scale image. Use only with unsigned byte, unsigned long-integer, or unsigned integer data.
  • Erode: Commonly known as shrink or reduce, it removes islands of pixels smaller than the structural element (kernel) in a binary or gray scale image. Use only with unsigned byte, unsigned long-integer, or unsigned integer data.
  • Opening: Smooth the contours, break narrow isthmuses, and eliminate small islands and sharp peaks or capes in an image. The opening of an image is defined as the erosion of the image followed by subsequent dilation using the same structural element.
  • Note: Using the Erode filter followed by using the Dilate filter produces the same result as using an Opening filter.

  • Closing: Smooth the contours, fuse narrow breaks and long thin gulfs, eliminate small holes, and fill gaps in the contours of an image. The closing of an image is defined as the dilation of the image followed by subsequent erosion using the same structural element.
  • Note: Using the Dilate filter followed by using the Erode filter produces the same result as using the Closing filter.

You can also write a script to perform morphological filtering using ENVIBinaryMorphologicalFilterTask and ENVIGrayscaleMorphologicalFilterTask.

Follow these steps to perform morphological filtering:

  1. From the Toolbox, select Filter > Convolutions and Morphology. The Convolutions and Morphology Tool dialog appears.
  2. From the Convolutions and Morphology Tool dialog menu bar, select Morphology > filter_type.
  3. Specify the Kernel Size.
  4. The kernel sizes are in odd-number increments. Left-click to increase/decrease the value by 2, middle-click to increase/decrease the value by 10, and right-click to set the kernel size back to 3x3.

    By default, the kernel size is set to a square kernel. To change to a non-square kernel, deselect Options > Square kernel from the Convolutions and Morphology Tool dialog menu bar. The Low Pass (average) and Median filters are always square. You can also edit individual kernels.

  5. Enter the number of iterations of the filter in the Cycles field.
  6. Select a filter style of Binary, Gray, or Value.
    • Binary: Produces output pixels in either black or white.
    • Gray: Preserves gradients.
    • Value: Allows the kernel value to be either added (dilate) or subtracted (erode) from the selected pixels.
  7. Select Quick Apply or Apply to File to apply filter results.
  8. A status message appears. If no image tiling is required, the status message does not advance gradually. It goes abruptly from 0 to 100% after a short wait because the operation is being performed on the entire image array. ENVI adds the resulting output to the Layer Manager.

Related Topics


Adaptive Filters, Frequency Filters, Texture Filters



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us