Here we discuss about Switching Bilateral Filter Noise Removal step by step.
1.Read the image pixel by pixel (i,j).
2. Each pixel we construct 4 sub windows.
For a (2N+1) *(2N+1) window we divide the window into four (N+1)*(N+1) subwindows .
case N = 2
1.Read the image pixel by pixel (i,j).
2. Each pixel we construct 4 sub windows.
For a (2N+1) *(2N+1) window we divide the window into four (N+1)*(N+1) subwindows .
case N = 2
3.Find the Sorted Quadrant Median Vector (SQMV) for all subwindows.
SQM1, SQM2, SQM3 and SQM4 are the medians
4. Then we find the regions from above all SQM.
Uniform Region
Diagonal edge in dark side
Diagonal edge in dark side
Veritical edge
Horizontal edge
Diagonal line
Gradual chage edge
Texture
5. Then we find the reference median (SQMR) based on above regions.
6. Then apply Bilateral Filter.
7. The apply noise detection .
Code:
clc
clear all
close all
close all hidden
warning off
con = 1; % con1 for
img = imread('lena.jpg');
figure;imshow(img);
title('Input Image');
img = imnoise(img,'salt & pepper',0.01); % salt and pepper
Tk1 = 30; % for salt and paper noise..
Tk2 = 15; % for salt and paper noise..
% img = imnoise(img,'gaussian',0,0.01); % gaussian noise
% Tk1 = 25; % for Gaussian noise..
% Tk2 = 5; % for Gaussian noise..
img = double(img);
figure;imshow(uint8(img));
title('Noisy Image');
ext_filt = img;
sigma_R = 40;
[r c] = size(img);
N = 2;
pi_val = 25;
h = waitbar(0,'Applying Switching bilateral filter..');
L = 1;
for i = (N+1):r-(N+1)
waitbar(L/length((N+1):r-(N+1)));
L = L+1;
for j = (N+1):c-(N+1)
[m0,m1,m2,m3,m4] = meadian_calc(i,j,img,N);
dav = dav_valc(m1,m2,m3,m4,img,i,j);
SQMDB = m4-m1;
SQMDC = m3-m2;
SQMR = SQMR_calc(SQMDC,m1,m2,m3,m4,dav,pi_val);
[s1 s2] = find_S1_S2(img,i,j,SQMR,Tk1,Tk2);
if(dav~=0)
sigma_S = 3;
else
sigma_S = 1;
end
f_x_y = f_of_x_y(i,j,N,img,sigma_S,sigma_R,s2,SQMR);
ext_filt(i,j) = f_x_y;
end
end
close(h);
figure;
imshow(uint8(ext_filt));%output...
Referencce : Switching Bilateral Filter With a Texture/Noise Detector for Universal Noise Removal Chih-Hsing Lin, Jia-Shiuan Tsai, and Ching-Te Chiu Transactions on: Image Processing, IEEE Journals 2010