Previous Getting Started with IDL: Images Next

Smoothing and Sharpening

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

  1. Display myimage smoothed using a 7 by 7 area:
  2. TVSCL,SMOOTH(MYIMAGE,7)  
    

     

    Figure 6-12: Smoothing with SMOOTH

    Figure 6-12: Smoothing with SMOOTH

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.

  1. Unsharp mask and display image:
  2. TVSCL, FLOAT(MYIMAGE)-SMOOTH(MYIMAGE,7)  
    

     

    Figure 6-13: Unsharp Masking

    Figure 6-13: Unsharp Masking

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:

  1. Create a new variable, R, that contains the Roberts gradient of myimage:
  2. R=ROBERTS(MYIMAGE)  
    

     

  3. Display array R:
  4. TVSCL, R  
    

     

    Figure 6-14: Roberts Gradient of myimage

    Figure 6-14: Roberts Gradient of myimage

Another commonly used gradient operator is the Sobel operator. IDL's SOBEL function operates over a 3 by 3 region, making it less sensitive to noise than some other methods. Enter the following commands.

  1. Create a Sobel sharpened version of the image:
  2. SO=SOBEL(MYIMAGE)  
    

     

  3. Display the sharper image:
  4. TVSCL, SO  
    

     

    Figure 6-15: Sobel Sharpened Version of myimage

    Figure 6-15: Sobel Sharpened Version of myimage

Loading Different Color Tables

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 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.


Note
If you load a new color table while an image is still being displayed on a 24-bit (true) color display, you will need to close the image and reload it in IDL in order to see the new image displayed in the new color scheme. In an 8-bit (pseudo) color display however, you will not need to re-display the image as the color change will be immediate.

  IDL Online Help (March 06, 2007)