CImage:SetDatatype CImage:SetVal

CImage:SetRegionVal


The SetRegionVal method sets the pixel values inside a rectangular region.

Syntax

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

    The region is specified by a CRect, with 1-based coordinates.

    value is the value to assign to the region.

    sigma is the sigma for a Gaussian random noise distribution.

    On success, this method returns true.

    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 data 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 in columns 100:200 and rows 250:350:

 

I = CImage:new()

-- Create a CImage

I:Open( sPath )

-- Open the image from sPath.

R = CRect:new(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

CImage, AddNoise, SetVal, FiltClipHigh