image-js
Version:
Image processing and manipulation in JavaScript
19 lines • 780 B
JavaScript
import { borderIterator } from '../utils/borderIterator.js';
import { multipleFloodFill } from './multipleFloodFill.js';
/**
* Set the pixels connected to the border of the mask to zero. You can chose to allow corner connection of not with the `allowCorners` option.
* @param mask - The mask to process.
* @param options - Clear border options.
* @returns The image with cleared borders.
*/
export function clearBorder(mask, options = {}) {
const { allowCorners = false, out, color = 'white' } = options;
return multipleFloodFill(mask, {
startPixels: borderIterator(mask),
startPixelValue: color === 'white' ? 1 : 0,
newPixelValue: color === 'white' ? 0 : 1,
allowCorners,
out,
});
}
//# sourceMappingURL=clearBorder.js.map