Skip to content

Morphology Operators

Mathematical morphology operations.

erode

cpp
GpuImage erode(const GpuImage& input, int kernelSize);

Applies erosion (shrinks white regions).

dilate

cpp
GpuImage dilate(const GpuImage& input, int kernelSize);

Applies dilation (expands white regions).

morphologyOpen

cpp
GpuImage morphologyOpen(const GpuImage& input, int kernelSize);

Opening: erosion followed by dilation. Removes small bright spots.

morphologyClose

cpp
GpuImage morphologyClose(const GpuImage& input, int kernelSize);

Closing: dilation followed by erosion. Fills small dark holes.

morphologyGradient

cpp
GpuImage morphologyGradient(const GpuImage& input, int kernelSize);

Morphological gradient: difference between dilation and erosion.

Performance

Operation4K ImageSpeedup
Erode 5×51.5 ms25.0×
Dilate 5×51.5 ms25.0×
Open 5×53.0 ms25.0×

Back to API

Released under the MIT License.