UNPKG

image-js

Version:

Image processing and manipulation in JavaScript

27 lines 1.03 kB
import { hsvToRgb } from '../hsvToRgb.js'; import { rgbToNumber } from '../rgbToNumber.js'; /** * Return a map where ROIs are red (negative) or green (positive) depending on the ROI index. * @param options - Color maps options. * @returns The colored map. */ export function getBinaryMap(options) { const { nbNegative, nbPositive, whiteHue = 120, blackHue = 0, roiKind = 'bw', } = options; const colorMap = new Uint32Array(nbNegative + nbPositive + 1); // negative values if (roiKind === 'bw' || roiKind === 'black') { for (let i = -nbNegative; i < 0; i++) { const hsv = [blackHue, 255, 255]; colorMap[i + nbNegative] = rgbToNumber(hsvToRgb(hsv)); } } if (roiKind === 'bw' || roiKind === 'white') { // positive values for (let i = 1; i <= nbPositive; i++) { const hsv = [whiteHue, 255, 255]; colorMap[i + nbNegative] = rgbToNumber(hsvToRgb(hsv)); } } return colorMap; } //# sourceMappingURL=getBinaryMap.js.map