Detecting edges is another way to extract features. Many edge detection methods use directional or Laplacian filters. IDL provides the following edge detection routines:
The results of these routines can be added or subtracted from the original image to enhance the contrast of its edges. Morphological operators are used for more complex edge detection.
The following example uses each of the above functions to detect edges in an aerial image of New York City. This example data is available in the examples/data directory of your IDL installation. The code shown below creates the following layout in one image window:
file = FILEPATH('nyny.dat', $
SUBDIRECTORY = ['examples', 'data'])
orig_imageSize = [768, 512]
orig_image = READ_BINARY(file, DATA_DIMS = orig_imageSize)
croppedSize = [96, 96]
croppedImage = orig_image[200:(croppedSize[0] - 1) + 200, $
180:(croppedSize[1] - 1) + 180]
img01 = IMAGE(croppedImage, $
TITLE = "Original", $
LAYOUT = [4, 2, 1], DIMENSIONS = [640, 400])
robimage = ROBERTS(croppedImage)
img02 = IMAGE(robimage, $
TITLE = "Roberts Filter", /CURRENT, $
LAYOUT = [4, 2, 2])
sobimage = SOBEL(croppedImage)
img03 = IMAGE(sobimage, $
TITLE = "Sobel Filter", /CURRENT, $
LAYOUT = [4, 2, 3])
prewimage = PREWITT(croppedImage)
img04 = IMAGE(prewimage, $
TITLE = "Prewitt Filter", /CURRENT, $
LAYOUT = [4, 2, 4])
shiftimage = SHIFT_DIFF(croppedImage)
img05 = IMAGE(shiftimage, $
TITLE = "SHIFT_DIFF Filter", /CURRENT, $
LAYOUT = [4, 2, 5])
edgedogimage = EDGE_DOG(croppedImage)
img06 = image(edgedogimage, $
TITLE = "EDGE_DOG Filter", /CURRENT, $
LAYOUT = [4,2,6])
lapimage = LAPLACIAN(croppedImage)
img07 = IMAGE(lapimage, $
TITLE = "Laplacian Filter", /CURRENT, $
LAYOUT = [4, 2, 7])
embossimage = EMBOSS(croppedImage)
img08 = IMAGE(embossimage, $
TITLE = "EMBOSS Filter", /CURRENT, $
LAYOUT = [4, 2, 8])
Resources