CImage:Mirror


The Mirror method flips (reverses) the image in the direction along an axis. For example, if the image is clipped about axis 2, then the image is reversed along the row axis so that data at higher row numbers would be placed at lower row numbers and vice versa.

Syntax

bSuccess = CImage:Mirror( nAxis )

where

    nAxis is the axis index, starting at 1 (column axis).

    bSuccess is the returned success code. On success it is true, otherwise false.

Example

A "plane" is the name given to axis 3 of a data array. The following script swaps the order of data planes. In other words, if there are n planes, then data in plane 1 will be moved to plane n, data in plane 2 will go into plane n-1, and so on. The script verifies that the image has 3 or more planes before doing the Mirror of axis 3:

 

I = CImage:new()

-- create a new CImage object

I:Open( sFileName )

-- open the image from a file

if I:Axes() >= 3 then

-- verify that planes exist

  I:Mirror(3)

-- reverse the order of planes.

  I:Save()

-- save back to the file

end

 

I:delete()

-- reclaim memory and the I name.

Often, a data array is filled with data in a particular "natural" order but you need to reverse the order along one of the axes. The next script creates a 5 dimensional image, then mirrors data along the 4th axis and 2nd axis:

I = CImage:new( {512,64,12,4,3}, "float")

-- create a 5-d image of "float" pixels

    --

-- fill the array with data

I:Mirror(4)

-- mirror about axis 4

I:Mirror(2)

-- mirror about axis 2

I:SaveAs()

-- open a SaveAs dialog for saving

Related Topics

Hflip

Vflip

CImage class