boolean

boolean — boolean algebra on images, bitshifts

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <vips/vips.h>

int                 im_andimage                         (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);
int                 im_orimage                          (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);
int                 im_eorimage                         (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);
int                 im_andimage_vec                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);
int                 im_andimageconst                    (IMAGE *in,
                                                         IMAGE *out,
                                                         double c);
int                 im_orimage_vec                      (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);
int                 im_orimageconst                     (IMAGE *in,
                                                         IMAGE *out,
                                                         double c);
int                 im_eorimage_vec                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);
int                 im_eorimageconst                    (IMAGE *in,
                                                         IMAGE *out,
                                                         double c);
int                 im_shiftleft_vec                    (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);
int                 im_shiftleft                        (IMAGE *in,
                                                         IMAGE *out,
                                                         int n);
int                 im_shiftright_vec                   (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);
int                 im_shiftright                       (IMAGE *in,
                                                         IMAGE *out,
                                                         int n);

Description

These operations perform boolean operations, such as bitwise-and, on every pixel in an image or pair of images. They are useful for combining the results of the relational and morphological functions. All will work with images of any type or any mixture of types of any size and of any number of bands.

For binary operations, if the number of bands differs, one of the images must have one band. In this case, an n-band image is formed from the one-band image by joining n copies of the one-band image together and then the two n-band images are operated upon.

In the same way, for operations that take an array constant, such as im_andimage_vec(), you can mix single-element arrays or single-band images freely.

The output type is the same as the input type for integer types. Float and complex types are cast to signed int.

For binary operations on pairs of images, the images must match in size.

You might think im_andimage() would be called "im_and", but that causes problems when we try and make a C++ binding and drop the "im_" prefix.

Details

im_andimage ()

int                 im_andimage                         (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);

This operation calculates in1 & in2 and writes the result to out. The images must be the same size. They may have any format. They may differ in their number of bands, see above.

See also: im_orimage().

in1 :

input IMAGE 1

in2 :

input IMAGE 2

out :

output IMAGE

Returns :

0 on success, -1 on error

im_orimage ()

int                 im_orimage                          (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);

This operation calculates in1 | in2 and writes the result to out. The images must be the same size. They may have any format. They may differ in their number of bands, see above.

See also: im_eorimage().

in1 :

input IMAGE 1

in2 :

input IMAGE 2

out :

output IMAGE

Returns :

0 on success, -1 on error

im_eorimage ()

int                 im_eorimage                         (IMAGE *in1,
                                                         IMAGE *in2,
                                                         IMAGE *out);

This operation calculates in1 ^ in2 and writes the result to out. The images must be the same size. They may have any format. They may differ in their number of bands, see above.

See also: im_eorimage_vec(), im_andimage().

in1 :

input IMAGE 1

in2 :

input IMAGE 2

out :

output IMAGE

Returns :

0 on success, -1 on error

im_andimage_vec ()

int                 im_andimage_vec                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);

This operation calculates in & c (bitwise and of image pixels with array c) and writes the result to out.

See also: im_andimage(), im_orimage_vec().

in :

input IMAGE 1

out :

output IMAGE

n :

array length

c :

array of constants

Returns :

0 on success, -1 on error

im_andimageconst ()

int                 im_andimageconst                    (IMAGE *in,
                                                         IMAGE *out,
                                                         double c);

This operation calculates in & c (bitwise and of image pixels with constant c) and writes the result to out.

See also: im_andimage(), im_orimage_vec().

in :

input IMAGE 1

out :

output IMAGE

c :

constant

Returns :

0 on success, -1 on error

im_orimage_vec ()

int                 im_orimage_vec                      (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);

This operation calculates in | c (bitwise or of image pixels with array c) and writes the result to out.

See also: im_andimage(), im_orimageconst().

in :

input IMAGE 1

out :

output IMAGE

n :

array length

c :

array of constants

Returns :

0 on success, -1 on error

im_orimageconst ()

int                 im_orimageconst                     (IMAGE *in,
                                                         IMAGE *out,
                                                         double c);

This operation calculates in | c (bitwise or of image pixels with constant c) and writes the result to out.

See also: im_andimage(), im_orimage_vec().

in :

input IMAGE 1

out :

output IMAGE

c :

constant

Returns :

0 on success, -1 on error

im_eorimage_vec ()

int                 im_eorimage_vec                     (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);

This operation calculates in ^ c (bitwise exclusive-or of image pixels with array c) and writes the result to out.

See also: im_andimage(), im_orimageconst().

in :

input IMAGE 1

out :

output IMAGE

n :

array length

c :

array of constants

Returns :

0 on success, -1 on error

im_eorimageconst ()

int                 im_eorimageconst                    (IMAGE *in,
                                                         IMAGE *out,
                                                         double c);

This operation calculates in ^ c (bitwise exclusive-or of image pixels with constant c) and writes the result to out.

See also: im_andimage(), im_orimage_vec().

in :

input IMAGE 1

out :

output IMAGE

c :

constant

Returns :

0 on success, -1 on error

im_shiftleft_vec ()

int                 im_shiftleft_vec                    (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);

This operation calculates in << c (left-shift by c bits with array c) and writes the result to out.

See also: im_andimage(), im_orimageconst().

in :

input IMAGE

out :

output IMAGE

n :

array length

c :

array of constants

Returns :

0 on success, -1 on error

im_shiftleft ()

int                 im_shiftleft                        (IMAGE *in,
                                                         IMAGE *out,
                                                         int n);

This operation calculates in << n (left-shift by n bits) and writes the result to out.

See also: im_andimage(), im_orimageconst().

in :

input IMAGE

out :

output IMAGE

n :

constant

Returns :

0 on success, -1 on error

im_shiftright_vec ()

int                 im_shiftright_vec                   (IMAGE *in,
                                                         IMAGE *out,
                                                         int n,
                                                         double *c);

This operation calculates in << c (right-shift by c bits with array c) and writes the result to out.

See also: im_andimage(), im_orimageconst().

in :

input IMAGE

out :

output IMAGE

n :

array length

c :

array of constants

Returns :

0 on success, -1 on error

im_shiftright ()

int                 im_shiftright                       (IMAGE *in,
                                                         IMAGE *out,
                                                         int n);

This operation calculates in >> n (right-shift by n bits) and writes the result to out.

See also: im_andimage(), im_orimageconst().

in :

input IMAGE

out :

output IMAGE

n :

constant

Returns :

0 on success, -1 on error

See Also

arithmetic