-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilterHighpass.m
More file actions
29 lines (22 loc) · 770 Bytes
/
filterHighpass.m
File metadata and controls
29 lines (22 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function out = filterHighpass(image,D, gaussian)
%Does highpass filtering on the image, returns filtered image of the same
%size. D is appropriate for the type of filter, gaussian or 2nd order
%butterworth.
% Detailed explanation goes here
image=double(image);
[startr,startc]=size(image);
%find correct size for fft
r=nextpow2(startr);
c=nextpow2(startc);
%make image correct size, store this size to generate filter
r=2^r;
c=2^c;
f=padarray(image,[r-startr c-startc],'post');
F=fft2(f);
Fc=fftshift(F);%bring center frequencies to center of array
H=drawHighpass(c,r,D,gaussian);
Yc=Fc.*H;
y=ifft2(Yc);
y= y(1:startr,1:startc);%take same subset as starting with
out=mat2gray(abs(y));
end