Image Processing Toolbox User's Guide Previous page   Next Page
imnoise

Add noise to an image

Syntax

Description

J = imnoise(I,type) adds noise of a given type to the intensity image I. type is a string that can have one of these values.

Value
Description
'gaussian'
Gaussian white noise with constant mean and variance
'localvar'
Zero-mean Gaussian white noise with an intensity-dependent variance
'poisson'
Poisson noise
'salt & pepper'
On and off pixels
'speckle'
Multiplicative noise

Depending on which type of noise you specify, imnoise accepts additional parameters. If you omit these arguments, imnoise uses default values for the parameters. All numerical parameters are normalized; they correspond to operations with images with intensities ranging from 0 to 1.

J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.

J = imnoise(I,'localvar',V) adds zero-mean, Gaussian white noise of local variance V to the image I. V is an array of the same size as I.

J = imnoise(I,'localvar',image_intensity,var) adds zero-mean, Gaussian noise to an image I, where the local variance of the noise, var, is a function of the image intensity values in I. The image_intensity and var arguments are vectors of the same size, and plot(image_intensity,var) plots the functional relationship between noise variance and image intensity. The image_intensity vector must contain normalized intensity values ranging from 0 to 1.

J = imnoise(I,'poisson') generates Poisson noise from the data instead of adding artificial noise to the data. In order to respect Poisson statistics, the intensities of unit8 and uint16 images must correspond to the number of photons (or any other quanta of information). Double-precision images are used when the number of photons per pixel can be much larger than 65535 (but less than 10^12); the intensity values vary between 0 and 1 and correspond to the number of photons divided by 10^12.

J = imnoise(I,'salt & pepper',d) adds salt and pepper noise to the image I, where d is the noise density. This affects approximately d*prod(size(I)) pixels. The default is 0.05 noise density.

J = imnoise(I,'speckle',v) adds multiplicative noise to the image I, using the equation J = I+n*I, where n is uniformly distributed random noise with mean 0 and variance v. The default for v is 0.04.

Class Support

I can be of class uint8, uint16, int16, single, or double. The output image J is of the same class as I. If I has more than two dimensions it is treated as a multidimensional intensity image and not as an RGB image.

Example

See Also

rand, randn in the MATLAB Function Reference


Previous page  immultiply imopen Next page

© 1994-2005 The MathWorks, Inc.