<< imfinfo SIP - Scilab Image Processing Toolbox imphase >>

SIP - Scilab Image Processing Toolbox >> SIP - Scilab Image Processing Toolbox > imnoise


Add noise (Gaussian, etc.) to an image

Calling Sequence

imn = imnoise(im, type [,parameters])


Input image (grayscale).
String having one of these values:
'salt & pepper'
drop-out/On-off noise
multiplicative noise
Gaussian white/additive noise
Pixel-specific variance (Zero-mean Gaussian)
Not yet implemented
A sequence of parameters to control the noise distribution, depending on the chosen type. If omitted, default values are used (see below).
Noisy image, which has the same size and type as input image im.


imnoise(im, type [, parameters]) adds a type of noise to the intensity image im. Optionally, you can control the noise parameters starting at the 3rd. Argument to imnoise. Here are examples of noise types and their parameters:

imn = imnoise(im, 'salt & pepper', d) adds drop-out noise, where d is the noise density (probability of swapping a pixel). (default: d=0.05).

imn = imnoise(im, 'gaussian', m, v) adds Gaussian additive noise of mean m and variance v. (default: m=0 and v=0.01)

im = imnoise(im, 'localvar', V) additive zero-mean Gaussian noise where the variance at im(i,j) is V(i,j).

imn = imnoise(im,'localvar', intensity, V) additive zero-mean Gaussian noise, and the local variance of the noise, var, is a function of the image intensity values in im. The variance is matrix( interp1(intensity(:),V(:),im(:)), size(im) )

imn = imnoise(im,'speckle',v) adds multiplicative noise, using imn = im + noise*im, where noise is uniformly distributed with mean 0 and variance v. (default: v=0.04)

The mean and variance parameters are specified as if image intensities went from 0 to 1. By default, we consider that "1" corresponds to the maximum intensity value of the image. If you want to change this for 'gaussian' and 'speckle', pass an extra parameter at the end of the argument list. For instance, your image may have maximum intensity 180 even though the grayscale range is 0-1:

J = imnoise(I,'gaussian', m, v, val)

J = imnoise(I,'speckle', v, val)


xset('auto clear', 'on');
A = gray_imread(SIPDIR + 'images/gra.jpg');

N = imnoise(A,'salt & pepper');

N = imnoise(A,'salt & pepper',0.3);

// Replace pixel by independent random value:
N = imnoise(A,'salt & pepper',0.3,0);

// Replace pixel by *dependent* random value:
N = imnoise(A,'speckle');

xset('auto clear', 'off');

Bugs and Shortcomings

'poisson' noise is not yet implemented.


"Noise Generation", The Hypermedia Image Processing Reference (HIPR), R. Fisher, S. Perkins, A. Walker and E. Wolfart, University of Edinburgh:




The latest version of SIP can be found at


See Also

<< imfinfo SIP - Scilab Image Processing Toolbox imphase >>