CImage:Crop


The Crop method trims an image to smaller dimension along one or more axes. This transformation preserves the world coordinate calibration of the image, if one exists.

Syntax

Forms for 1-d and 2-d images:

bSuccess = CImage:Crop( CRect )

bSuccess = CImage:Crop( nMinX, nMaxX )

bSuccess = CImage:Crop( nMinX, nMaxX, nMinY, nMaxY )

There are additional forms in which the axis, or a set of axes, can be specified:

bSuccess = CImage:Crop( nAxis, nMin, nMax )

bSuccess = CImage:Crop( nAxis[], nMin[], nMax[] )

where

    CRect is a CRect object (rectangle) containing the high and low indicies to crop in the X and Y directions.

    nMinX, nMaxX, nMinY, nMaxY are the index of high and low indices to crop in the X and Y directions.

    nAxis specifies the axis to crop or is a table of axes to crop.

    nMin specifies the minimum index to crop. This may be an array of min values for each of the specified axes.

    nMax specifies the maximum index to crop. This may be an array of max values for each of the specified axes.

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

  

The crop region is passed as a CRect object containing the minimum and maximum x and y limits of the sub-image. These pixel coordinates are 1-based, meaning that pixel (1,) is at the origin of the image.

Example

Assume that an image is displayed in a CImageView named V. The following script crops a subimage from the image cursor:

I = V:GetImage()

-- attach the displayed image to the CImage

R = V:GetCursorRect()

-- get the cursor extent as a CRect

I:Crop( R )

--crop the image to the image cursor

Related Topics

CImage class

CImageView class,

CRect class