The ImageSource Utils

imageSource.utils contains functions which are of common use for image source devices. This is the list of the currently provided ones:

imageSourcePy.utils.unpack_mono12_packed()[source]

Unpack the input MONO12PACKED data to MONO12.

In MONO12PACKED pixel data format, every 3 bytes contain data for 2 pixels, according to the following table:

Byte Pixel - Data bits
B0 P0 11…4
B1 P1 3…0 | P0 3…0
B2 P1 11…4
Bm Pn 11…4
Parameters:
  • in_buffer – the input packed data
  • lock – an optional lock
Returns:

the output unpacked data

imageSourcePy.utils.unpack_mono_xx_p()[source]

Unpack the input MonoXXp data to MONO12, where XX is usually 10 or 12.

Use with caution! The function can be quite slow on large images.

In MONOXXp pixel data format, XX-bit pixel data are packed, with no padding bits in between. Padding 0s are added to the MSB if needed. For example Mono10p pixels are packed this way:

Byte Pixel - Data bits
B0 P0 7…0
B1 P1 5…0 | P0 9…8
B2 P2 3…0 | P1 9…6
B3 P4 1…0 | P3 9…4
Parameters:
  • data – the input packed data
  • bpp – the bits-per-pixel, normally 10 or 12
  • lock – an optional lock
Returns:

the output unpacked data

imageSourcePy.utils.unpack_mono10_p()[source]

Specialization of the ‘unpack_mono_xx_p’ function for the MONO10p format

imageSourcePy.utils.unpack_mono12_p()[source]

Specialization of the ‘unpack_mono_xx_p’ function for the MONO12p format