imnoise - Add noise (gaussian, etc.) to an image
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 example of noise types and their parameterss:
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)
By default, we consider that "1" corresponds to the maximum intensity value of the image, and "0" to minimum. If the input image im is an integer image, it will be converted to double using im2double function first. Before return the result, the image will be converted to the same type as the input image. The elements in the output matrix imn that exceed the range of the integer or double type will be truncated.
Supported classes: INT8, UINT8, INT16, UINT16, INT32, DOUBLE.
im = imread('lena.png'); imn = imnoise(im, 'gaussian'); imshow(imn); imn = imnoise(im, 'salt & pepper'); imshow(imn); imn = imnoise(im(:,:,1), 'salt & pepper', 0.2); imshow(imn); lowtri = tril(ones(im(:,:,1))); imn = imnoise( im(:,:,1), 'localvar', lowtri/5); imshow(imn); imn = imnoise( im(:,:,1), 'localvar', [0:0.1:1], [0:0.1:1].^3); imshow(imn); imn = imnoise(im, 'speckle' ); imshow(imn);
'poisson' noise is not yet implemented.