UNPKG

image-js

Version:

Image processing and manipulation in JavaScript

27 lines 1.02 kB
import { match } from 'ts-pattern'; import { computeRois } from './computeRois.js'; export const RoiKind = { BLACK: 'black', WHITE: 'white', BW: 'bw', }; /** * Return an array of ROIs matching the options. * @param roiMapManager - The ROI map manager containing the ROIs. * @param options - Get ROIs options. * @returns The array of ROIs. */ export function getRois(roiMapManager, options = {}) { const { minSurface = 0, maxSurface = Number.MAX_SAFE_INTEGER, kind = 'white', } = options; if (roiMapManager.blackRois.length === 0 && roiMapManager.whiteRois.length === 0) { computeRois(roiMapManager); } const rois = match(kind) .with('black', () => roiMapManager.blackRois) .with('white', () => roiMapManager.whiteRois) .with('bw', () => [...roiMapManager.whiteRois, ...roiMapManager.blackRois]) .exhaustive(); return rois.filter((roi) => roi.surface >= minSurface && roi.surface <= maxSurface); } //# sourceMappingURL=getRois.js.map