mirror of
https://github.com/lovell/sharp.git
synced 2026-02-04 13:46:19 +01:00
Expose erode and dilate operations #4243
This commit is contained in:
committed by
Lovell Fuller
parent
03e1b19764
commit
031c808aa5
@@ -472,4 +472,26 @@ namespace sharp {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dilate an image
|
||||
*/
|
||||
VImage Dilate(VImage image, int const width) {
|
||||
int const maskWidth = 2 * width + 1;
|
||||
VImage mask = VImage::new_matrix(maskWidth, maskWidth);
|
||||
return image.morph(
|
||||
mask,
|
||||
VIPS_OPERATION_MORPHOLOGY_DILATE).invert();
|
||||
}
|
||||
|
||||
/*
|
||||
* Erode an image
|
||||
*/
|
||||
VImage Erode(VImage image, int const width) {
|
||||
int const maskWidth = 2 * width + 1;
|
||||
VImage mask = VImage::new_matrix(maskWidth, maskWidth);
|
||||
return image.morph(
|
||||
mask,
|
||||
VIPS_OPERATION_MORPHOLOGY_ERODE).invert();
|
||||
}
|
||||
|
||||
} // namespace sharp
|
||||
|
||||
Reference in New Issue
Block a user