note | DIST is an excellent choice when you need a two-dimensional array of any size for a fast test display. |
test_arr = DIST(60)
LOADCT, 18
; Display data as a 2D plot
WINDOW, /Free
PLOT, test_arr, Background=WoColorConvert(255), Color=WoColorConvert(0)
; Display data as a contour plot
WINDOW, /Free
CONTOUR, test_arr, Background=WoColorConvert(255), Color=WoColorConvert(0), $
Thick=2.0, Nlevels=9, $
C_Colors=WoColorConvert([50, 75, 100, 125, 150, 175, 200, 225, 250])
; Display data as a surface
WINDOW, /Free
SURFACE, test_arr, Linestyle=2, Background=WoColorConvert(255), $
Color=WoColorConvert(0)
; Display data as a shaded surface
WINDOW, /Free
SHADE_SURF, test_arr, Background=WoColorConvert(255), Color=WoColorConvert(0)
; Display data as an image
test_img = DIST(300)
WINDOW, Xsize=300, Ysize=300, /Free
TVSCL, test_img, 3
; Read the demo image.
mandril = BYTARR(512,512)
OPENR, unit, !Data_dir + 'mandril.img', /Get_lun
READU, unit, mandril
FREE_LUN, unit
; Use the DIST function to create a frequency image of the same
; size as the demo image.
d = DIST(512)
; Set n, the order (steepness) of Butterworth filter to use, and
; d0, the cutoff frequency.
n = 1.0
d0 = 10.0
; Create a Butterworth low-pass filter to be applied to the image.
filter = 1.0 / (1.0 + (d/d0)^(2.0 * n))
; Filter the image by transforming it to the frequency domain,
; multiplying by the filter, and then transforming back to the
; spatial domain.
filt_image = FFT(FFT(mandril, -1) * filter, 1)
; Display the original image.
WINDOW, XSize=1024, YSize=512, /Free, $
Title='Original Image (left) - Filtered Image (right)'
TVSCL, mandril, 2
; Display the resulting image.
TVSCL, filt_image, 1