CImage:AreaUnits CImage:DistanceUnits

CImage:Distance


The Distance method calculates the Distance in pixel coordinate units along a line formed by 2 image points. To measure a distance in world coordinates, use the DistanceWcs method.

Syntax

nDistance = CImage:Distance( x1, y1, x2, y2)

    wherex1, y1, x2, y2 are pixel coordinates and may be numbers or strings.

    On success, this method returns nDistance, as a number in pixel units.

    On failure, this method returns 0.

Remarks

The Distance method returns a distance in pixel units. The DistanceWcs and DistanceWcsStr methods return distance measured in calibrated world coordinate units rather than pixel coordinates.

Example

Assume an image is displayed and attached to a CImageView named V. The following script fragment measures the distance between two points (x1,y1) and (x2,y2) when the coordinates are in pixel units:

I = V:GetImage()

-- load the image from a

x1 = 442.5 ; y1 = 220.44

-- point 1

x2 = 1.554 ; y2 = 20.552

-- point 2

D = I:Distance(x1,y1,x2,y2)

-- make the measurement

Related Topics

CImage, DistanceWcs, Image Coordinate System, Subpixel Coordinate Definition