Shifts the elements of a vector orarray along any dimension by any number of elements.
shifti The shift parameters (see Discussion).
If only one shift parameter is present and the parameter is an array, the array is treated as a vector.
a = INDGEN(5)
PRINT, a, SHIFT(a,1), SHIFT(a,-1)
0 1 2 3 4
4 0 1 2 3
1 2 3 4 0
When performed on a binary image (containing only black and white pixels), edges that are opposite the direction of the shift are enhanced.
When performed on a gray scale or pseudocolor image, an embossing effect is created opposite the direction of the shift.
By carefully selecting the direction and amount of the shift, you can make certain details (for example, only vertical or horizontal lines) be discernible in an otherwise jumbled image.
Typically, single-element (one pixel) shifts are most pronounced, while any shift beyond ten elements (pixels) tends to start blurring the features in the image.
For example, to shift a mandrill image to highlight the edges to the left of each feature, you would first run the SHIFT function and then subtract the resulting image from the original image to create a third image:
shift_mandril = SHIFT(mandril, 1, 0) shift_diff_mand = mandril - shift_mandril
Figure 2-111 The SHIFT function described above has been used with this 512-by-512 mandrill image for edge enhancement. Notice how the dark edges to the left of each feature in the image are highlighted by using SHIFT with a positive number for the first parameter (which causes the image to be shifted to the right).
Figure 2-112 The SHIFT function described above has been used with this 512-by-512 mandrill image for edge enhancement. Notice how the dark edges to the left of each feature in the image are highlighted by using SHIFT with a positive number for the first parameter (which causes the image to be shifted to the right).
shift_mandril = SHIFT(mandril, 1, 1) shift_diff_mand = mandril - shift_mandril
Figure 2-113 Notice how the dark edges to the southwest of each feature in the image are now highlighted by using the SHIFT function with a positive number for the first and second parameter (which causes the image to be shifted both up and to the right).
Figure 2-114 Notice how the dark edges to the southwest of each feature in the image are now highlighted by using the SHIFT function with a positive number for the first and second parameter (which causes the image to be shifted both up and to the right).