function drawMask(imageData, ctx, width, height, x, y, threshold, color, alpha, blurRadius, doPaint) {
  const image = {
    data: imageData.data,
    width,
    height,
    bytes: 4, // RGBA
  };
  const existingMask = null;
  let mask = MagicWand.floodFill(image, x, y, threshold, existingMask);

  if (mask) mask = MagicWand.gaussBlurOnlyBorder(mask, blurRadius, existingMask);
  if (doPaint) paint(ctx, width, height, mask, color, alpha);

  return mask;
}
Given some image, apply a threshold to it anchored at the x and y location, and also
draw a results border around the thresholded mask.
@param {ImageData} imageData Raw image data to do the thresholding on.
@param {CanvasRenderingContext2D} ctx Image context on which to draw the results.
@param {int} width of the image.
@param {int} height of the image.
@param {int} x of start pixel
@param {int} y of start pixel.
@param {int} threshold Color range around anchor pixel to include within mask.
@param {string} color The color to draw the mask as, passed in as an RGB string.
@param {float} alpha Alpha opacity of the mask when drawn, 0. to 1.
@param {boolean} doPaint Whether to draw the mask once its calculated; not drawing
 it can save some performance time.
@param {int} blurRadius The degree of gaussian blur to apply to the contour.
@param {boolean} doPaint Whether to draw the mask once its calculated; not drawing
 it can save some performance time.
@returns The mask as {Uint8Array} data, {int} width, {int} height, {Object} bounds.