imgPixelmatch function
Compares two Image objects and calculates the number of differing pixels.
Parameters:
- img1: The first
Imageobject to compare. - img2: The second
Imageobject to compare. - options: A map of options to customize the comparison.
Returns a Future that completes with a tuple containing:
Implementation
Future<(double, Uint8List)> imgPixelmatch(Image img1, Image img2, Map<String, dynamic> options) async {
final rgba1 = await imgToRgba(img1);
final rgba2 = await imgToRgba(img2);
final diff = Uint8List(rgba1.length);
final numPix = pixelmatch(rgba1, rgba2, diff, img1.width, img1.height, options);
final ratio = numPix / (img1.width * img1.height);
return (ratio, diff);
}