-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
127 lines (105 loc) · 2.2 KB
/
main.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
%% Akhilesh Ravi 16110007
%% Implementation of various binarization, halftoning and error diffusion function
%Input Image
%image = 'campus';
image = 'river';
%image = 'snow';
try
if image == 'campus'
imagename = strcat(image,'.png');
else
imagename = strcat(image,'.jpg');
end
catch
imagename = strcat(image,'.jpg');
end
img = imread(imagename);
%img = img(:,:,3);
try
if size(size(img)) == [1 3]
f = rgb2gray(img);
else
f = img;
end
catch
f = img;
end
%image = 'blue';
%% Thresholding
g1 = threshold_161100007(f);
figure
try
imshow(g1)
truesize
imwrite(g1, strcat(image,'g1.tiff'));
catch
end
%% Random Noise Thresholding
[f1, g2] = noiser_16110007(f);
figure
try
imshow(g2)
truesize
imwrite(g2, strcat(image,'g2.tiff'));
catch
end
%% Halftoning with dither matrix sizes
[g3, g4, g5] = halftone_16110007(f);
figure
try
imshow(g3)
truesize
imwrite(g3, strcat(image,'g3.tiff'));
catch
end
figure
try
imshow(g4)
truesize
imwrite(g4, strcat(image,'g4.tiff'));
catch
end
figure
try
imshow(g5)
truesize
imwrite(g5, strcat(image,'g5.tiff'));
catch
end
%% Error diffusion
g6 = error_diffusion_16110007(f);
figure
try
imshow(g6)
truesize
imwrite(g6, strcat(image,'g6.tiff'));
catch
end
%% Fidelity Metrics
A = zeros(6);
[a1, a2, a3, a4, a5, a6] = fidelity_16110007(f,g1);
A(1,:) = [a1, a2, a3, a4, a5, a6];
[a1, a2, a3, a4, a5, a6] = fidelity_16110007(f,g2);
A(2,:) = [a1, a2, a3, a4, a5, a6];
[a1, a2, a3, a4, a5, a6] = fidelity_16110007(f,g3);
A(3,:) = [a1, a2, a3, a4, a5, a6];
[a1, a2, a3, a4, a5, a6] = fidelity_16110007(f,g4);
A(4,:) = [a1, a2, a3, a4, a5, a6];
[a1, a2, a3, a4, a5, a6] = fidelity_16110007(f,g5);
A(5,:) = [a1, a2, a3, a4, a5, a6];
[a1, a2, a3, a4, a5, a6] = fidelity_16110007(f,g6);
A(6,:) = [a1, a2, a3, a4, a5, a6];
disp(' Fidelity Metrics')
disp(' a1 a2 a3 a4 a5 a6')
disp('g1')
disp(A(1,:))
disp('g2')
disp(A(2,:))
disp('g3')
disp(A(3,:))
disp('g4')
disp(A(4,:))
disp('g5')
disp(A(5,:))
disp('g6')
disp(A(6,:))