|
Image Processing : Contrasting and Filtering |
|
Detecting edges is another way to help extract features. Many edge detection methods use either directional or Laplacian filters. See Directional Filtering and Laplacian Filtering for more information on directional and Laplacian filters.
IDL contains the following edge detection routines:
See the individual filter descriptions in the IDL Reference Guide for more information on these operators. Morphological operators are used for more complex edge detection. See "Detecting Edges of Image Objects" for more information on these operators.
The results of these edge detection routines can be added or subtracted from the original image to enhance the contrast of the edges within that image. Edge detection results are also used to calculate masks. See "Masking Images" for more information on masks.
The following example shows how to use each of the seven functions to detect edges within an image. This example uses the aerial view of New York City within the nyny.dat file in the examples/data directory. Complete the following steps for a detailed description of the process.
| Example Code The file for this example, detecting_edges_doc.pro, is located in the examples/doc/image subdirectory of the IDL distribution. |
file = FILEPATH('nyny.dat', SUBDIRECTORY = ['examples',$
'data'])
imageSize = [768, 512]
image = READ_BINARY(file, DATA_DIMS = imageSize)
croppedSize = [96, 96] croppedImage = image[200:(croppedSize[0] - 1) + 200, $ 180:(croppedSize[1] - 1) + 180]
displaySize = [150, 150]
croppedImage = CONGRID(croppedImage, displaySize[0],$ displaySize[1]) IIMAGE, croppedImage, DIMENSIONS=[700,700], $ VIEW_GRID=[4,2], $ VIEW_TITLE='Original', /NO_SAVEPROMPT, $ TITLE='Comparison of Edge Detection Filters' robertsfilteredImage = ROBERTS(croppedImage) IIMAGE, RobertsFilteredImage, /VIEW_NEXT , /OVERPLOT, $ VIEW_TITLE='ROBERTS Filter' SobelFilteredImage = SOBEL(croppedImage) IIMAGE, SobelFilteredImage, /VIEW_NEXT, /OVERPLOT, $ VIEW_TITLE='SOBEL Filter' PrewittFilteredImage = PREWITT(croppedImage) IIMAGE, PrewittFilteredImage, /VIEW_NEXT, /OVERPLOT, $ VIEW_TITLE='PREWITT Filter' ShiftDiffFilteredimage = SHIFT_DIFF(croppedImage) IIMAGE, ShiftDiffFilteredimage, /VIEW_NEXT, /OVERPLOT, $ VIEW_TITLE='SHIFT_DIFF Filter' EdgeDogFilteredimage = EDGE_DOG(croppedImage) IIMAGE, EdgeDogFilteredimage, /VIEW_NEXT, /OVERPLOT, $ VIEW_TITLE='EDGE_DOG Filter' LaplacianFilteredImage = LAPLACIAN(croppedImage) IIMAGE, LaplacianFilteredImage, /VIEW_NEXT, /OVERPLOT, $ VIEW_TITLE='LAPLACIAN Filter' EmbossFilteredImage = EMBOSS(croppedImage) IIMAGE, EmbossFilteredImage, /VIEW_NEXT, /OVERPLOT, $ VIEW_TITLE='EMBOSS Filter'
Figure 8-35: Each Filter Applied to the New York Image
Figure 8-35: Each Filter Applied to the New York Image IDL Online Help (March 06, 2007)