Method: Diffux::SnapshotComparisonImage::Base#pixel_diff_score
- Defined in:
- lib/diffux_core/snapshot_comparison_image/base.rb
#pixel_diff_score(pixel_after, pixel_before) ⇒ Float
Compute a score that represents the difference between 2 pixels
This method simply takes the Euclidean distance between the RGBA channels of 2 colors over the maximum possible Euclidean distance. This gives us a percentage of how different the two colors are.
Although it would be more perceptually accurate to calculate a proper Delta E in Lab colorspace, we probably don't need perceptual accuracy for this application, and it is nice to avoid the overhead of converting RGBA to Lab.
84 85 86 87 |
# File 'lib/diffux_core/snapshot_comparison_image/base.rb', line 84 def pixel_diff_score(pixel_after, pixel_before) ChunkyPNG::Color::euclidean_distance_rgba(pixel_after, pixel_before) / ChunkyPNG::Color::MAX_EUCLIDEAN_DISTANCE_RGBA end |