Percentage difference between images: Difference between revisions

Line 1,176:
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;
}</lang>
Take the bytes in each image, zip them together [lazily], sumssum the differences between each byte and normalizesnormalize.
<lang zkl>fcn readJPG2PPM(fileName){
p:=System.popen("convert \"%s\" ppm:-".fmt(fileName),"r");
Anonymous user