Displaying Images

You can easily create image visualizations using the Tool Palette in the IDL Visualize perspective or from the command line with the IIMAGE command. Either way, the visualization displays in the IDL iImage tool, which allows you to visualize, modify, and manipulate image data in an interactive environment.

For more information on working with the images using the Tool Palette, see Image Visualizations

For more information on working with the image tools, see Working with Images

Displaying Images Using the Tool Palette

iimageexamp.gif

This example displays a TIFF image of an aerial view above Manhattan.

  1. Make sure you are viewing the IDL Visualize Perspective. (Click the Visualize button (viz_button.gif) in the upper right of the Workbench.)
  2. In IDL, select File →  Open File.
  3. Navigate to the examples\data directory of your IDL installation.
  4. Select the file image.tif.

Displaying Images Using IIMAGE

You can create the visualization shown in the previous section by opening the iImage tool from the IDL command line:

  1. At the IDL command line, enter iImage.
  2. The iImage tool displays.

  3. On the iImage tool, select File  Open, and select image.tif from the examples\data subdirectory of your IDL installation.
  4. Click Open, and the file is displayed in the iImage tool.

Resizing Images

There are several easy ways to resize an image in the iImage tool:

zoom_tools.gif

Contrast Enhancement

Sometimes changing how the colors are represented is all you need to improve the look of an image. IDL provides several ways to manipulate the contrast.

Thresholding

The Thresholding operation takes an image containing a range of pixel values and produces a two-value image (effectively a black and white image). Specifically, all the pixel values up to a certain value are represented by either black or white pixels, and all the pixel values above the threshold value are represented by the opposite color. For example, a threshold value of 150 produces an image in which all the pixel values under 150 are represented by black pixels, and all pixel values of 150 and above are represented by white pixels.

thresholding_1.gif

In the following example, we use the "greater than" operator (GT) to create a thresholded image in which pixel values greater than 140 are white and all others are black.

  1. Load the image.tif file into an IDL variable:
  2. img = READ_TIFF(FILEPATH('image.tif', $
       SUBDIRECTORY=['examples', 'data']))

  3. The operation img GT 140 creates an array of ones and zeros. The BYTSCL command transforms the array into values of 255 and zero.
  4. Scale the pixel values of the image.tif file to the entire range of a byte (0-256), and send all values greater than 140 to the iImage tool.
    thresholding_2.gif

    IIMAGE, BYTSCL(img GT 140)

To create a thresholded image in which pixels with values less than 140 are white (the inverse of the previous example), enter the following code at the IDL command line:

IIMAGE, BYTSCL(img 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. In IDL, the HIST_EQUAL function performs this redistribution on an array.

thresholding_3.gif

To display a histogram-equalized version of image.tif, enter the following code at the IDL command line:

IIMAGE, HIST_EQUAL(img)

Smoothing and Sharpening

Images can be rapidly smoothed to soften edges or compensate for random noise in an image using IDL's Smooth filter. The Smooth filter performs an equally weighted smoothing using a square neighborhood of an arbitrary odd width, as shown below.

smooth_filter.gif

To smooth an image:

  1. In the iImage tool, select File  Open, and select image.tif from the examples\data subdirectory of your IDL installation.
  2. Click Open, and the file is displayed in the iImage tool.
  3. Select Operations  Filter  Smooth.
  4. The Smooth dialog appears.
    gsimg11.gif

  5. In the Width box, enter the value 7. This creates a 7 x 7 pixel-square smoothing area.
  6. The images at the bottom of the dialog show the displayed file before and after the filter is applied. The image shown at right is the smoothed image.

  7. Click OK.

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.

unsharp_mask_filter.gif

To unsharp mask an image:

  1. Using the smoothed image.tif file used in the previous example, select Operations  Filter  Unsharp Mask.
  2. The Unsharp Mask dialog displays.

  3. In the Radius in Pixels box, enter the value 7.
    unsharp_mask_image.gif
  4. The images at the bottom of the dialog show the displayed file before and after the filter is applied.

  5. Click OK.

Sharpening Images with Differentiation

IDL has other built-in sharpening filters that use differentiation to sharpen images. The Roberts filter is one of these, and returns the Roberts gradient of an image.

To apply the Roberts filter to an image:

  1. Select File  Open, and select image.tif from the examples\data subdirectory of your IDL installation.
  2. Click Open.
    gsimg13.gif
  3. The file is displayed in the iImage tool.

  4. Select Operations  Filter  Roberts.
  5. The Roberts filter is applied to the displayed image.

Another commonly-used gradient operation is the Sobel filter. IDL's Sobel filter operates over a 3 x 3 pixel region, making it less sensitive to noise than some other methods.

To apply the Sobel filter to an image:

  1. Select File  Open, and select image.tif from the examples\data subdirectory of your IDL installation.
  2. Click Open.
    sobel_image.gif
  3. The file is displayed in the iImage tool.

  4. Select Operations  Filter  Sobel.
  5. The Sobel filter is applied to the displayed image.

Loading Alternate Color Tables

Try loading some of the predefined IDL color tables to increase the contrast of the image.

  1. After loading an image into the iImage tool, click Edit Palette (located on the Image tab).
  2. The Palette Editor dialog is displayed.

  3. Click the Load Predefined... menu at the bottom of the dialog, and select a color table menu item.
  4. The loaded image will immediately incorporate the new color table. Go ahead and play with different color tables to observe their effect on the image.

  5. When you are finished experimenting with different color tables, select the first color table in the menu, B-W Linear (the original black and white color table you have been working with), and click OK.

Cropping Images

To crop an image:

  1. Select File  Open, and select image.tif from the examples\data subdirectory of your IDL installation.
  2. Click Open.
    crop_image.gif
  3. The file is displayed in the iImage tool.

  4. Select Operations  Crop.
  5. The Crop dialog displays.

  6. Click on the image, and drag the box around the tip of the peninsula (actually Manhattan island).
  7.  

     

     

  8. On the Crop dialog, click Crop.
    crop_image_2.gif
  9. The cropped portion of the original image is displayed (the lower tip of Manhattan, in this case).

You may also crop an image directly using the toolbar:

  1. Click the Crop button crop_button.gifon the toolbar.
  2. Click on the image and drag the box around the peninsula.
  3. Double-click inside the box.
  4. The cropped portion of the original image is displayed.

Rotating Images

crop_image_2bz.gif

You can easily flip or rotate in image in the iImage tool.

To rotate an image 90 degrees clockwise:

  1. If not already loaded, load the image.tif file and crop Manhattan island (the procedure is explained in Cropping Images).
  2. Select Operations  Rotate or Flip  Rotate Right.
    clockwise_rotated_image.gif
  3. The rotated image is displayed.

Extracting Profiles

The Line Profile tool plots image pixel values from a line drawn over your image. The resulting 2-D plot is displayed in a new iPlot window.

line_profile_1.gif

To create a line profile plot of an image:

  1. On the iImage tool, select File  Open, and select image.tif from the examples\data subdirectory of your IDL installation.
  2. Click Open, and the file is displayed in the iImage tool.
  3. On the iImage toolbar, click the Line Profileline_profile_button.gif button.
  4. Position the mouse pointer over the spot on the image where you want to start the line, and click.
    line_profile_2.gif
  5. Drag the pointer to the end point of your line, and release the mouse button.
  6. A new plot window displays showing a plot of the image pixel values that fall along the line.

You can move the line around the image or change the endpoints, and the plot window continuously updates.