Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Edge detection using directional filter.

Status
Not open for further replies.

Sujata Mourya

Newbie level 1
Joined
Jul 2, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
5
I have made a diamond filter of 29*29 and then sampled it by 512. here is the code,
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))


%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(Ui)

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top