|
Image Processing : Working with Masks and Image Statistics |
|
Clipping is used to enhance features within an image. You provide a threshold level to determine how the clipping occurs. The values above (or below) the threshold level remain the same while the other values are set equal to the level.
In IDL, clipping is performed with the minimum and maximum operators. IDL's minimum and maximum operators are shown in the following table.
|
Operator
|
Description
|
|---|---|
|
|
Less than or equal to
|
|
|
Greater than or equal to
|
The operators are used in an expression that contains an image array, the operator, and then the threshold level. For example, if you have an image variable and you want to scale it to include only the values greater than or equal to 125, the resulting clippedImage variable is created with the following IDL statement.
clippedImage = image > 125
The threshold level is applied to every element in the image array. If the element value is less than 125, it is set equal to 125. If the value is greater than or equal to 125, it is left unchanged.
| Note When clipping is combined with byte-scaling, this is equivalent to performing a stretch on an image. See "Determining Intensity Values for Threshold and Stretch" for more information. |
The following example shows how to threshold an image of Hurricane Gilbert, which is in the hurric.dat file in the examples/data directory. Two clipped images are created. One contains all data values greater than 125 and the other contains all values less than 125. Since these clipped images are grayscale images and do not use the entire 0 to 255 range, they are displayed with the TV procedure and then scaled with the TVSCL procedure, which scales the range of the image from 0 to 255. Complete the following steps for a detailed description of the process.
| Example Code See clippingimages.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
worldtmp.png file:
file = FILEPATH('hurric.dat', $
SUBDIRECTORY = ['examples', 'data'])
imageSize = [440, 340]
image = READ_BINARY(file, DATA_DIMS = imageSize)
DEVICE, DECOMPOSED = 0 LOADCT, 0
WINDOW, 0, XSIZE = imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Hurricane Gilbert' TV, image
The following figure shows the original image of Hurricane Gilbert.
topClippedImage = image > 125
WINDOW, 1, XSIZE = 2*imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Image Greater Than 125, TV (left) ' + $ 'and TVSCL (right)' TV, topClippedImage, 0 TVSCL, topClippedImage, 1
The following figure shows the resulting image of pixel values greater than 125 with the TV and TVSCL procedures.
![]() |
bottomClippedImage = image < 125
WINDOW, 1, XSIZE = 2*imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Image Less Than 125, TV (left) ' + $ 'and TVSCL (right)' TV, bottomClippedImage, 0 TVSCL, bottomClippedImage, 1
The following figure shows the resulting image of pixel values less than 125 with the TV (left) and TVSCL (right) procedures.
IDL Online Help (March 06, 2007)