: bwpack (bw)

Pack binary image.

Packs binary image bw into an array of 32 bit unsigned integers. Each 32 elements of bw are packed into a uint32 integer, the first row corresponding to the least significant bit and the 32th row corresponding to the most significant bit.

Packing is performed along the first dimension (rows), so that each 32 rows on each column correspond to one element in the packed image. bw is zero-padded if its height isn’t an exact multiple of 32. It is thus necessary to remember the height of the original image in order to retrieve it from the packed version, e.g. by calling bwunpack.

bw is converted to logical before packing, non-zero elements being converted to true.

See also: bwunpack, bitpack, bitunpack.

Package: image