CMeasureRegions:Add
The Add mehod adds a region to the collection and draws it on the image. The Measure Regions toolbar is opened on the target image window, if not already open, to facilitate working with the regions (mark, move, and delete regions, etc.). The collection is actually owned by the image window. See the Mira Pro x64 User's Guide for details about the MeasureRegions feature.
C = CMeasureRegions:Add( Image, tblData ) Adds a region with properties defined by RegionParams and coordinates passed in a 1-dimensional array. C = CMeasureRegions:Add( Image, tblDataX, tblDataY ) Adds a region with properties defined by RegionParams and coordinates passed in two 1-dimensional arrays with values that are numbers. |
tblData is a table of x and y as described in Remarks, below.
tblDataX and tblDataY contain separate x and y coordinates.
Returns true on success, and false on failure.
This method supports two strategies for defining regions based on storing coordinates in a 1-dimensional arrays. You can use either one that is convenient:
Use one array containing the points [1], [2], [3], etc., as in { x[1], y[1], x[2], y[2], x[3], y[3], ... }.
Use two arrays, one for x coordinates and the other for y coordinates. The points [1], [2], [3], etc., are then stored as { x[1], x[2], x[3], ... } and { y[1], y[2], y[3], ... }.
The following script creates a new CMeasureRegions object, attaches an image window and an image, then adds two regions to the image using the two strategies described above, under Remarks.
|
-- create a new CMeasureRegions |
|
|
|
-- RegionParams properties to change |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- attach an image window |
|
-- exit if no image window |
-- grab an image from the window, V |
|
|
|
|
-- pick an image from the CImageView V |
|
-- exit if no image |
|
|
|
-- pick the only image in the window |
|
|
|
|
-- create regions centered on the image: |
|
-- first, get the image center coordinates |
|
|
|
|
|
|
|
-- create a region using one x,y table |
|
|
-- create a table for x and y coordinates |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- draw the marker |
|
|
-- create a region using separate x, y tables |
|
|
-- creaste a table for x coordinates |
|
|
|
|
|
|
|
|
|
-- create a table for y coordinates |
|
|
|
|
|
|
|
|
|
-- draw the marker |
CMeasureRegions class, new, delete, RegionParams Table
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics,
Inc. All Rights Reserved.