Skip to main content
v2026.11,858 entries · CC-BY 4.0

MATLAB imnoise: Noise Types, Defaults and Usage

MATLAB imnoise adds Gaussian, Poisson, salt-and-pepper, speckle or local-variance noise to an image. Syntax, defaults and the [0,1] variance rule.

Written and maintained by CASRAI Editorial Board

Last updated

Quick answer. imnoise is the Image Processing Toolbox function that adds synthetic noise to an image: J = imnoise(I, type, parameters). It supports five noise types (gaussian, localvar, poisson, salt & pepper, speckle), and the output has the same class as the input image. This page, written for researchers and analysts, covers each type’s syntax and defaults, the intensity-range rule that trips most users, and how to pair each noise type with a removal filter. Details were checked against the MathWorks documentation on 2026-11-08.

What imnoise is used for in research

imnoise adds noise to an image you already have. Typical research uses are building test images with a known noise level to benchmark denoising or segmentation methods, simulating sensor noise, and checking how robust an analysis pipeline is to degraded input. It does not remove noise: removal uses separate filters (see the sections below). For related signal-processing background, see what is signal processing and signal analysis in MATLAB.

Install or access

imnoise belongs to the Image Processing Toolbox, an add-on to MATLAB licensed by MathWorks. The reference page is mathworks.com/help/images/ref/imnoise.html. The same page notes that code generation requires MATLAB Coder and GPU Coder, and that GPU array input requires Parallel Computing Toolbox. A free alternative is in the table further down.

Step by step: add noise to an image

  1. Read an image into a variable: I = imread('eight.tif'); (the sample image used in the MathWorks example).
  2. Call imnoise with the noise type and its parameters: J = imnoise(I, 'salt & pepper', 0.02);
  3. Display the result: imshow(J).

To compare the original and the noisy image side by side, the MathWorks noise-removal page uses imshowpair.

imnoise matlab: syntax for each noise type

Type Syntax Parameters and defaults
Gaussian imnoise(I,"gaussian",m,var_gauss) Mean m default 0; variance var_gauss default 0.01.
Local variance imnoise(I,"localvar",var_local) or imnoise(I,"localvar",intensity_map,var_local) Zero-mean Gaussian noise whose variance depends on the image. var_local is the same size as I, or a vector matching intensity_map.
Poisson imnoise(I,"poisson") No parameters. Noise is generated from the image data rather than added artificially. The int16 class is not supported.
Salt and pepper imnoise(I,"salt & pepper",d) Noise density d default 0.05, affecting approximately 5% of pixels.
Speckle imnoise(I,"speckle",var_speckle) Multiplicative noise, J = I + n*I; variance var_speckle default 0.05.

For salt and pepper noise, each pixel gets a random value: if it falls below d/2 the pixel is set to 0, and if it falls between d/2 and d the pixel is set to the maximum value of the data type.

Output and how to read it

The intensity-range rule for mean and variance

Mean and variance are specified as if the image were class double with intensities in the range [0, 1], whatever the input class. Other classes (for example uint8, values 0 to 255) are converted to double, noise is added, the result is clipped to range, and it is converted back to the original class. So a variance of 0.01 means a standard deviation of 0.1 on the 0 to 1 scale, not 0.1 grey levels. double and single inputs should already be within [0, 1]; values outside that range are clipped before noise is added. The output has the same class as the input.

Poisson noise scaling by class

For poisson, pixel values are treated as expected counts. For uint8 and uint16 images the stored values are used directly (a pixel value of 10 gives a Poisson distribution with mean 10). For double images the values are scaled by 1e12 (a value of 5.5e-12 gives mean 5.5), and for single by 1e6. The same scene stored in different classes therefore receives different relative noise, which matters when you compare results across datasets.

Pairing noise types with removal filters

The MathWorks noise-removal page describes these choices:

Noise or goal Function What the documentation says
General smoothing imfilter, or filter2 with fspecial('average',3) Linear averaging or Gaussian filters.
Salt and pepper medfilt2 Median filtering is better than averaging at removing this noise and blurs edges less.
Constant-power additive noise such as Gaussian wiener2 Adaptive filter, most effective for this noise type; needs more computation.
Order-statistic filtering ordfilt2 Listed as a noise-removal option.

The page also points to imguidedfilter, imgaussfilt, locallapfilt, nlfilter and imbilatfilt as related functions. For one-dimensional data rather than images, see MATLAB moving average; for modelling noise values as Gaussian, see MATLAB normal distribution.

Troubleshooting

  • Noise looks far too strong or too weak on a uint8 image. Check the variance against the [0, 1] scale described above, not the 0 to 255 scale.
  • Poisson call fails on an int16 image. int16 is not supported for poisson; convert to a supported class first.
  • Poisson results differ between double and uint8 versions of one image. This follows from the class-dependent scale factors (1e12, 1e6, or direct use).
  • Double image values above 1. They are clipped before noise is added, so rescale the image first.
  • Function not found. The Image Processing Toolbox is not installed or licensed.

Free alternatives

Option What its documentation lists
GNU Octave image package: imnoise(A,type,...) Types gaussian (defaults 0 and 0.01), poisson, salt & pepper (default 0.05) and speckle (default variance 0.04). The function page does not list localvar.

The speckle default is 0.04 on the Octave function page versus 0.05 on the MathWorks page, so default results are not identical across the two. Octave’s page names rand, randn and randp as related functions. Source: Octave image package, imnoise, read 2026-11-08.

FAQ

What does imnoise do in MATLAB?

It returns a copy of an image with Gaussian, local-variance Gaussian, Poisson, salt-and-pepper or speckle noise added, in the same class as the input.

What are the default noise values?

Gaussian: mean 0, variance 0.01. Salt and pepper: density 0.05. Speckle: variance 0.05 (MathWorks documentation).

Is the variance in grey levels?

No. It is on the [0, 1] intensity scale, even for uint8 images.

Which filter removes salt-and-pepper noise?

The MathWorks noise-removal page says medfilt2 is better than averaging for this noise; for Gaussian-type additive noise it describes wiener2.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about MATLAB imnoise: Noise Types, Defaults and Usage

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →