-
Notifications
You must be signed in to change notification settings - Fork 227
/
test_openjpeg.m
35 lines (31 loc) · 907 Bytes
/
test_openjpeg.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
% test for OpengJPEG implementation of the JPEG2000 Codec
clear options;
name = 'lena';
M = load_image(name);
test_type = 'rate';
test_type = 'db';
test_type = 'bits';
switch test_type
case 'rate'
% compression of a factor 30
options.rate = 30;
case 'db'
% compression with given erro
options.db = 30;
case 'bits'
options.nbr_bits = 5e4;
end
% Compression:
[stream,nbr_bits] = perform_jp2k_compression(M,options);
% De-compression:
M1 = perform_jp2k_compression(stream,options);
bd = ceil(log2(max(M(:))));
nbr_bits_orig = bd*prod(size(M));
clf;
subplot(1,2,1);
imagesc(M); axis image, axis off;
title('Original');
subplot(1,2,2);
imagesc(M1); axis image, axis off;
title(['Compressed, db=' num2str(psnr(M,M1,2^bd),3) ', rate=' num2str(nbr_bits_orig/nbr_bits,3), ' nbrbits=' num2str(nbr_bits,3) ]);
colormap gray(256)