Table of Contents

Name

im_generate, im_start_one, im_stop_one, im_allocate_input_array, im_start_many, im_stop_many - generate image pixels

Synopsis

#include <vips/vips.h>

void *im_start_one( out, in )
IMAGE *out, *in;

int im_stop_one( reg )
REGION *reg;

IMAGE **im_allocate_input_array( IMAGE *out, ... )

void *im_start_many( out, in )
IMAGE *out, **in;

int im_stop_many( REGION **out )
REGION **out;

int im_generate( im, start_fn, gen_fn, stop_fn, void *a, void *b )

IMAGE *im;
void *(*start_fn)();
int (*gen_fn)();
int (*stop_fn)();
void *a, void *b;

where, typically,

void *start_fn( im, a, b )
IMAGE *im;
void *a, *b;

int gen_fn( or, seq, a, b )
REGION *or;
void *seq;
void *a, *b;

int stop_fn( seq, a, b )
void *seq;
void *a, *b;

Description

im_generate(3) , with its supporting convenience functions, is used for PIO image output. See also im_wrapone(3) for an easy alternative to im_generate(3) for simple image processing operations.

im_start_one(3) and im_stop_one(3) are convenience functions, useful for simple one-image-in, one-image-out operations. im_start_one(3) assumes the first of the two user arguments (a, above) is the input image. It creates a REGION on this image and returns a pointer to the region as a sequence value.

im_stop_one(3) assumes the sequence value is a REGION pointer, and frees it.

im_allocate_input_array(3) takes as arguments the output image and a list of input images, terminated with a NULL. It allocates a NULL-terminated array to hold the images, and attaches a close callback to the output image to free that array. Example:

IMAGE *in, *in2, *in3, *in4;
IMAGE **arry;

if( !(arry = im_allocate_input_array( out,
in1, in2, in3, in4, NULL )) )
return( -1 );

builds the structure

IMAGE *arry[] = { in1, in2, in3, in4, NULL };

and makes sure it will be freed.

im_start_many(3) and im_stop_many(3) work exactly as im_start_one(3) and im_stop_one(3) , but with NULL-terminated arrays of IMAGEs and REGIONs. They are useful for many-images-in, one-image-out operations. im_start_many(3) assumes that the first of the two user arguments is a pointer to a NULL-terminates array of IMAGEs. It builds and returns as the sequence value a NULL-terminated array of REGIONs.

im_stop_many(3) assumes the sequence value is a pointer to a NULL-terminated array of REGIONs. It frees all the regions in turn. See im_add(3) for an example of this pair of functions in action.

im_generate(3) looks at the type of im and acts accordingly:

IM_PARTIAL: the start, process and stop functions are attached to the
region, and im_generate returns immediately. See im_prepare(3) .

IM_SETBUF: memory for the output image is created and sequences
started to ;vips/vips.h>

int im_avg(im, out)
IMAGE *im;
double *out;

int im_deviate(im, out)
IMAGE *im;
double *out;

int im_min(im, out)
IMAGE *im;
double *out;

int im_minpos(im, xpos, ypos, min)
IMAGE *im;
int *xpos, *ypos;
double *min;

int im_max(im, out)
IMAGE *im;
double *out;

int im_maxpos(im, xpos, ypos, max)
IMAGE *im;
int *xpos, *ypos;
double *max;

Description

These functions find the mean, standard deviation, minimum, maximum of an image. They operate on all bands of the input image. Use im_stats(3) if you need to calculate on bands separately. All computations are carried out in double precision arithmetic. The standard deviation is calculated using the formula:

Var{E} = 1 / (N - 1) * (E{X^2} - E{X}^2 / N)
stdev{E} = sqrt(Var{E}).

im_avg(3) finds the average of an image pointed by im. Takes as input any non-complex image format and returns a double at the location pointed by out.

im_deviate(3) finds the standard deviation of an image pointed by im. Takes as input any non-complex image format and returns a double at the location pointed by out.

im_min(3) finds the the minimum value of the image pointed by im and returns it at the location pointed by out. Takes as input any image format and returns a double at the location pointed by out. If input is complex the min square amplitude (re*re+im*im) is returned.

im_minpos(3) finds the the minimum value of the image pointed by im and returns it at the location pointed by out. The coordinates of the last occurrence of min is returned at locations pointed by xpos, ypos. If input is complex the min square amplitude (re*re+im*im) is returned.

im_max(3) finds the the maximum value of the image pointed by im and returns it at the location pointed by out. If input is complex the max square amplitude (re*re+im*im) is returned.

im_maxpos(3) finds the the maximum value of the image pointed by im and returns it at the location pointed by max. The coordinates of the last occurrence of max is returned at locations pointed by xpos, ypos. If input is complex the max square amplitude (re*re+im*im) and its last occurrence is returned.

Return Value

All functions return 0 on success and -1 on error.

See Also

im_exptra(3) , im_lintra(3) , im_abs(3) , im_stats(3) .

Copyright


N. Dessipris

Author

N. Dessipris - 24/04/1991
J. Cupitt - 21/7/93


Table of Contents