-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
34 lines (28 loc) · 963 Bytes
/
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
clear all; close all;
MIN_THRESH = 4;
LEVEL = 6;
LOGRESCALE = 0;
IMAGE = 'castle.png';
OIMAGE = 'castle';
DESIRED_TITERS = 10;
c = double(imread(IMAGE));
initThresh = encoder(c, OIMAGE, LEVEL, LOGRESCALE, MIN_THRESH);
[ic] = decoder(OIMAGE, DESIRED_TITERS);
figure;
imshow(touint8(c));
f= figure;
imshow(touint8(ic));
outFile = dir([OIMAGE '.gnj']);
fsize = ceil(outFile.bytes/1000);
[sx, sy, ~] = size(c);
[sxout, syout, ~] = size(ic);
t = sprintf('Original size: %d x %d\nRescaled: %d x %d', sx, sy, sxout, syout);
t = [t sprintf('\nQuantization: %g%%', 100*MIN_THRESH/initThresh)];
t = [t sprintf('\n Estimated compressed file size: %d kB', fsize)];
t = [t sprintf('\n Compression ratio (compared to raw size): %g', numel(c)/(1000*fsize))];
if LOGRESCALE == 0
t = [t sprintf('\nPSNR = %g', psnr(round(c),round(ic)))];
end
title(t);
set(findall(f,'-property','FontSize'),'FontSize',17);
set(findall(f,'-property','FontName'),'FontName', 'Helvetica');