pack8bit             package:wavethresh             R Documentation

_P_a_c_k_i_n_g _o_f _8-_b_i_t _I_n_t_e_g_e_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

     pack8bit(v8)
     unpack8bit(v)

_A_r_g_u_m_e_n_t_s:

      v8: integer vector with 8-bit elements in 0..255.

       v: integer vector (at least 32 bits).

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

     '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)'.

_A_u_t_h_o_r(_s):

     Martin Maechler

_S_e_e _A_l_s_o:

     'compress' etc for wavelet compression.

_E_x_a_m_p_l_e_s:

     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)))

