Image Processing Toolbox | ![]() ![]() |
Syntax
Description
J = imnoise(I,
type
)
adds noise of given type to the intensity image I
. type
is a string that can have one of these values:
'gaussian'
for Gaussian white noise
'localvar'
for zero-mean Gaussian white noise with an intensity-dependent variance
'poisson'
for Poisson noise
'salt & pepper'
for "on and off" pixels
'speckle'
for multiplicative noise
J = imnoise(I,
type
,parameters)
accepts an algorithm type
plus additional modifying parameters particular to the type of algorithm chosen. If you omit these arguments, imnoise
uses default values for the parameters. Here are examples of the different noise types and their parameters:
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 releationship 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 intensities 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
, 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
![]() | immultiply | imopen | ![]() |