myarray : an integer type array whose elements should be packed to bits
This routine packs the elements of a binary-valued dataset into a NumPy array of type uint8 (‘B’) whose bits correspond to the logical (0 or nonzero) value of the input elements. The dimension over-which bit-packing is done is given by axis. The shape of the output has the same number of dimensions as the input (unless axis is None, in which case the output is 1-d).
Example: >>> a = array([[[1,0,1], ... [0,1,0]], ... [[1,1,0], ... [0,0,1]]]) >>> b = numpy.packbits(a,axis=-1) >>> b array([[[160],[64]],[[192],[32]]], dtype=uint8)