The original mask canvas
HTMLCanvasElement with smoothed mask
When canvas context creation fails
// 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);
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.