UNPKG

image-js

Version:

Image processing and manipulation in JavaScript

41 lines 1.21 kB
import { Image } from '../Image.js'; import { getColorMap } from './utils/getColorMap.js'; export const RoisColorMode = { /** * Only two acceptable values: red or green. */ BINARY: 'binary', /** * Palette of reds and blues. */ SATURATION: 'saturation', /** * All possible hues (gradient of colors). */ RAINBOW: 'rainbow', }; /** * Generate an image with all the ROIs of various colors. * @param roiMapManager - The ROI map manager. * @param options - Color ROIs options. * @returns The colored image. */ export function colorRois(roiMapManager, options = {}) { const { roiKind = 'bw', mode = 'binary' } = options; const map = roiMapManager.getMap(); const image = new Image(map.width, map.height, { colorModel: 'RGBA', }); const colorMap = getColorMap({ roiKind, mode, nbNegative: map.nbNegative, nbPositive: map.nbPositive, }); const data32 = new Uint32Array(image.getRawImage().data.buffer); for (let index = 0; index < image.size; index++) { data32[index] = colorMap[map.data[index] + map.nbNegative]; } return image; } //# sourceMappingURL=colorRois.js.map