-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBRaVO.m
131 lines (92 loc) · 2.06 KB
/
BRaVO.m
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
cd /Users/Dave/Documents/MATLAB/IMAGE_PROCESSING/
I0 = imread('P913786_20160811_153834_Angio (2)_L_001.jpg');
I = rgb2gray(I0);
figure(1)
imshow(I)
%Loading images, conversion to grayscale, displayed to confirm.
figure(2)
imhist(I)
%Image Histogram to find distribution of intensity levels
% I2 = histeq(I);
% figure(3)
% imshow(I2)
% figure(4)
% imhist(I2)
F = fft2(I);
figure(3)
imshow(F, [])
%Fast Fourier Transform to take the image into the frequency spectrum
F = fftshift(F);
F1 = abs(F);
% F1 = log(F1);
% F = mat2gray(F);
figure(4)
imshow(F, [])
figure(5)
imshow(F1, [])
[m,n] = size(I);
%% Ideal Band Reject Filter
myfilter = ones(m,n);
bandwidth = 20;
cutoff = 100;
LL = cutoff - bandwidth/2;
UL = cutoff + bandwidth/2;
for i=1:m-1
for j=1:n-1
dist = sqrt((i-m/2)^2 + (j-n/2)^2);
if (LL<=dist) && (dist<=UL)
myfilter(i,j) = 0;
end
end
end
G = myfilter.*F;
g1=abs(ifft2(G));
figure(7)
imshow(g1,[])
title('Ideal Band-Reject Filter')
figure(99)
imshow(mat2gray(myfilter))
title('Ideal Bandreject filter')
%%Butterworth
myfilter1 = ones(m,n);
bworder = 2;
bandwidth1 = 20;
cutoff1 = 100;
for i=1:m-1
for j=1:n-1
dist = sqrt((i-m/2)^2 + (j-n/2)^2);
myfilter1(i,j) = 1/(1 + (((dist*bandwidth1)/(dist^2 - cutoff1^2))^(2*bworder)));
end
end
G2 = myfilter1.*F;
g2=abs(ifft2(G2));
% figure(9)
% plot(myfilter)
figure(8)
imshow(g2,[])
title('Butterworth Band-Reject Filter')
figure(100)
imshow(mat2gray(myfilter1))
title('Butterworth Bandreject filter')
%%Gaussian
myfilter2 = ones(m,n);
bandwidth2 = 20;
cutoff2 = 100;
for i=1:m-1
for j=1:n-1
dist = sqrt((i-m/2)^2 + (j-n/2)^2);
myfilter2(i,j) = (1 - exp(-(((dist^2 - cutoff2^2)/(dist*bandwidth2))^2)));
end
end
G3 = myfilter2.*F;
g3=abs(ifft2(G3));
% figure(10)
% imshow(g3, [])
% title('Gaussian Band-Reject Filter')
%
% figure(101)
% imshow(mat2gray(myfilter2))
% title('Gaussian Bandreject filter')
% display(min(abs(F)))
%
% display(max(abs(F)))