CImage:SetRegionVal


The SetRegionVal method sets the pixel values inside a rectangular region. The Setn and Setr methods may also be used but are not nearly as fast when used in a loop to set a large number of values.

Syntax

bSuccess = CImage:SetRegionVal( nValue )

bSuccess = CImage:SetRegionVal( nValue, CRect )

bSuccess = CImage:SetRegionVal( nValue, CRect, nSigma )

where

    nValue is the value to assign to the region.

    CRect is a CRect rectangle that describes the rectangle to set. If not specified or nil, the entire image is set.

    nSigma is the sigma for a Gaussian random noise distribution.

    bSuccess is the returned success code. On success it is true, otherwise false.

  

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

If the image has a numeric data type and you pass an RGB string for either nValue or nSigma, 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 in columns 100:200 and rows 250:350:

I = CImage:new()

-- Create a CImage

I:Open( sPath )

-- Open the image from sPath.

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

-- create a rectangle

I:SetRegionVal( R,1800.5, 0 )

-- Set the new pixel value

I:Save()

-- save the modified image

Related Topics

AddNoise

Set

Setn

Setr

Get

CImage class