im_msb(3)

im_msb3

Convert to uchar by discarding bits

Usage

#include <vips/vips.h>

int im_msb( IMAGE *in, IMAGE *out );
int im_msb_band( IMAGE *in, IMAGE *out, int band );

Overview

im_msb(3) converts char, short, or int images (including LABQ coded ones) into unsigned char images, very quickly, by discarding the lower order bits. Once scaled to char, signed values are converted to unsigned by adding 128.

For a signed short (16 bit) image,

im_msb( in, out );

is equivalent to:

im_lintra( (1.0/256.0), in, 128.0, temp );
im_clip2fmt( temp, out, IM_BANDFMT_UCHAR );

but much faster.

For any image which uses the whole range of values for its band format,

im_msb( in, out );

is equivalent to:

im_scale( in, out );

but a great deal faster, and without evaluating the input twice.

im_msb_band(3) is as im_msb(3), except that all but one of the bands are also discarded.

im_msb_band( in, out, i );

is equivalent to:

im_msb( in, temp );
im_extract_bands( temp, out, i, 1 );

but again, faster.

Return value

The functions returns 0 on success and -1 on error.

Releases

Unchanged in 2 releases since Debian 5.0 (Lenny).

  1. 5.0–6.0

Author

Tom Vajzovic

From libvips-dev 7.20.7-1+b3 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.