---
name: "im_erode_raw"
section: "3"
platform: "linux"
package: "libvips-dev"
version: "7.20.7-1+b3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/im_dilate"
---

# im\_erode\_raw(3)

perform morphological operations on a white object against a black background

Part of [im\_dilate(3)](/im_dilate/3.md).

## NAME

im\_dilate, im\_dilate\_raw, im\_erode, im\_erode\_raw - perform morphological operations on a white object against a black background

## SYNOPSIS

**#include \<vips/vips.h\>**

**int im\_dilate(in, out, m)**\
 **IMAGE \*in, \*out;**\
 **INTMASK \*m;**

**int im\_erode(in, out, m)**\
 **IMAGE \*in, \*out;**\
 **INTMASK \*m;**

**int im\_dilate\_raw(in, out, m)**\
 **IMAGE \*in, \*out;**\
 **INTMASK \*m;**

**int im\_erode\_raw(in, out, m)**\
 **IMAGE \*in, \*out;**\
 **INTMASK \*m;**

## DESCRIPTION

The above functions are applications of morphological operations on one channel binary images ie. images with pixels that are either 0 (black) or 255 (white).  All functions assume that input images contain white objects against a black background.

Mask coefficients can be either 0 (for object) or 255 (for background) or 128 (for do not care).

The mask should have odd length sides and the origin of the mask is at location (m-\>xsize/2,m-\>ysize/2) integer division.  All algorithms have been based on the book "Fundamentals of Digital Image Processing" by A.  Jain, pp 384-388, Prentice-Hall, 1989.  Essentially,  **[im\_dilate(3)](/im_dilate/3.md)** sets pixels in the output if \*any\* part of the mask matches, whereas  **[im\_erode(3)](/im_erode/3.md)** sets pixels only if \*all\* of the mask matches.

**[im\_dilate(3)](/im_dilate/3.md)** dilates the image pointed by in, according to the mask pointed by m and writes the result in the location pointed by the IMAGE descriptor out. The output image is the same size as the input, in the manner of **[im\_conv(3)](/im_conv/3.md).**

**[im\_dilate\_raw(3)](/im_dilate_raw/3.md)** works as [im\_dilate(3)](/im_dilate/3.md), but does not expand the input.

**[im\_erode(3)](/im_erode/3.md)** erodes the image pointed by in, according to the mask pointed by m and writes the result in the location pointed by the IMAGE descriptor out. Again, the output image is forced to have the same size as the input.

**[im\_erode\_raw(3)](/im_erode_raw/3.md)** works as [im\_erode(3)](/im_erode/3.md), but does not expand the input.

See the boolean operations  **[im\_andimage(3)](/im_andimage/3.md),** **[im\_orimage(3)](/im_orimage/3.md)** and  **[im\_eorimage(3)](/im_eorimage/3.md)** for analogues of the usual set difference and set union operations.

## RETURN VALUE

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

## SEE ALSO

[im\_read\_imask(3)](/im_read_imask/3.md), [im\_conv(3)](/im_conv/3.md), [im\_andimage(3)](/im_andimage/3.md), im\_rotate\_imask(3).

## COPYRIGHT

1991-1995, Birkbeck College and the National Gallery
