CImage:CreatePixelMask


The CreatePixelMask method creates a pixel mask file containing the coordinates of pixels that exceed an upper or lower threshold. Compared with CreatePixelMaskHigh and CreatePixelMaskLow, this method tests both thresholds.

Syntax

bSuccess = CImage:CreatePixelMask( sMask, vHigh, vLow, CRect=nil )

bullet.gif    sMask is the name of the text file where the pixel mask will be saved.

bullet.gif    vHigh is the high threshold value, and may be a number or a string.

bullet.gif    vLow is the low value threshold, and may be a number or a string.

bullet.gif    The target rectangle is CRect; if nil, then the entire image is searched.

bullet.gif    On success, this method returns true.

bullet.gif    On failure, this method returns false.

Remarks

This method produces a text file consisting of pixel coordinate pairs, one per line, in the form column, row. This format is described in the topic Pixel Mask File. To examine only the upper threshold or lower threshold use one of the other methods, CreatePixelMaskHigh or CreatePixelMaskLow.

Example

The following script makes a pixel mask containing the coordinates of pixel values above 32000 and below -32000 in the central 50% of the image:

I = new_image()

-- Create a CImage

I:Open( sPath )

-- Open the image from sPath.

R = new_rect()

-- create a rectangle

w = I:Cols() ; h = I:Rows()

-- get the image size

R:Set( 0.25*w, 0.75*w, 0.25*h, 0.25*h )

-- central 50% of columns and rows

low = -32000 ; high= 32000

-- set the threshold values

I:CreatePixelMask(sMaskFile,high,low,R)

-- create the pixel mask

I:delete()

-- delete the CImage from memory

R:delete()

-- delete the CRect from memory

Related Topics

CreatePixelMaskHigh, CreatePixelMaskLow, ApplyPixelMask, Pixel Mask File


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