boolean revised

This commit is contained in:
John Cupitt 2009-09-17 16:03:25 +00:00
parent 4e2cb87524
commit f9fcb97fd4
3 changed files with 76 additions and 31 deletions

View File

@ -45,7 +45,7 @@
/**
* SECTION: arithmetic
* @short_description: operations which perform pixel arithmetic, trig, log, statistics
* @see_also: <link linkend="VIPS-iofuncs">iofuncs</link>
* @see_also: <link linkend="libvips-boolean">boolean</link>
* @stability: Stable
* @include: vips/vips.h
*
@ -60,15 +60,9 @@
* 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 a constant, such as
* im_remainderconst_vec(), the constant can either a vector with a single
* element (in which case the same constant is used for all image bands) or a
* vector with the same number of elements as there are bandsin the image (in
* which case one element is used for each band).
*
* im_lintra_vec() supports an additional mode where you can use a
* many-element vector with a single-band image to generate a multi-band
* image. No other operations support this yet.
* In the same way, for operations that take an array constant, such as
* im_remainderconst_vec(), you can mix single-element arrays or single-band
* images freely.
*
* Arithmetic operations try to preserve precision by increasing the number of
* bits in the output image when necessary. Generally, this follows the ANSI C

View File

@ -42,6 +42,35 @@
#include <dmalloc.h>
#endif /*WITH_DMALLOC*/
/**
* SECTION: boolean
* @short_description: boolean algebra on images, bitshifts
* @see_also: <link linkend="libvips-arithmetic">arithmetic</link>
* @stability: Stable
* @include: vips/vips.h
*
* These operations perform boolean operations, such as bitwise-and, on
* every pixel in an image or pair of images.
* All (except in a few cases noted below) 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.
*
* 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.
*/
/* Two images in, one out.
*/
static im_arg_desc two_in_one_out[] = {

View File

@ -1,24 +1,4 @@
/* @(#) Bitwise operations on VASARI images. Inputs must be some
* @(#) integer type and have the same size and number of bands. Use
* @(#) im_eorconst( in, out, -1 ) for im_not.
* @(#)
* @(#) int im_andimage( a, b, out ) int im_andconst( a, out, c )
* @(#) IMAGE *a, *b, *out; IMAGE *a, *out;
* @(#) unsigned char c;
* @(#)
* @(#) int im_orimage( a, b, out ) int im_orconst( a, out, c )
* @(#) IMAGE *a, *b, *out; IMAGE *a, *out;
* @(#) unsigned char c;
* @(#)
* @(#) int im_eorimage( a, b, out ) int im_eorconst( a, out, c )
* @(#) IMAGE *a, *b, *out; IMAGE *a, *out;
* @(#) unsigned char c;
* @(#)
* @(#) int im_shiftleft( in, out, n ) int im_shiftright( in, out, n )
* @(#) IMAGE *in, *out; IMAGE *in, *out;
* @(#) int n; int n;
* @(#)
* @(#) Returns either 0 (success) or -1 (fail).
/* boolean.c
*
* Modified:
* 15/12/94 JC
@ -153,6 +133,20 @@ NAME ## _buffer( PEL **p, PEL *q, int n, IMAGE *im ) \
BINARY_BUFFER( AND, & )
/**
* im_andimage:
* @in1: input #IMAGE 1
* @in2: input #IMAGE 2
* @out: output #IMAGE
*
* 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().
*
* Returns: 0 on success, -1 on error
*/
int
im_andimage( IMAGE *in1, IMAGE *in2, IMAGE *out )
{
@ -164,6 +158,20 @@ im_andimage( IMAGE *in1, IMAGE *in2, IMAGE *out )
BINARY_BUFFER( OR, | )
/**
* im_orimage:
* @in1: input #IMAGE 1
* @in2: input #IMAGE 2
* @out: output #IMAGE
*
* 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().
*
* Returns: 0 on success, -1 on error
*/
int
im_orimage( IMAGE *in1, IMAGE *in2, IMAGE *out )
{
@ -175,6 +183,20 @@ im_orimage( IMAGE *in1, IMAGE *in2, IMAGE *out )
BINARY_BUFFER( EOR, ^ )
/**
* im_eorimage:
* @in1: input #IMAGE 1
* @in2: input #IMAGE 2
* @out: output #IMAGE
*
* 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().
*
* Returns: 0 on success, -1 on error
*/
int
im_eorimage( IMAGE *in1, IMAGE *in2, IMAGE *out )
{