morphOpen static method

Uint8List morphOpen(
  1. Uint8List gray,
  2. int width,
  3. int height, {
  4. int kernelSize = 3,
})

Morphological opening: erosion followed by dilation.

Removes small bright noise while preserving shape and size of larger objects. Equivalent to OpenCV's cv::morphologyEx(MORPH_OPEN).

Implementation

static Uint8List morphOpen(
  Uint8List gray,
  int width,
  int height, {
  int kernelSize = 3,
}) {
  final eroded = erode(gray, width, height, kernelSize: kernelSize);
  return dilate(eroded, width, height, kernelSize: kernelSize);
}