UNPKG

image-js

Version:

Image processing and manipulation in JavaScript

18 lines 704 B
import { sum } from '../../utils/geometry/points.js'; /** * Compare the intensity of two pixels of a GREY image. * @param image - Source image of the pixels. * @param p1 - First point. * @param p2 - Second point. * @param options - Options. * @returns Wether p1 is darker that p2. */ export function compareIntensity(image, p1, p2, options = {}) { const { origin = image.getCoordinates('center') } = options; const absoluteP1 = sum(p1, origin); const absoluteP2 = sum(p2, origin); const intensity1 = image.getValueByPoint(absoluteP1, 0); const intensity2 = image.getValueByPoint(absoluteP2, 0); return intensity1 < intensity2; } //# sourceMappingURL=compareIntensity.js.map