Reference:
Https://www.cnblogs.com/tiandsp/archive/2012/11/14/2770462.html
https://blog.csdn.net/zbc1090549839/article/details/38404995
Https://baike.baidu.com/item/%E6%A4%92%E7%9B%90%E5%99%AA%E5%A3%B0/3455958?fr=aladdin Salt and pepper noise
Salt and pepper noise is also called impulse noise. It is generated by image sensor, transmission channel, decoding processing, such as black and white light and dark point noise. Where the black noise point is called the pepper noise (pepper noise), and the white noise point is called salt noise (salt noise). In general, these 2 kinds of noise appear at the same time, showing in the image is black and white clutter.
Salt and pepper noise is often caused by image cutting, the most common algorithm to remove impulse interference and salt and pepper noise is median filter. Median filter
The effective method to filter out salt and pepper noise is to process the signal with median filter. Remove the salt and pepper noise can get a smoother signal, the effect is better than the mean filter, of course, median filtering will also cause blurred edges, signal is not sharp, which seems to be a lot of filtering methods of a common problem. So one of the things that can be excited is how to keep the edges better while filtering, especially in filtering.
In matlab, call y = Medfilt1 (x,n) to perform a one-dimensional signal median filter operation (x for input signal, N-value window width)
Call B = Medfilt2 (A, [M n]) to complete the median filter operation of the two-dimensional signal (A is the image to be filtered by the median value, using a m*n-sized window). Median filter Code
CLC;
Clear;
Close all;
fprintf (' ======= median filter =====\n ');
Img=imread (' remote_sense.tif ');
[~,~,ch] = Size (img);
If CH ==3
img =rgb2gray (IMG);
End
Figure;imshow (IMG); title (' Original image ');
img_med = Medfilt2 (IMG, [2,2]);
Figure;imshow (img_med); title (' 2*2 median filter ');
psnr_med = Eval_psnr (img,img_med);
% using the [3,3] window
img_med2 = MEDFILT2 (IMG, [3,3]);
Figure;imshow (IMG_MED2); title (' 3*3 median filter ');
Psnr_med2 = Eval_psnr (IMG,IMG_MED2);
For comparison we also use DCT to remove salt and pepper noise and use PSNR evaluation. DCT (frequency domain filtering) to remove salt and pepper noise
After showing the results of denoising we can also see that both in the frequency domain filter or in the spatial domain filter, we will cause the edge blur. This is what we need to think about.
CLC;
Close all;
img = imread (' remote_sense.tif ');
[M,n,ch] = Size (img);
if ch = = 3
img = Rgb2gray (img);
End
Figure;imshow (IMG), title (' original image ');
%d CT transform
IMG_DCT = Dct2 (img);
I = zeros (m,n);
% high Frequency shielding
I (1:M/3,1:N/3) =1;
YDCT = img_dct. * I;
% Inverse DCT Transform
img_dct = Uint8 (Idct2 (YDCT));
% result output
figure;imshow (IMG_DCT); title (' After de-noising ');
PSNR_DCT = Eval_psnr (IMG,IMG_DCT);
evaluation results and conclusions
We will find that the median filter is better than the DCT filter, but the [2,2] window filter is better than the [3,3] window filtering effect. Psnr Reviews
The PSNR can be simply defined by the mean variance MSE. The Psnr is based on the gray value of image pixels for statistical analysis. Because of the difference of human visual characteristics, the evaluation results that usually appear are inconsistent with people's main feeling, but it is still a reference value evaluation index.
The formula for the solution is
Max here is usually the grayscale level of the image, which is generally 255. When used to compare 2 images, the larger the Psnr, the higher the similarity between the images.
function [PSNR] = Eval_psnr (IMG,IMGN)% =================psnr rating param:% img: input grayscale image (IMG and IMGN equal size)% IMGN: Enter the grayscale image to be compared with B = 8; % encodes a pixel with how much bits MAX = 2^b-1;
% image has how many gray levels [height,width,~] = Size (IMG); MES = SUM (sum ((IMG-IMGN). ^2))/(Height*width); % mean variance PSNR = 20*log10 (max/sqrt (MES)); % peak signal-to-noise ratio end