docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a color change validation tool that determines whether visual changes between two images are perceptually significant to human observers.
When comparing images, raw pixel differences don't always reflect what humans actually perceive. For example, a subtle hue shift might have large RGB differences but be barely noticeable to the human eye, while a brightness change might have smaller RGB differences but be very obvious.
Your task is to build a validator that uses perceptual color difference algorithms to determine if changes between two images would be noticeable to human viewers.
The validator should accept:
The validator must use perceptual color difference detection that accounts for how humans actually perceive color changes, rather than raw RGB differences. This should be based on color space algorithms that model human vision.
The validator should return an object containing:
totalPixels: total number of pixels in the imagechangedPixels: number of pixels with perceptually noticeable differenceschangePercentage: percentage of changed pixels (0-100)isSignificant: boolean indicating if the change is significant (>1% of pixels changed)The sensitivity parameter should allow users to tune how strict the comparison is:
isSignificant: false @testisSignificant: true @test/**
* Validates whether color changes between two images are perceptually significant.
*
* @param {Uint8Array|Uint8ClampedArray} img1 - First image buffer in RGBA format
* @param {Uint8Array|Uint8ClampedArray} img2 - Second image buffer in RGBA format
* @param {number} width - Image width in pixels
* @param {number} height - Image height in pixels
* @param {Object} options - Configuration options
* @param {number} [options.sensitivity=0.1] - Sensitivity level (0-1, lower = more sensitive)
* @returns {Object} Validation result with totalPixels, changedPixels, changePercentage, and isSignificant
*/
function validateColorChanges(img1, img2, width, height, options = {}) {
// IMPLEMENTATION HERE
}
module.exports = { validateColorChanges };Provides perceptual color difference detection using YIQ color space algorithm for human-vision-accurate image comparison.