• Apply simple post-processing to smooth mask edges.

    Applies a 2px blur filter to the mask to create smoother edges. This helps reduce jagged edges in the final cutout.

    Parameters

    • maskCanvas: HTMLCanvasElement

      The original mask canvas

    Returns HTMLCanvasElement

    HTMLCanvasElement with smoothed mask

    Throws

    When canvas context creation fails

    Example

    // Generate raw mask from model
    const rawMask = processModelOutput(outputData, originalSize);

    // Apply smoothing
    const smoothMask = postProcessMask(rawMask);

    // Use smoothed mask for better cutout
    const cutout = naiveCutout(originalCanvas, smoothMask);