UNPKG

image-js

Version:

Image processing and manipulation in JavaScript

21 lines 838 B
import { Image } from '../../Image.js'; import { checkProcessable } from '../utils/checkProcessable.js'; /** * Returns a new image with the maximum values of each pixel from the stack. * @param stack - Stack to process. * @returns The maximum image. */ export function maxImage(stack) { checkProcessable(stack, { sameDimensions: true }); const newImage = Image.createFrom(stack.getImage(0)); const nbChannels = newImage.channels; for (let i = 0; i < stack.size; i++) { for (let j = 0; j < newImage.size; j++) { for (let channel = 0; channel < nbChannels; channel++) { newImage.setValueByIndex(j, channel, Math.max(newImage.getValueByIndex(j, channel), stack.getValueByIndex(i, j, channel))); } } } return newImage; } //# sourceMappingURL=maxImage.js.map