Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.unpackbits

numpy.unpackbits(myarray,axis=None)

Unpacks elements of a uint8 array into a binary-valued output array.

Each element ofmyarray represents a bit-field that should be unpackedinto a binary-valued output array. The shape of the output array is either1-D (ifaxis is None) or the same shape as the input array with unpackingdone along the axis specified.

Parameters:
myarray:ndarray, uint8 type

Input array.

axis:int, optional

The dimension over which bit-unpacking is done.None implies unpacking the flattened array.

Returns:
unpacked:ndarray, uint8 type

The elements are binary-valued (0 or 1).

See also

packbits
Packs the elements of a binary-valued array into bits in a uint8 array.

Examples

>>>a=np.array([[2],[7],[23]],dtype=np.uint8)>>>aarray([[ 2],       [ 7],       [23]], dtype=uint8)>>>b=np.unpackbits(a,axis=1)>>>barray([[0, 0, 0, 0, 0, 0, 1, 0],       [0, 0, 0, 0, 0, 1, 1, 1],       [0, 0, 0, 1, 0, 1, 1, 1]], dtype=uint8)

Previous topic

numpy.packbits

Next topic

numpy.binary_repr

Quick search

  • © Copyright 2008-2018, The SciPy community.
  • Last updated on Jul 24, 2018.
  • Created usingSphinx 1.6.6.

[8]ページ先頭

©2009-2025 Movatter.jp