High Pass Filtering

A high pass filter is the basis for most sharpening methods. An image is sharpened when contrast is enhanced between adjoining areas with little variation in brightness or darkness. A high pass filter tends to retain the high frequency information within an image while reducing the low frequency information. The kernel of the high pass filter is designed to increase the brightness of the center pixel relative to neighboring pixels. The kernel array usually contains a single positive value at its center, which is completely surrounded by negative values. The following array is an example of a 3 by 3 kernel for a high pass filter:

The above array is just an example of one possible kernel for a high pass filter. Other filters may include more weighting for the center point.

The following example uses the CONVOL function with a 3 by 3 high pass filter to sharpen a whirlpool galaxy M51 image. This example data is available in the examples/data directory of your IDL installation. The code shown below creates the following images:

; Import the image from the file.

file = FILEPATH('m51.dat', $

   SUBDIRECTORY = ['examples', 'data'])

orig_imageSize = [340, 440]

orig_image = READ_BINARY(file, DATA_DIMS = orig_imageSize)

 

im = IMAGE(orig_image, RGB_TABLE=5, $

  TITLE = "Original Galaxy Image", $

  POSITION = [.10, .025, .50, .55], DIMENSIONS=[800, 800])

 

croppedSize = [56, 56]

croppedImage = orig_image[200:(croppedSize[0] - 1) + 200, $

  180:(croppedSize[1] - 1) + 180]

 

im01 = IMAGE(croppedImage, RGB_TABLE=5, $

  TITLE = "Cropped Galaxy Image", $

  POSITION = [.10, .625, .40, .925], /CURRENT)

 

; Create a kernel for a high pass filter.

kernelSize = [3, 3]

kernel = REPLICATE(-1., kernelSize[0], kernelSize[1])

kernel[1, 1] = 8

 

; Apply the filter to the image.

filteredImage = CONVOL(FLOAT(croppedImage), kernel, $

  /CENTER, /EDGE_TRUNCATE)

 

im02 = IMAGE(filteredImage, $

  RGB_TABLE = 5, $

  TITLE = "High-Pass Filtered Galaxy Image", $

  POSITION = [.60, .625, .90, .925], /CURRENT)

 

im03 = IMAGE(croppedImage + filteredImage, $

  RGB_TABLE = 5, $

  TITLE = "Filtered and Cropped Images Combined", $

  POSITION = [.60, .125, .90, .45], /CURRENT)

Resources