magickMeanShiftImage method

Future<bool> magickMeanShiftImage({
  1. required int width,
  2. required int height,
  3. required double colorDistance,
})

MagickMeanShiftImage() delineate arbitrarily shaped clusters in the image. For each pixel, it visits all the pixels in the neighborhood specified by the window centered at the pixel and excludes those that are outside the radius=(window-1)/2 surrounding the pixel. From those pixels, it finds those that are within the specified color distance from the current mean, and computes a new x,y centroid from those coordinates and a new mean. This new x,y centroid is used as the center for a new window. This process iterates until it converges and the final mean is replaces the (original window center) pixel value. It repeats this process for the next pixel, etc., until it processes all pixels in the image. Results are typically better with colorspaces other than sRGB. We recommend YIQ, YUV or YCbCr.

This method runs inside an isolate different from the main isolate.

  • width: the width of the neighborhood.
  • height: the height of the neighborhood.
  • colorDistance: the color distance.

Implementation

Future<bool> magickMeanShiftImage({
  required int width,
  required int height,
  required double colorDistance,
}) async =>
    await _magickCompute(
      _magickMeanShiftImage,
      _MagickMeanShiftImageParams(
        _wandPtr.address,
        width,
        height,
        colorDistance,
      ),
    );