How to resolve the algorithm Percentage difference between images step by step in the Frink programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Percentage difference between images step by step in the Frink programming language

Table of Contents

Problem Statement

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): The expected difference for these two images is 1.62125%

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Percentage difference between images step by step in the Frink programming language

Source code in the frink programming language

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")]

  

You may also check:How to resolve the algorithm Variadic function step by step in the Lasso programming language
You may also check:How to resolve the algorithm XML/Input step by step in the Tcl programming language
You may also check:How to resolve the algorithm Quad-power prime seeds step by step in the Arturo programming language
You may also check:How to resolve the algorithm Forward difference step by step in the Wren programming language
You may also check:How to resolve the algorithm Water collected between towers step by step in the Ruby programming language