pack8bit {wavethresh} | R Documentation |
In image processing, often pictures are stored as long array of values
in 0:255
. For (file) storage, these can be packed into 32 bit
integers. These functions are for packing and unpacking.
pack8bit(v8) unpack8bit(v)
v8 |
integer vector with 8-bit elements in 0..255. |
v |
integer vector (at least 32 bits). |
If the length of v8
is not a multiple of 4, v8
is effectively padded with one to three 0
s.
The implementation is straightforward and short; look at the function definitions.
pack8bit(v8)
returns an integer vector of length
ceiling(length(v8) / 4)
.
unpack8bit(v)
returns a vector of values from 0:255
of
length 4 * length(v)
.
Martin Maechler
compress
etc for wavelet compression.
pack8bit(0:11) (pack8bit(0:11) == pack8bit(0:9))# both need 3 32-bit ints; only 1st is = ## BUG: all(250:255 == unpack8bit(pack8bit(250:255))) stopifnot(0:255 == unpack8bit(pack8bit(0:255)))