1. Enter the following at the IDL Command Line:You can view an image in IDL with two different routines. The TV procedure writes an array to the display as an image without scaling. Enter the commands below at the IDL Command Line.nyny=read_tiff('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/image.tif')
2. Display the image:tv,nyny

2. Enter WDELETE at the Command Line to dismiss the graphics window.wdelete3. The TVSCL procedure displays the image with the color values scaled to use the whole color table. Display the scaled image:tvscl,nyny

4. Enter WDELETE at the Command Line to dismiss the graphics window.
The REBIN function in IDL makes it easy to resize a vector or array to new dimensions. The supplied dimensions must be proportionate (that is, integral multiples or factors) to the dimensions of the original image. Since our original image array here is 768 by 512, well need to decide the correct dimensions of our new resized image. If we want to resize the image to half the original size then simply take half of the arrays original dimensions.wdelete
5. Create a new image with new dimensions using the REBIN function:
newimage=rebin(nyny,384,256)
6. Now display the image:
tv,newimage

7. Enter WDELETE at the Command Line to dismiss the graphics window.
IDL automatically creates a window for displayed graphics if one does not already exist. You can use the WINDOW command to create new windows with custom sizes.wdelete
8. To display Manhattan in a larger graphics window, enter:
window,0,xsize=800,ysize=600
9. Then enter:
tv,nyny

10. Enter WDELETE at the Command Line to dismiss the graphics window.
The WINDOW command above creates a new version of window number 0 that is 800 pixels wide (specified with the XSIZE keyword) and 500 pixels tall (specified with the YSIZE keyword).wdelete
Thresholding
One of the simplest contrast enhancements that can be performed on an image is thresholding. Thresholding produces a two-level mapping from all of the possible intensities into black and white. The IDL relational operators, EQ, NE, GE, GT, LE, and LT, return a value of 1 if the relation is true and 0 if the relation is false. When applied to images, the relation is evaluated for each pixel and an image of 1s and 0s results.
1. To display the pixels in the image that have values greater than 140 as white and all others as black, as shown in the following, enter:tvscl,nyny gt 140

2. Similarly, the pixels that have values less than 140 can be displayed as white, as shown, by entering the command:tvscl,nyny lt 140

In many images, the pixels have values that are only a small subrange of the possible values. By spreading the distribution so that each range of pixel values contains an approximately equal number of members, the information content of the display is maximized, as shown in the following.
3. The HIST_EQUAL function performs this redistribution on an array. To display a histogram-equalized version of myimage, enter the following:tv,hist_equal(nyny)

Scaling Pixel Values
Another way to enhance the contrast of an image is to scale a subrange of pixel values to fill the entire range of displayed brightnesses. The > operator, the IDL maximum operator, returns a result equal to the larger of its two parameters. The following commands contrast the maximum and minimum operators.
4. Scale pixels with a value of 100 or greater into the full range of displayed brightnesses:tvscl,nyny > 100

5. Scale pixels with a value less than 140 into the full range of brightnesses.tvscl,nyny < 140

6. The minimum and maximum operators can be used together for more complicated contrast enhancements. Set the minimum brightness to 140, set the maximum brightness to 200, scale myimage and display it by entering:tvscl,nyny >140<200

1. Display myimage smoothed using a 7 by 7 area:tvscl,smooth(nyny,7)

Unsharp Masking
The previous image looks a bit blurry because it contains only the low frequency components of the original image. Often, an image needs to be sharpened so that edges or high spatial frequency components of the image are enhanced. One way to sharpen an image is to subtract a smoothed image containing only low-frequency components from the original image. This technique is called unsharp masking.
2. Unsharp mask and display image:tvscl,float(nyny)-smooth(nyny,7)

This command subtracts a smoothed version of the image from the original, scales the result, and displays it, as shown previously.
Sharpening Images with Differentiation
IDL has other built-in sharpening functions that use differentiation to sharpen images. The ROBERTS function returns the Roberts gradient of an image. Enter the following commands:
3. Create a new variable, r, that contains the Roberts gradient of myimage:r=roberts(nyny)4. Display array r:tvscl,r

Another commonly used gradient operator is the Sobel operator. IDLs SOBEL function operates over a 3 by 3 region, making it less sensitive to noise than some other methods. Enter the following commands.
5. Create a Sobel sharpened version of the image:so=sobel(nyny)6. Display the sharper image:tvscl,so

Try loading some of the pre-defined IDL color tables to make this image more visible. While the graphics window is visible, type xloadct at the IDL Command Input Line. The XLOADCT widget application appears. Select a color table from the field; the window will reflect the color scheme. Click Done to accept a color table. When you are finished looking at the effects of different tables, click on the first color table in the field, B-W Linear, and click Done to load the original black and white color table.
Sections of an Image
Sections of images can be easily displayed by using subarrays.
1. Erase the current display, create a new array that contains Manhattan and display it by entering:erase2. Then enter:
e=nyny[100:300, 150:250]tv,e

3. Enter WDELETE at the Command Line to dismiss the graphics window.wdelete
Rotating an Image
Simple rotation in multiples of 90 degrees can be accomplished with the ROTATE function.
4. Rotate the image by 90 degrees, as shown below, by entering:r=rotate(e,1)5. Now enter to display:tvscl,r

The second parameter of ROTATE is an integer from 1 to 8 that specifies which one of the eight possible combinations of rotation and axis reversal to use.
1. Use the PROFILES routine with the rotated image that you just displayed by entering the following:profiles,r

A new window for displaying the profiles appears. Move the cursor in
the window containing the image r to display the profiles of different
rows andcolumns.
2. Click the left mouse button while the cursor is in the image window to switch between displaying row and column profiles.3. Click the right mouse button while the cursor is in the image window to exit the PROFILES routine.
1. Enter:live_image,nyny

You can click once on the image and then drag the cursor across the image to read the image values.
You may also double-click on the image to display a properties dialog.
The set of buttons in the upper left corner of the image window allows
you to print, undo the last operation, redo the last undone operation,
copy, draw a line, draw a rectangle, or add text. The LIVE_IMAGE window
may also be resized using the mouse.
| This information is available in alternative formats upon request by individuals with disabilities. Please send email to alt-format@msi.umn.edu or call 612-624-0528. | ||||||||||||
|
HOME
| QUESTIONS | FEEDBACK
|
||||||||||||
|
||||||||||||