imnoise.m
来自「A toolbox for the non-local means algori」· M 代码 · 共 65 行
M
65 行
function b = imnoise(varargin)
%IMNOISE Add noise to image.
% J = IMNOISE(I,TYPE,...) Add noise of a given TYPE to the intensity image
% I. TYPE is a string that can have one of these values:
%
% '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 TYPE, you can specify additional parameters to IMNOISE. 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. When unspecified, M and V default to 0 and
% 0.01 respectively.
%
% 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 is a
% function of the image intensity values in I. IMAGE_INTENSITY and VAR
% are vectors of the same size, and PLOT(IMAGE_INTENSITY,VAR) plots the
% functional relationship between noise variance and image intensity.
% IMAGE_INTENSITY 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 uint8 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*numel(I) pixels. The default for D is 0.05.
%
% 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.
%
% Note
% ----
% The mean and variance parameters for 'gaussian', 'localvar', and
% 'speckle' noise types are always specified as if for a double image
% in the range [0, 1]. If the input image is of class uint8 or uint16,
% the imnoise function converts the image to double, adds noise
% according to the specified type and parameters, and then converts the
% noisy image back to the same class as the input.
%
% Class Support
% -------------
% I can be of class uint8, uint16, or double.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?