Transposing Images
Transposing an image array interchanges array dimensions, reflecting an image about a diagonal (for example, reflecting a square image about a 45 degree line). By default, the TRANSPOSE function reverses the order of the dimensions. However, you can control how the dimensions are altered by specifying the optional vector, P, in the following statement:
The values for P start at zero and correspond to the dimensions of the array. The following example transposes a photomicrograph of smooth muscle cells.
Example Code
See transposeimage.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. Run the example procedure by entering transposeimage at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT transposeimage.pro.
- Open the file and prepare to display it with a color table:
- Display the original image:
- Reduce the image size for display purposes:
- Using the TRANSPOSE function, reverse the array dimensions. This essentially flips the image across its main diagonal axis, moving the upper left corner of the image to the lower right corner.
- Specifying the reversal of the array dimensions leads to the same result since this is the default behavior of the TRANSPOSE function.
- However, specifying the original arrangement of the array dimensions results in no image transposition.
READ_JPEG, FILEPATH('muscle.jpg', $
SUBDIRECTORY=['examples', 'data']), image
DEVICE, DECOMPOSED = 0, RETAIN = 2
LOADCT, 0
transposeImg1 = TRANSPOSE(smallImg) WINDOW, 1, XSIZE = 600, YSIZE = 183, TITLE = 'Transposed Images' TV, transposeImg1, 0
The following figure displays the original image (top) and the results of the various TRANSPOSE statements (bottom).
|
![]()
|
