(packed)
Unpacks a single integer or array of integers into one or more
24-bit RGB values.
Unpacks a single integer or array of integers into one or more
24-bit RGB values.
Unpacks a single integer or array of integers into one or more 24 - bit RGB values .
def unpack_rgb(packed):
    '''Unpacks a single integer or array of integers into one or more
24-bit RGB values.

    '''

    orig_shape = None

    if isinstance(packed, np.ndarray):
        assert packed.dtype == int
        orig_shape = packed.shape
        packed = packed.reshape((-1, 1))

    rgb = ((packed >> 16) & 0xff,
           (packed >> 8) & 0xff,
           (packed) & 0xff)

    if orig_shape is None:
        return rgb
    else:
        return np.hstack(rgb).reshape(orig_shape + (3,))
def unpack_rgb ( packed ) : orig_shape = None if isinstance ( packed , np . ndarray ) : assert packed . dtype == int orig_shape = packed . shape packed = packed . reshape ( ( - 1 , 1 ) ) rgb = ( ( packed >> 16 ) & 0xff , ( packed >> 8 ) & 0xff , ( packed ) & 0xff ) if orig_shape is None : return rgb else : return np . hstack ( rgb ) . reshape ( orig_shape + ( 3 , ) )