Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

Adaptive filtering-local noise filter using Matlab


Adaptive filter is performed on the degraded image that contains original image and noise. The mean and variance are the two statistical measures that a local adaptive filter depends with a defined mxn window region. 


















A=imread('saturn.png');
B=rgb2gray(A);
sz=size(B,1)*size(B,2);
%Add gaussian noise with mean 0 and variance 0.005
B = imnoise(B,'gaussian',0,0.005);
figure,imshow(B); title('Image with gaussian noise');


B= double(B);

%Define the window size mxn
M=5;
N=5;

%Pad the matrix with zeros on all sides
C=padarray(B,[round(M/2),round(N/2)]);


lvar=zeros([size(B,1) size(B,2)]);
lmean=zeros([size(B,1) size(B,2)]);
temp=zeros([size(B,1) size(B,2)]);
NewImg=zeros([size(B,1) size(B,2)]);

for i=1:size(C,1)-M-1
    for j=1:size(C,2)-N-1
        
        
        temp=C(i:i+(M-1),j:j+(N-1));
        tmp=reshape(temp,[1,(M*N)]);
             %Find the local mean and local variance for the local region        
        lmean(i,j)=mean(tmp);
        lvar(i,j)=mean(tmp.^2)-mean(tmp).^2;
        
    end
end

%Noise variance and average of the local variance
nvar=sum(lvar(:))/sz;

%If noise_variance > local_variance then local_variance=noise_variance
 lvar=max(lvar,nvar);     

 %Final_Image=B- (noise variance/local variance)*(B-local_mean);
 NewImg=nvar./lvar;
 NewImg=NewImg.*(B-lmean);
 NewImg=B-NewImg;

 %Convert the image to uint8 format.
 NewImg=uint8(NewImg);
figure,imshow(NewImg);title('Restored Image using Adaptive Local filter');

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.