Skip to content

Commit dc52b93

Browse files
committed
Added main file to run the tests
1 parent fcc3804 commit dc52b93

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

main.m

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
% figure 1
2+
%for i = 1:8
3+
% temp = quantize_matrix(lena_gray_512,i);
4+
% subplot(2,4,i,'replace')
5+
% imshow(temp,[0,2^(i)-1]);
6+
%end
7+
8+
%figure 2
9+
%for i = 1:8
10+
% temp = quantize_matrix(lena_gray_512,i);
11+
% temp2 = dequantize_matrix(temp,i,8);
12+
% subplot(2,4,i,'replace')
13+
% imshow(temp2);
14+
%end
15+
16+
%zeros(8,N,M)
17+
18+
%for j = 1:8
19+
% output=zeros(256,1);
20+
% delta = 2^(8-j);
21+
% for i = 0:255
22+
% output(i+1,1) = dequantize(quantize(i,j),delta);
23+
% end
24+
% subplot(2,4,j,'replace')
25+
% plot(0:255,output(:,1));
26+
% axis([0,255,0,255])
27+
%end
28+
29+
%for j = 1:8
30+
% output=zeros(256,1);
31+
% for i = 0:255
32+
% output(i+1,1) = quantize(i,j);
33+
% end
34+
% subplot(2,4,j,'replace')
35+
% plot(0:255,output(:,1));
36+
% axis([0,255,0,2^(j)])
37+
%end
38+
39+
%results = zeros(8,1);
40+
%for i = 1:8
41+
% temp = dequantize_matrix(quantize_matrix(lena_gray_512,i),i,8);
42+
% D = abs(lena_gray_512-temp).^2;
43+
% MSE = sum(D(:))/numel(lena_gray_512);
44+
% results(i,1) = MSE;
45+
%end
46+
%plot(1:8,results);
47+
48+
49+
50+
%function quantization = quantize(pixel, new_bytesize)
51+
% dif_levels = 2^(8-new_bytesize);
52+
% quantization=floor(double(pixel)/double(dif_levels));
53+
%end
54+
55+
%function dequantization = dequantize(pixel, delta)
56+
% Operation avg*Pixel+avg changed to:
57+
% dequantization= delta*(double(pixel) + 0.5);
58+
%end

0 commit comments

Comments
 (0)