on the image window output shows repeatation of image
    4 views (last 30 days)
  
       Show older comments
    
I am trying to implement low pass filter code but it is showing repeatation of output image on same window....Plz help me to overcome this problem
my code is like this--
clc;clear all;close all; f=imread('e:\IMAGES\quantum1.png');
a=imnoise(f,'gaussian',0,0.01);
w=[1 1 1 1 1 1 1;1 1 1 1 1 1 1;1 1 1 1 1 1 1;1 1 1 1 1 1 1;1 1 1 1 1 1 1;1 1 1 1 1 1 1;1 1 1 1 1 1 1 ]/49 [row col]=size(a); for x=4:1:row-4 for y=4:1:col-4 a1(x,y)=w(1)*a(x-3,y-3)+ w(2)*a(x-3,y-2)+ w(3)*a(x-3,y-1)+ w(4)*a(x-3,y)+ w(5)*a(x-3,y+1)+ w(6)*a(x-3,y+2)+ w(7)*a(x-3,y+3)+ w(8)*a(x-2,y-3)+ w(9)*a(x-2,y-2)+ w(10)*a(x-2,y-1)+ w(11)*a(x-2,y)+ w(12)*a(x-2,y+1)+ w(13)*a(x-2,y+2)+ w(14)*a(x-2,y+3)+ w(15)*a(x-1,y-3)+ w(16)*a(x-1,y-2)+ w(17)*a(x-1,y-1)+ w(18)*a(x-1,y)+ w(19)*a(x-1,y+1)+ w(20)*a(x-1,y+2)+ w(21)*a(x-1,y+3)+w(22)*a(x,y-3)+ w(23)*a(x,y-2)+ w(24)*a(x,y-1)+ w(25)*a(x,y)+ w(26)*a(x,y+1)+ w(27)*a(x,y+2)+ w(28)*a(x,y+3)+w(29)*a(x+1,y-3)+ w(30)*a(x+1,y-2)+ w(31)*a(x+1,y-1)+ w(32)*a(x+1,y)+ w(33)*a(x+1,y+1)+ w(34)*a(x+1,y+2)+ w(35)*a(x+1,y+3)+w(36)*a(x+2,y-3)+ w(37)*a(x+2,y-2)+ w(38)*a(x+2,y-1)+ w(39)*a(x+2,y)+ w(40)*a(x+2,y+1)+ w(41)*a(x+2,y+2)+ w(42)*a(x+2,y+3)+w(43)*a(x+3,y-3)+ w(44)*a(x+3,y-2)+ w(45)*a(x+3,y-1)+ w(46)*a(x+3,y)+ w(47)*a(x+3,y+1)+ w(48)*a(x+3,y+2)+ w(49)*a(x+3,y+3); end end figure(1) imshow(a)
figure(2) imshow(a1)
Also,how to convert grayscale image to binary image?????

1 Comment
  Youssef  Khmou
      
 on 13 Dec 2013
				before the low pass filter try to convert the input into gray scale :
 T=rgb2gray(f);
Answers (2)
  Youssef  Khmou
      
 on 13 Dec 2013
        
      Edited: Youssef  Khmou
      
 on 13 Dec 2013
  
      hi,
The code you provided is working correctly, but you did not exploit the matrix operations effectively, here is simpler version of you program :
clc;clear all;close all;
%f=imread('e:\IMAGES\quantum1.png');
f=im2double(imread('circuit.tif'));
a=imnoise(f,'gaussian',0,0.01);
w=ones(7)/49;
[row col]=size(a);
a1=zeros(row,col);
for x=4:1:row-4 
  for y=4:1:col-4 
      a1(x,y)=sum(sum(w.*a(x-3:x+3,y-3:y+3)));
  end
end
figure(1),imshow(a)
figure(2),imshow(a1)
The binary transformation is given by :
 b=im2bw(a1);
figure(3), imshow(b)
2 Comments
  Image Analyst
      
      
 on 14 Dec 2013
				That's because you have a color image and you're not using the size function properly. Please see http://blogs.mathworks.com/steve/2011/03/22/too-much-information-about-the-size-function/
  Image Analyst
      
      
 on 13 Dec 2013
        Just simply do
w = ones(7);
a1 = imfilter(double(a), w);
imshow(a1, []);
4 Comments
  Image Analyst
      
      
 on 14 Dec 2013
				You have a color image so you need to convert to hsv with rgb2hsv(), then blur the v image only with imfilter() or conv2(). Then convert back to rgb with hsv2rgb().
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

