CImage:SetPixelType CImage:SetVal

CImage:SetRegionVal


The SetRegionVal method sets the pixel values inside a rectangular region to a specified value and noise. In comparison, the SetRegionValExclude method sets the pixels outside a rectangular region.

Syntax

bResult = CImage:SetRegionVal( CRect, value, sigma )

bullet.gif    The region is specified by a CRect, using 1-based coordinates.

bullet.gif    value is the value to assign to the region.

bullet.gif    sigma is the sigma for a Gaussian random noise distribution.

bullet.gif    On success, true is returned.

bullet.gif    On failure, false is returned.

Remarks

This method replaces the pixel values by a single value and Gaussian random noise. To set only the pixel value, pass sigma=0. To add only noise, use set value=0 or use the AddNoise method.

If the image has a numeric pixel type and you pass an rgb string for either value or sigma, the rgb string is converted to an equivalent numeric intensity.

Example

The following script opens an image from the file at sPath, then assigns the value 1800.5 to all pixels inside the rectangle defined by columns 100:200 and rows 250:350:

I = new_image()

-- Create a CImage

I:Open( sPath )

-- Open the image from sPath.

R = new_rect(100,200,250,350)

-- create a rectangle

I:SetRegionVal( R,1800.5, 0 )

-- Set new pixel values inside the rectangle

I:Save()

-- save the modified image

Related Topics

CImage class, SetRegionValExclude, AddNoise, SetVal, FiltClipHigh


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