|
Image Processing : Transforming Image Geometry |
|
The REVERSE function allows you to reverse any dimension of an array. This allows you to quickly change the viewing orientation of an image (flipping it horizontally or vertically).
Note that in the REVERSE syntax,
Result = REVERSE(Array [, Subscript_Index][,/OVERWRITE])
Subscript_Index specifies the dimension number beginning with 1, not 0 as with some other functions.
The following example demonstrates reversing the x-axis values (dimension 1) and the y-axis values (dimension 2) of an image of a knee.
| Example Code See reverseimage.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
image = READ_DICOM (FILEPATH('mr_knee.dcm', $
SUBDIRECTORY = ['examples', 'data']))
imgSize = SIZE (image, /DIMENSIONS)
DEVICE, DECOMPOSED = 0, RETAIN = 2 LOADCT, 0
flipHorzImg) and y-axis values (flipVertImg):flipHorzImg = REVERSE(image, 1) flipVertImg = REVERSE(image, 2)
WINDOW, 0, XSIZE = 2*imgSize[0], YSIZE = 2*imgSize[1], $
TITLE = 'Original (Top) & Flipped Images (Bottom)'
TV, image, 0 TV, flipHorzImg, 2 TV, flipVertImg, 3
Your output should appear similar to the following figure.
![]() |
IDL Online Help (March 06, 2007)