CImage:Pos


The Pos method returns the array position corresponding to a pixel coordinate. The return value is an integral number such that the first pixel of the image has an offset of 1. Also see the inverse method, CoordOf.

Syntax

nPos = CImage:Pos( tCoord[] )

where

    tCoord[] is a coordinate table containing 1-based axis positions.

    nPos is the linear pixel offset into the data array. The first pixel has nOffset = 1.

Example

The following script creates a 3-D image and then returns the offset of an element in the image array.

I = CImage:new( {100,200,50} "double" )

-- create a CImage 100 x 200 x 50 pixels

nPos = I:Pos( {10,20,40} )

 -- get the offset at column 10, row 20, plane 40

Printf( "ArrayPos=%d\n", nPos )

-- result: ArrayPos = 783810

Related Topics

CoordOf

CImage:PtInside

Pixel Coordinate Definition

CImage class