on the image window output shows repeatation of image
    3 次查看(过去 30 天)
  
       显示 更早的评论
    
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 个评论
  Youssef  Khmou
      
 2013-12-13
				before the low pass filter try to convert the input into gray scale :
 T=rgb2gray(f);
回答(2 个)
  Youssef  Khmou
      
 2013-12-13
        
      编辑:Youssef  Khmou
      
 2013-12-13
  
      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 个评论
  Image Analyst
      
      
 2013-12-14
				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
      
      
 2013-12-13
        Just simply do
w = ones(7);
a1 = imfilter(double(a), w);
imshow(a1, []);
4 个评论
  Image Analyst
      
      
 2013-12-14
				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().
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!