image-js
Version:
Image processing and manipulation in JavaScript
22 lines • 876 B
JavaScript
import { Image } from '../../Image.js';
import { checkProcessable } from '../utils/checkProcessable.js';
/**
* Returns a new image with the minimum values of each pixel from the stack.
* @param stack - Stack to process.
* @returns The minimum image.
*/
export function minImage(stack) {
checkProcessable(stack, { sameDimensions: true });
const newImage = Image.createFrom(stack.getImage(0));
newImage.fill(newImage.maxValue);
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.min(newImage.getValueByIndex(j, channel), stack.getValueByIndex(i, j, channel)));
}
}
}
return newImage;
}
//# sourceMappingURL=minImage.js.map