SlideShare a Scribd company logo
1 of 2
%% Implementation of Decision-Based Algorithm for Removal of High-Density
%% Impulse Noises
%% Base Paper : "A New Fast and Efficient Decision-Based Algorithm for
% Removal of High-Density Impulse Noises", IEEE Sigmal Pricessing Letter,
% Vol. 14,No. 3, Mar 2007.
%% Function Y = DBAIN(x)
%% input     x = Given an Image
%%
%% Example: Y = DBAIN(x);
%%       Posted date    : 23 - 10 - 2008
%%       Modified date :
%%
%% Developed By : K.Kannan (kannan.keizer@gmail.com)
%%                  & Jeny Rajan (jenyrajan@gmail.com)
%%                    Medical Imaging Research Group (MIRG), NeST,
%%                    Trivandrum.
%%
%% Decision-Based Algorithm for Removal of High-Density Impulse Noises
function Y = DBAIN(x)
%% Demo
disp('Noise density lies between 0 and 1');
%% Noise Generation
disp(' ');
ND = input('Enter Noise Density [0.5] : ');
if isempty(ND)
    ND = 0.5;
end
y = imnoise(x,'salt & pepper',ND);
y = double(y);
Y = y;
[R C] = size(x);
%% Implementation
for i = 2:R-1
    for j = 2:C-1
         clear tmp;
         tmp = Y(i-1:i+1,j-1:j+1);
         flg = 0;
         S = sort(tmp(:));
         if Y(i,j) == 0 || Y(i,j) == 255
             flg = 1;
         end
         if flg == 0 % if the Pixel is uncorrupted.
             if S(1) < Y(i,j) && Y(i,j) < S(5) && 0 < S(1) && S(9) < 255 % The
                  % P(X,Y) is an uncorrupted pixel if Pmin < P(X,Y) < Pmax,
                  % Pmin > 0 and Pmax < 255; the pixel being processed is
                  % left unchanged. Otherwise, P(X,Y) is a corrupted pixel.
                  Y(i,j) = Y(i,j);
             end
         else % if the Pixel is corrupted.
             if S(1) < S(5) && S(5) < S(9) && 0 < S(5) && S(5) < 255 % If P(X,Y)
                  % is a corrupted pixel, it is replaced by its median value
                  % if Pmin < Pmed < Pmax and 0 < Pmed < 255.
                  Y(i,j) = S(5);
             end
             if S(1) >= S(5) || S(5) >= S(9) || S(5) == 255 && S(5) == 0
                  % If Pmin < Pmed < Pmax is not satisfied or 255 < Pmed = 0,
                  % then is a noisy pixel. In this case, the P(X,Y) is replaced
                  % by the value of neighborhood pixel value.
                  Y(i,j) = Y(i,j-1);
             end
         end
    end
end
%% Border Correction
Y(1,:) = Y(2,:);
Y(R,:) = Y(R-1,:);
Y(:,1) = Y(:,2);
Y(:,C) = Y(:,C-1);
f = medfilt2(y,[3 3]);
figure;subplot(2,2,1);imshow(x,[]);title('Given Image');
subplot(2,2,2);imshow(y,[]);title(strcat('Noisy : Noise Density -
',num2str(ND)));xlabel(PSNR(x,y));
subplot(2,2,3);imshow(f,[]);title('Traditional Median');xlabel(PSNR(x,f));
subplot(2,2,4);imshow(Y,[]);title('DBA');xlabel(PSNR(x,Y));

%% PSNR
function P = PSNR(A,B)
A = double(A);B = double(B);
error = abs(A - B);
P = 20*log10(255/(sqrt(mean(mean(error.^2)))));

More Related Content

What's hot

Standard form solve equations
Standard form solve equationsStandard form solve equations
Standard form solve equationspfefferteacher
 
IB Maths SL Transformations of functions
IB Maths SL Transformations of functionsIB Maths SL Transformations of functions
IB Maths SL Transformations of functionsestelav
 
January 10, 2014
January 10, 2014January 10, 2014
January 10, 2014khyps13
 
Amth250 octave matlab some solutions (4)
Amth250 octave matlab some solutions (4)Amth250 octave matlab some solutions (4)
Amth250 octave matlab some solutions (4)asghar123456
 
If control structure in c lnaguage
If control structure in c lnaguageIf control structure in c lnaguage
If control structure in c lnaguageInnovative
 

What's hot (11)

Standard form solve equations
Standard form solve equationsStandard form solve equations
Standard form solve equations
 
IB Maths SL Transformations of functions
IB Maths SL Transformations of functionsIB Maths SL Transformations of functions
IB Maths SL Transformations of functions
 
Dwp08 0106
Dwp08 0106Dwp08 0106
Dwp08 0106
 
January 10, 2014
January 10, 2014January 10, 2014
January 10, 2014
 
Gm
GmGm
Gm
 
Lesson 3.4
Lesson 3.4Lesson 3.4
Lesson 3.4
 
Transformations
TransformationsTransformations
Transformations
 
Amth250 octave matlab some solutions (4)
Amth250 octave matlab some solutions (4)Amth250 octave matlab some solutions (4)
Amth250 octave matlab some solutions (4)
 
Image fft
Image fftImage fft
Image fft
 
Day 6 examples
Day 6 examplesDay 6 examples
Day 6 examples
 
If control structure in c lnaguage
If control structure in c lnaguageIf control structure in c lnaguage
If control structure in c lnaguage
 

Viewers also liked

Putting Learners First (Revised and Updated 10/22/15)
Putting Learners First (Revised and Updated 10/22/15)Putting Learners First (Revised and Updated 10/22/15)
Putting Learners First (Revised and Updated 10/22/15)David Blake
 
TRAFFIC CODE MATLAB Function varargouttraffic code
TRAFFIC CODE MATLAB Function varargouttraffic codeTRAFFIC CODE MATLAB Function varargouttraffic code
TRAFFIC CODE MATLAB Function varargouttraffic codeYograj Ghodekar
 
QPatch By Sophion
QPatch By SophionQPatch By Sophion
QPatch By Sophionchrismathes
 
Sistema cardiovascular by Danusa Menegaz
Sistema cardiovascular by Danusa MenegazSistema cardiovascular by Danusa Menegaz
Sistema cardiovascular by Danusa MenegazDanusa Menegaz
 
Matlab to vhdl
Matlab to vhdlMatlab to vhdl
Matlab to vhdlsumalama
 
Pca matlab code_matlab_central
Pca matlab code_matlab_centralPca matlab code_matlab_central
Pca matlab code_matlab_centraldkkamat
 
Matlab code of chapter 4
Matlab code of chapter 4Matlab code of chapter 4
Matlab code of chapter 4Mohamed El Kiki
 
Matlab code of chapter 4
Matlab code of chapter 4Matlab code of chapter 4
Matlab code of chapter 4Abdo Khalaf
 
Code matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimo
Code matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimoCode matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimo
Code matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimoPTIT HCM
 
Bioelectric Communication Between Neurons
Bioelectric Communication Between NeuronsBioelectric Communication Between Neurons
Bioelectric Communication Between NeuronsLuís Rita
 
Understanding and Developing Web Services - For DBAs and Developers (whitepaper)
Understanding and Developing Web Services - For DBAs and Developers (whitepaper)Understanding and Developing Web Services - For DBAs and Developers (whitepaper)
Understanding and Developing Web Services - For DBAs and Developers (whitepaper)Revelation Technologies
 
Patch-Clamp by Menegaz Danusa Ph.D
Patch-Clamp by Menegaz Danusa Ph.DPatch-Clamp by Menegaz Danusa Ph.D
Patch-Clamp by Menegaz Danusa Ph.DDanusa Menegaz
 
Satellite link-budget-analysis-matlab-code
Satellite link-budget-analysis-matlab-codeSatellite link-budget-analysis-matlab-code
Satellite link-budget-analysis-matlab-codevijaya selvan sundaram
 
IGARSS2011_SWOT_mesoscale_morrow.ppt
IGARSS2011_SWOT_mesoscale_morrow.pptIGARSS2011_SWOT_mesoscale_morrow.ppt
IGARSS2011_SWOT_mesoscale_morrow.pptgrssieee
 
Matlab code for comparing two microphone files
Matlab code for comparing two microphone filesMatlab code for comparing two microphone files
Matlab code for comparing two microphone filesMinh Anh Nguyen
 
Basics of edge detection and forier transform
Basics of edge detection and forier transformBasics of edge detection and forier transform
Basics of edge detection and forier transformSimranjit Singh
 

Viewers also liked (20)

Putting Learners First (Revised and Updated 10/22/15)
Putting Learners First (Revised and Updated 10/22/15)Putting Learners First (Revised and Updated 10/22/15)
Putting Learners First (Revised and Updated 10/22/15)
 
TRAFFIC CODE MATLAB Function varargouttraffic code
TRAFFIC CODE MATLAB Function varargouttraffic codeTRAFFIC CODE MATLAB Function varargouttraffic code
TRAFFIC CODE MATLAB Function varargouttraffic code
 
QPatch By Sophion
QPatch By SophionQPatch By Sophion
QPatch By Sophion
 
Sistema cardiovascular by Danusa Menegaz
Sistema cardiovascular by Danusa MenegazSistema cardiovascular by Danusa Menegaz
Sistema cardiovascular by Danusa Menegaz
 
Matlab to vhdl
Matlab to vhdlMatlab to vhdl
Matlab to vhdl
 
Matlab code for secant method
Matlab code for secant methodMatlab code for secant method
Matlab code for secant method
 
Pca matlab code_matlab_central
Pca matlab code_matlab_centralPca matlab code_matlab_central
Pca matlab code_matlab_central
 
Matlab code of chapter 4
Matlab code of chapter 4Matlab code of chapter 4
Matlab code of chapter 4
 
Matlab code of chapter 4
Matlab code of chapter 4Matlab code of chapter 4
Matlab code of chapter 4
 
Code matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimo
Code matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimoCode matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimo
Code matlab mô phỏng dung lượng kênh truy ền reyleght trong kĩ thuật mimo
 
Matlab code for crout method
Matlab code for crout methodMatlab code for crout method
Matlab code for crout method
 
Bioelectric Communication Between Neurons
Bioelectric Communication Between NeuronsBioelectric Communication Between Neurons
Bioelectric Communication Between Neurons
 
DFT and IDFT Matlab Code
DFT and IDFT Matlab CodeDFT and IDFT Matlab Code
DFT and IDFT Matlab Code
 
Understanding and Developing Web Services - For DBAs and Developers (whitepaper)
Understanding and Developing Web Services - For DBAs and Developers (whitepaper)Understanding and Developing Web Services - For DBAs and Developers (whitepaper)
Understanding and Developing Web Services - For DBAs and Developers (whitepaper)
 
Patch-Clamp by Menegaz Danusa Ph.D
Patch-Clamp by Menegaz Danusa Ph.DPatch-Clamp by Menegaz Danusa Ph.D
Patch-Clamp by Menegaz Danusa Ph.D
 
Satellite link-budget-analysis-matlab-code
Satellite link-budget-analysis-matlab-codeSatellite link-budget-analysis-matlab-code
Satellite link-budget-analysis-matlab-code
 
IGARSS2011_SWOT_mesoscale_morrow.ppt
IGARSS2011_SWOT_mesoscale_morrow.pptIGARSS2011_SWOT_mesoscale_morrow.ppt
IGARSS2011_SWOT_mesoscale_morrow.ppt
 
Modulation techniques matlab_code
Modulation techniques matlab_codeModulation techniques matlab_code
Modulation techniques matlab_code
 
Matlab code for comparing two microphone files
Matlab code for comparing two microphone filesMatlab code for comparing two microphone files
Matlab code for comparing two microphone files
 
Basics of edge detection and forier transform
Basics of edge detection and forier transformBasics of edge detection and forier transform
Basics of edge detection and forier transform
 

Similar to Dba matlab code

The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorAbhranil Das
 
MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709Min-hyung Kim
 
ECE 565 Project1
ECE 565 Project1ECE 565 Project1
ECE 565 Project1?? ?
 
E E 458 Project 003
E E 458 Project 003E E 458 Project 003
E E 458 Project 003Chad Weiss
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing DesignV Tripathi
 
Solution Manual Image Processing for Engineers by Yagle and Ulaby
Solution Manual Image Processing for Engineers by Yagle and UlabySolution Manual Image Processing for Engineers by Yagle and Ulaby
Solution Manual Image Processing for Engineers by Yagle and Ulabyspaceradar35
 
Conference poster 6
Conference poster 6Conference poster 6
Conference poster 6NTNU
 
Optimal control problem for processes
Optimal control problem for processesOptimal control problem for processes
Optimal control problem for processesIJCI JOURNAL
 
Problem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element MethodProblem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element MethodPeter Herbert
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」Ken'ichi Matsui
 
Dct compressionfactor8.doc
Dct compressionfactor8.docDct compressionfactor8.doc
Dct compressionfactor8.docMITTU1
 

Similar to Dba matlab code (20)

The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
Adaptive signal processing simon haykins
Adaptive signal processing simon haykinsAdaptive signal processing simon haykins
Adaptive signal processing simon haykins
 
MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709
 
ECE 565 Project1
ECE 565 Project1ECE 565 Project1
ECE 565 Project1
 
E E 458 Project 003
E E 458 Project 003E E 458 Project 003
E E 458 Project 003
 
matlab codes.pdf
matlab codes.pdfmatlab codes.pdf
matlab codes.pdf
 
Martha
MarthaMartha
Martha
 
Computer Aided Manufacturing Design
Computer Aided Manufacturing DesignComputer Aided Manufacturing Design
Computer Aided Manufacturing Design
 
E251014
E251014E251014
E251014
 
Solution Manual Image Processing for Engineers by Yagle and Ulaby
Solution Manual Image Processing for Engineers by Yagle and UlabySolution Manual Image Processing for Engineers by Yagle and Ulaby
Solution Manual Image Processing for Engineers by Yagle and Ulaby
 
Nbvtalkatbzaonencryptionpuzzles
NbvtalkatbzaonencryptionpuzzlesNbvtalkatbzaonencryptionpuzzles
Nbvtalkatbzaonencryptionpuzzles
 
Nbvtalkatbzaonencryptionpuzzles
NbvtalkatbzaonencryptionpuzzlesNbvtalkatbzaonencryptionpuzzles
Nbvtalkatbzaonencryptionpuzzles
 
matlab.docx
matlab.docxmatlab.docx
matlab.docx
 
Vcs9
Vcs9Vcs9
Vcs9
 
Conference poster 6
Conference poster 6Conference poster 6
Conference poster 6
 
Optimal control problem for processes
Optimal control problem for processesOptimal control problem for processes
Optimal control problem for processes
 
Problem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element MethodProblem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element Method
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
 
Dct compressionfactor8.doc
Dct compressionfactor8.docDct compressionfactor8.doc
Dct compressionfactor8.doc
 
Assignmnt 4
Assignmnt 4Assignmnt 4
Assignmnt 4
 

Dba matlab code

  • 1. %% Implementation of Decision-Based Algorithm for Removal of High-Density %% Impulse Noises %% Base Paper : "A New Fast and Efficient Decision-Based Algorithm for % Removal of High-Density Impulse Noises", IEEE Sigmal Pricessing Letter, % Vol. 14,No. 3, Mar 2007. %% Function Y = DBAIN(x) %% input x = Given an Image %% %% Example: Y = DBAIN(x); %% Posted date : 23 - 10 - 2008 %% Modified date : %% %% Developed By : K.Kannan (kannan.keizer@gmail.com) %% & Jeny Rajan (jenyrajan@gmail.com) %% Medical Imaging Research Group (MIRG), NeST, %% Trivandrum. %% %% Decision-Based Algorithm for Removal of High-Density Impulse Noises function Y = DBAIN(x) %% Demo disp('Noise density lies between 0 and 1'); %% Noise Generation disp(' '); ND = input('Enter Noise Density [0.5] : '); if isempty(ND) ND = 0.5; end y = imnoise(x,'salt & pepper',ND); y = double(y); Y = y; [R C] = size(x); %% Implementation for i = 2:R-1 for j = 2:C-1 clear tmp; tmp = Y(i-1:i+1,j-1:j+1); flg = 0; S = sort(tmp(:)); if Y(i,j) == 0 || Y(i,j) == 255 flg = 1; end if flg == 0 % if the Pixel is uncorrupted. if S(1) < Y(i,j) && Y(i,j) < S(5) && 0 < S(1) && S(9) < 255 % The % P(X,Y) is an uncorrupted pixel if Pmin < P(X,Y) < Pmax, % Pmin > 0 and Pmax < 255; the pixel being processed is % left unchanged. Otherwise, P(X,Y) is a corrupted pixel. Y(i,j) = Y(i,j); end else % if the Pixel is corrupted. if S(1) < S(5) && S(5) < S(9) && 0 < S(5) && S(5) < 255 % If P(X,Y) % is a corrupted pixel, it is replaced by its median value % if Pmin < Pmed < Pmax and 0 < Pmed < 255. Y(i,j) = S(5); end if S(1) >= S(5) || S(5) >= S(9) || S(5) == 255 && S(5) == 0 % If Pmin < Pmed < Pmax is not satisfied or 255 < Pmed = 0, % then is a noisy pixel. In this case, the P(X,Y) is replaced % by the value of neighborhood pixel value. Y(i,j) = Y(i,j-1); end end end end %% Border Correction
  • 2. Y(1,:) = Y(2,:); Y(R,:) = Y(R-1,:); Y(:,1) = Y(:,2); Y(:,C) = Y(:,C-1); f = medfilt2(y,[3 3]); figure;subplot(2,2,1);imshow(x,[]);title('Given Image'); subplot(2,2,2);imshow(y,[]);title(strcat('Noisy : Noise Density - ',num2str(ND)));xlabel(PSNR(x,y)); subplot(2,2,3);imshow(f,[]);title('Traditional Median');xlabel(PSNR(x,f)); subplot(2,2,4);imshow(Y,[]);title('DBA');xlabel(PSNR(x,Y)); %% PSNR function P = PSNR(A,B) A = double(A);B = double(B); error = abs(A - B); P = 20*log10(255/(sqrt(mean(mean(error.^2)))));