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 )

where

    x1,y1 are pixel coordinates of the first point.

    x2,y2 are pixel coordinates of the second point.

    nDistance is the distance, measured in pixel units.

    On success, this method returns nDistance.

    On failure, this method returns 0.

  

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 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

DistanceWcs

CImage class

Image Coordinate System

Subpixel Coordinate Definition