Table of Contents

## Name

im_extract, im_extract_band, im_etract_area - extract a portion of an image

## Synopsis

#include <vips/vips.h>

int im_extract(in, out, pbox)
IMAGE *in, *out;
IMAGE_BOX *pbox;

int im_extract_band(in, out, band)
IMAGE *in, *out;
int band;

int im_extract_area(in, out, x, y, w, h)
IMAGE *in, *out;
int x, y, w, h;

## Description

im_extract() extracts a portion of the image pointed by in and writes the result to out. pbox specifies the size and position of the area to be extracted and is defined as

/* Used to define a region of interest for
* im_extract() etc.
*/
typedef struct {
int xstart;
int ystart;
int xsize;
int ysize;
int chsel;
} IMAGE_BOX;

see <vips/vips.h>. if pbox->chsel is set to -1, all bands are extracted; otherwise pbox->chsel gives the band to extract, numbering from zero.The area specified by pbox must lie entirely within the image.

Works for any size image, any number of bands, any type. Works for LABPACK coded images too! But disallows band extraction in this case.

If used as part of a pipeline of partial image operations, im_extract() magically vanishes if chsel is -1. See the VIPS IO System Guide.

im_extract_band() is a convenience function which extracts a band from an image, leaving the size the same.

im_extract_area() is a convenience function which extracts an area from an image, leaving the bands the same.

## Return Value

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

## See Also

im_insert(3X) , im_lrjoin(3X) , im_lrmerge(3X) , im_stats(3X) , im_region_region(3X) .

## Copyright

J. Cupitt,

## Author

J. Cupitt - 11/04/1990

Table of Contents

- Name
- Synopsis
- Description
- Return Value
- See Also
- Copyright
- Author