Percentage difference between images: Difference between revisions
Content added Content deleted
(Added Python 3) |
(Realize in F#) |
||
Line 424: | Line 424: | ||
The result on the provided images is 1.6255930981604882%. |
The result on the provided images is 1.6255930981604882%. |
||
=={{header|F_Sharp|F#}}== |
|||
<lang fsharp> |
|||
//Percentage difference between 2 images. Nigel Galloway April 18th., 2018 |
|||
let img50 = new System.Drawing.Bitmap("Lenna50.jpg") |
|||
let n = Seq.init(img50.Height*img50.Width) (fun n->img50.GetPixel(n%img50.Width,n/img50.Width)) |
|||
let img100 = new System.Drawing.Bitmap("Lenna100.jpg") |
|||
let g = Seq.init(img100.Height*img100.Width) (fun n->img100.GetPixel(n%img100.Width,n/img100.Width)) |
|||
let diff=Seq.fold2 (fun i (e:System.Drawing.Color) (l:System.Drawing.Color)->i+abs(int(e.R)-int(l.R))+abs(int(e.B)-int(l.B))+abs(int(e.G)-int(l.G))) 0 n g |
|||
printfn "%f" ((float diff)*100.00/(float(img50.Height*img50.Width)*255.0*3.0)) |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
1.774691 |
|||
</pre> |
|||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
<lang forth>: pixel-diff ( pixel1 pixel2 -- n ) |
<lang forth>: pixel-diff ( pixel1 pixel2 -- n ) |