Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@helper/dunzip.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function M = dunzip(Z) | |
2 % DUNZIP - decompress DZIP output to recover original data | |
3 % | |
4 % USAGE: | |
5 % M = dzip(Z) | |
6 % | |
7 % VARIABLES: | |
8 % Z = compressed variable to decompress | |
9 % M = decompressed output | |
10 % | |
11 % NOTES: (1) The input variable Z is created by the DZIP function and | |
12 % is a vector of type uint8 | |
13 % (2) The decompressed output will have the same data type and | |
14 % dimensions as the original data provided to DZIP. | |
15 % (3) See DZIP for other notes. | |
16 % (4) Carefully tested, but no warranty; use at your own risk. | |
17 % (5) Michael Kleder, Nov 2005 | |
18 | |
19 import com.mathworks.mlwidgets.io.InterruptibleStreamCopier | |
20 a=java.io.ByteArrayInputStream(Z); | |
21 b=java.util.zip.InflaterInputStream(a); | |
22 isc = InterruptibleStreamCopier.getInterruptibleStreamCopier; | |
23 c = java.io.ByteArrayOutputStream; | |
24 isc.copyStream(b,c); | |
25 Q=typecast(c.toByteArray,'uint8'); | |
26 cn = double(Q(1)); % class | |
27 nd = double(Q(2)); % # dims | |
28 s = typecast(Q(3:8*nd+2),'double')'; % size | |
29 Q=Q(8*nd+3:end); | |
30 if cn == 3 | |
31 M = logical(Q); | |
32 elseif cn == 4 | |
33 M = char(Q); | |
34 else | |
35 ct = {'double','single','logical','char','int8','uint8',... | |
36 'int16','uint16','int32','uint32','int64','uint64'}; | |
37 M = typecast(Q,ct{cn}); | |
38 end | |
39 M=reshape(M,s); | |
40 return |