Current location - Recipe Complete Network - Diet recipes - How to add two-dimensional noise with specific frequency to images with matlab
How to add two-dimensional noise with specific frequency to images with matlab
First of all, the image is at least two-dimensional, and the image has a matrix consisting of two attributes: length and width. One-dimensional signals are vectors.

The command of MATLAB to add noise to the image is

noise

The basic syntax of this function is:

G=imnoise(f, type, parameter)

F is the input image. Before adding noise to the image, the function imnoise converts it into a double image with the range of [0, 1]. This must be taken into account when specifying noise parameters.

G=imnoise(f,' Gaussian', m, var) adds Gaussian noise with a mean value of m and a variance of var to the image F. The default value is noise with a mean value of 0 and a variance of 0.0 1.

G=imnoise(f,' localvar', v) adds Gaussian noise with a mean of 0 and a local variance of V to the image F, where V is an array with the same size as F and contains the ideal variance of each point.

G = imnoise (f,' localvar', image _ intensity, var) will

Gaussian noise with an average value of 0 is added to the image f, where the local variance var of the noise is a function of the brightness value of the image f. Parameters image_intensity and var are directions with the same size.

Quantity, plot(image_intensity, var) draws the functional relationship between noise variance and image brightness. The vector image_intensity must contain a range.

The normalized brightness value is in the range of [0, 1].

G=imnoise(f,' salt & ampPepper', d) pollutes the image f with salt and pepper noise, where d is the noise density (that is, the percentage of the image area containing the noise value). Therefore, about d*numel(f) pixels are affected. The default noise density is 0.05.

G=imnoise(f,' speckle', VaR) multiplicative noise is added to the image f through the equation g=f+n*f), where n is uniformly distributed random noise with a mean value of 0 and a variance of var, and the default value of var is 0.04.

G=imnoise(f,' poisson') generates Poisson noise from data instead of adding artificial noise.

In the data, in order to conform to Poisson statistics, the image brightness of unit8 and unit 16 must be consistent with the photon number. When the number of photons per pixel is greater than 65535, a double-precision image will be used. The brightness value varies from 0 to 1, corresponding to the number of photons divided by 10e 12.

1 average filter

Mean filtering is a typical linear denoising method, because its operation is simple and fast, and it can effectively remove Gaussian noise. Therefore, it has a wide range of applications.

Many noise filtering methods are developed on this basis. Its disadvantage is that it seriously destroys the edge of the image and blurs the image.

2 Low pass filter

Low-pass filter, it is very common that the energy of signal or image is mostly concentrated in the middle and low frequency band of amplitude spectrum; In the higher frequency band, the information of interest is often drowned by noise. Therefore. Filters that can reduce the amplitude of high-frequency components can reduce the visible influence of noise. This is a frequency domain processing method. When analyzing the frequency characteristics of the image signal, the edge, jump and particle noise of the image represent the high-frequency components of the image signal, while the large-area background area represents the low-frequency components. Filtering the high frequency part can remove noise and smooth the image. But at the same time, the useful high-frequency components are also filtered out. Therefore, this processing is at the expense of clarity.

3 median filter

Median filtering is a nonlinear processing method to eliminate noise proposed by Tueky in 197 1. Its basic principle is to replace the value of a point with the median of the adjacent points in a digital image or digital sequence. The definition of median is as follows: sort the elements of a numerical sequence, and if the number of elements is odd, take the median of the sorted sequence. If the number of sequence elements is even, the average of the middle two values of the sorted sequence is taken.

An area with points of a certain length or shape is called a window. In the one-dimensional case, the median filter is a sliding window with odd pixels. The value of the middle pixel in the window is replaced by the median value of each pixel in the window.

This filter is a typical nonlinear processing method. Its advantage is that it is very effective in eliminating impulse noise in the image and can better protect the edge information of the image.

The disadvantage is that it involves a lot of sorting operations, and the operation speed is slow, which has an impact on the real-time processing of images. Generally speaking, images must be converted into digital images before they can be processed by computers. Digital images exist in digital form. When using MATLAB (Matrix Laboratory) for processing, we simply understand it as a digital matrix with a certain size. Each valid word in the matrix represents an image point. Therefore, the processing of digital images is actually the operation of a digital matrix.

For the convenience of research, our method is to artificially add noise to the original image, mainly random noise with normal distribution and impulse noise with different intensities. In MATLAB, the normal distribution noise is realized by randn function, while the impulse noise, commonly known as salt and pepper noise, is realized by imnoise(Io,' saIt 8L pepper, I). Where Io is the original image matrix and i takes the value. To 1, indicating the intensity of noise.