basic bitmap storage
Useful for comparing two JPEG images saved with a different compression ratios.

You can use these pictures for testing (use the full-size version of each):



50% quality JPEG

100% quality JPEG







link to full size 50% image

link to full size 100% image

The expected difference for these two images is 1.62125%

 
img1 = new image["file:Lenna50.jpg"]
img2 = new image["file:Lenna100.jpg"]
 
[w1, h1] = img1.getSize[]
[w2, h2] = img2.getSize[]
 
sum = 0
for x=0 to w1-1
   for y=0 to h1-1
   {
      [r1,g1,b1] = img1.getPixel[x,y]
      [r2,g2,b2] = img2.getPixel[x,y]
      sum = sum + abs[r1-r2] + abs[g1-g2] + abs[b1-b2]
   }
 
errors = sum / (w1 * h1 * 3)
println["Error is " + (errors->"percent")]
 