Anonymous user
Percentage difference between images: Difference between revisions
Percentage difference between images (view source)
Revision as of 10:04, 28 December 2018
, 5 years ago→{{header|C#}}: GetPixel is an expensive call, optimized to minimize calls (Code is now 2.8x faster by BenchmarkDotNet test). Also optimized to remove repeated floating point rounding errors. .Net's Math.Abs is optimized, repeated calls can be left.
(→{{header|Perl}}: added an alternative solution using the Imager library) |
(→{{header|C#}}: GetPixel is an expensive call, optimized to minimize calls (Code is now 2.8x faster by BenchmarkDotNet test). Also optimized to remove repeated floating point rounding errors. .Net's Math.Abs is optimized, repeated calls can be left.) |
||
Line 337:
for (int x = 0; x < img1.Width; x++)
{
diff += (float)Math.Abs(img1.GetPixel(x, y).B - img2.GetPixel(x, y).B) / 255;▼
diff += Math.Abs(pixel1.R - pixel2.R);
diff += Math.Abs(pixel1.G - pixel2.G);
}
}
Console.WriteLine("diff: {0} %", 100 * (diff / 255) / (img1.Width * img1.Height * 3));
}
}</lang>
|