Jump to content

Percentage difference between images: Difference between revisions

m
No edit summary
m (→‎{{header|zkl}}: verbiage)
Line 1,218:
throw(Exception.ValueError("width/height of the images must match!"));
Utils.Helpers.zipW(img1.data.howza(0),img2.data.howza(0)) // bytes, not strings
.reduce(fcn(totalDiff,[(a,b)]){ totalDiff += (a - b).abs() },0)
.toFloat()/img1.w/img1.h/3/255; // or: .toFloat()/img1.data.len()/255
}</lang>
Take the bytes in each image, zip them together [lazily], sum the differences between each byte and normalize.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.