CImage:RectToTable


The RectToTable method copies the pixels from a rectangular region of a CImage into a 2-dimensional array. If the CImage has a numeric pixel type (e.g., "ushort", "float", etc.) then the array has numeric values. If the CImage has an rgb pixel type, then the array has rgb strings as values, for example "255,0,0" for pure red. See Pixel Types. Note that this method does not work with a 1-dimensional CImage. The inverse operation, pasting a rectangle region into a CImage, is done using the TableToRect method.

Syntax

lua_table = CImage:RectToTable(nColMin, nColMax, nRowMin, nRowMax)

bullet.gif    nColMin is the minimum column to extract.

bullet.gif    nColMax is the maximum column to extract.

bullet.gif    nRowMin is the minimum row to extract.

bullet.gif    nRowMax is the maximum row to extract.

bullet.gif    lua_table is a 2-dimensional array.

bullet.gif    On failure, nil is returned.

Remarks

The parameter order follows the standard order for describing image sections: [nMinCol:nMaxCol, nMinRow:nMaxRow]. Assuming the image has nCols total columns and nRows total rows, the specified limits are automatically chopped at the limits [1:nCols, 1:nRows].

Examples

The following script copies a 2-dimensional image rectangle [30:49,120:159] into a 2-dimensional array. The array size is (49-30+1) * (159-120+1) = 20*40 = 800 elements:

I = new_image()

-- create a CImage object

-- fill the image or open it from a file...

 

tbl = I:RectToTable(30,49,120,159)

-- create a 2-dimensional table from the rectangle

  

Related Topics

CImage class, ColToTable, RowToTable, ToTable, arraytoimage, TableToRect, Table and Array Functions


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.