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().
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!