Edge detection using directional filter.
Show older comments
I have made a diamond filter of 29*29 and then sampled it by 512. here is the code,
close all
clear all
clc
k=0.35;
for n1=0:28
for n2=0:28
z1= (n1^2)-((n2^2)*(k^2));
if n1==0 && n2==0
h(n1+1,n2+1)=k/2;
elseif n1~=0 && n2==0
h(n1+1,n2+1)=(k*(cos(n1*pi)-1))/((n1^2)*(pi^2));
elseif n2~=0 && z1==0
h(n1+1,n2+1)=0;
else
A= k/(((n2^2)*(k^2)-n1^2)*pi^2);
B= 1/(2*n2*pi^2);
C= (cos(((n2*k)-n1)*pi))/((n2*k)+n1);
D= (cos(((n2*k)+n1)*pi))/((n2*k)+n1);
h(n1+1,n2+1)= A-(B*(C+D));
end
end
end
hf=fft2(h,512,512);
hfn=max(max(abs(hf)));
hflog=20*log10((abs(hf))/hfn);
figure
mesh(hflog)
surf(hflog(1:end,1:end))
%plot3(hf,1:512,1:512)
%window function
n1=28
N= n1+1
t=1:N
w1=kaiser(N,4)
w1f=fft(w1,512);
%filter
A=fwind1(hf,w1);
freqz2(A)
Af=fft2(A,512,512);
figure
Afa=abs(Af);
surf(Afa(1:end,1:end))
figure
%image data
I = imread ('LEENA.bmp');
imshow(I)
figure
If=fft2(I);
Ifa=abs(If);
%operation
U=imfilter(Ifa,Afa);
Ui=ifft2(U);
Uia=abs(Ui);
imshow(Uia)
|
i have taken a standard image of LEENA, and applied the filter 'A' , but am unable to get the result. Uia results in white image.|
Answers (0)
Categories
Find more on Object Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!