Clipping Images
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.
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" in Chapter 9 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. Run the example procedure by entering clippingimages at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT clippingimages.pro.
- Determine the path to the
worldtmp.pngfile: - Define the image size parameter:
- Import the image from the file:
- Initialize the display:
- Create a window and display the image:
- Clip the image to determine which pixel values are greater than 125:
- Create another window and display the clipped image with the TV (left) and the TVSCL (right) procedures:
- Clip the image to determine which pixel values are less than a 125:
- Create another window and display the clipped image with the TV and the TVSCL procedures:
WINDOW, 0, XSIZE = imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Hurricane Gilbert' TV, imageThe following figure shows the original image of Hurricane Gilbert.
WINDOW, 1, XSIZE = 2*imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Image Greater Than 125, TV (left) ' + $ 'and TVSCL (right)' TV, topClippedImage, 0 TVSCL, topClippedImage, 1The following figure shows the resulting image of pixel values greater than 125 with the TV and TVSCL procedures.
WINDOW, 1, XSIZE = 2*imageSize[0], YSIZE = imageSize[1], $ TITLE = 'Image Less Than 125, TV (left) ' + $ 'and TVSCL (right)' TV, bottomClippedImage, 0 TVSCL, bottomClippedImage, 1The following figure shows the resulting image of pixel values less than 125 with the TV (left) and TVSCL (right) procedures.


