Method

VipsImagefind_trim

Declaration [src]

int
vips_find_trim (
  VipsImage* in,
  int* left,
  int* top,
  int* width,
  int* height,
  ...
)

Description [src]

Optional arguments:

  • threshold: %gdouble, background / object threshold
  • background: VipsArrayDouble, background colour

Search in for the bounding box of the non-background area.

Any alpha is flattened out, then the image is median-filtered, all the row and column sums of the absolute difference from background are calculated in a single pass, then the first row or column in each of the four directions where the sum is greater than threshold gives the bounding box.

If the image is entirely background, vips_find_trim() returns width == 0 and height == 0.

background defaults to 255, or 65535 for 16-bit images. Set another value, or use vips_getpoint() to pick a value from an edge. You’ll need to flatten before vips_getpoint() to get a correct background value.

threshold defaults to 10.

The image needs to be at least 3x3 pixels in size.

See also: vips_getpoint(), vips_extract_area(), vips_smartcrop().

This method is not directly available to language bindings.

Parameters

left int*
 

Output left edge.

 The argument will be set by the function.
top int*
 

Output top edge.

 The argument will be set by the function.
width int*
 

Output width.

 The argument will be set by the function.
height int*
 

Output height.

 The argument will be set by the function.
...
 

NULL-terminated list of optional named arguments.

Return value

Returns: int
 

0 on success, -1 on error.