CImage:AddNoise


The AddNoise method adds noise to the pixel values inside a rectangular region.

Syntax

bResult = CImage:AddNoise( CRect, sigma )

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

bullet.gif    sigma is the noise sigma, specified by a number or string.

bullet.gif    On success, this method returns true.

bullet.gif    On failure, false is returned.

Remarks

This method adds Gaussian random noise to the pixel values. The noise may be positive or negative relative to the existing pixel value. To set a pixel value plus noise, rather than add noise to the existing value, use SetRegionVal.

Example

The following script opens an image from the file at sPath, then add noise with a Gaussian sigma of 7.6 to all pixels in columns 100:200 and rows 250:350:

 

I = new_image()

-- Create a CImage

I:Open( sPath )

-- Open the image from sPath.

R = new_rect()

-- create a rectangle

R:Set( 100, 200, 250, 350 )

-- columns 100:200, rows 250:350

I:AddNoise( R, 7.6 )

-- add Gaussian noise

I:Save()

-- save the image

I:delete()

-- delete the CImage from memory

R:delete()

-- delete the CRect from memory

Related Topics

CImage class, SetRegionVal


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