The UNSHARP_MASK function performs an unsharp-mask sharpening filter on a two-dimensional array or a TrueColor image. For TrueColor images the unsharp mask is applied to each channel.
The unsharp mask algorithm works by enhancing the contrast between neighboring pixels in an image, and is widely used for astronomical images and for digital photographs.
The algorithm involves the following steps:
In pseudocode this algorithm can be written as:
HighPass = Image - Convol ( Image, Gaussian )
Result = Image + A * HighPass * ( |HighPass| ³ T )
where A is the amount, T is the threshold, and ³ indicates a Boolean operation, 1 if true, or 0 otherwise.
| Note |
This routine is written in the IDL language. Its source code can be found in the file unsharp_mask.pro in the lib subdirectory of the IDL distribution.
Result = UNSHARP_MASK(Image [, AMOUNT=value] [, RADIUS=value] [, THRESHOLD=value] [, TRUE={1|2|3}] )
The Result is an array with the same dimensions and type as Image that contains the filtered image.
The two-dimensional array or multichannel image to be filtered. If Image is a multichannel image, then the TRUE keyword may be used to indicate which dimension represents the channels.
Set this keyword to a floating-point value giving the amount (or strength) of filtering to be applied. The default is AMOUNT=1.0, which implies that 100% of the filter difference will be applied to the Image. AMOUNT may be negative, which will have the effect of blurring the image instead of sharpening.
Set this keyword to a floating-point value giving the radius in pixels of the Gaussian smoothing filter. The default is RADIUS=3. The Gaussian filter is designed to fall to 1/e (~0.367) at a distance of RADIUS/sqrt(2). The total width of the Gaussian filter is given by ceil(2 * RADIUS)/2 * 2 + 1 (if RADIUS is an integer then this is just 2 * RADIUS + 1).
| Note |
| Tip |
Set this keyword to a non-negative integer (or a floating-point if Image is floating point) giving the clipping threshold. For each element, if the absolute value of the difference between the original image and the low-pass filtered array is greater than or equal to THRESHOLD then the filter is applied to that point. The default is THRESHOLD=0, which implies that every point will be filtered.
| Tip |
If Image is a three-dimensional array (a multichannel image), set this keyword to 1, 2, or 3 to indicate which dimension represents the channels. The default is 1, for pixel interleaving, (3, m, n). A value of 2 indicates line interleaving (m, 3, n), and 3 indicates band interleaving, (m, n, 3).
file = FILEPATH('marsglobe.jpg', SUBDIR=['examples','data'])
READ_JPEG, file, image
; Display the original image.
iImage, image, VIEW_GRID=[2,1], DIMENSIONS = [800, 500]
; Display the unsharp-mask-filtered image.
result = UNSHARP_MASK(image, RADIUS=4)
iImage, result, /VIEW_NEXT
Introduced: 6.1
CONVOL, LEEFILT, ROBERTS, SOBEL