Aus öffentlichen Paketdaten erstellte Orientierung.
Das image_compare-Paket ist ein Dart-Tool zur Bildvergleichsanalyse mit mehreren Algorithmen. Es ermöglicht Entwicklern, visuelle Unterschiede zwischen zwei Bildern zu bewerten und ist nützlich für die Überprüfung der Konsistenz der Benutzeroberfläche, die Validierung von Bildtransformationen oder die Erkennung von Änderungen in Bildschirmfotos. Das Paket unterstützt plattformübergreifende Nutzung unter Android, iOS, macOS, Windows und Linux und ist daher ideal für automatisierte Testworkflows. Es bietet eine einfache API, um Bildvergleichslogik in Flutter-Anwendungen zu integrieren.
Anwendungsfälle
Automatisierte UI-Tests
Visuelle Regressionsdetektion
Bildtransformation-Validierung
Bildschirmfoto-Vergleich
Qualitätssicherung bei der App-Entwicklung
Hauptmerkmale
Mehrere Vergleichsalgorithmen
Plattformübergreifende Kompatibilität
Einfache Integration mit Flutter
Unterstützung verschiedener Bildformate
Echtzeit-Differenzanalyse
Geeignet für
Test-Automatisierungsingenieure
UI/UX-Entwickler
Qualitätssicherungsteams
Flutter-App-Entwickler
Hinweise
Die Leistung kann bei großen Bildern variieren
Erfordert sorgfältige Einstellung der Schwellenwerte für Genauigkeit
Beschränkt auf Pixel-Ebene Vergleiche
Nicht für die Echtzeit-Videobearbeitung optimiert
Abhängig von der Bildformatunterstützung durch die zugrunde liegenden Bibliotheken
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
image_compare
Comparing images for difference
Simple, extensible dart package
What's New?
Handle transparency with the alpha channel option
Set ignoreAlpha to true to ignore alpha channel
Available for EuclideanColorDistance, PixelMatching, and the histogram algorithms
var a = Uri.parse('https://fujifilm-x.com/wp-content/uploads/2019/08/x-t30_sample-images03.jpg');
var b = Uri.parse('https://hs.sbcounty.gov/cn/Photo%20Gallery/Sample%20Picture%20-%20Koala.jpg');
File example:
var a = File('../images/tiger.jpg');
var b = File('../images/leopard.png');
Bytes example:
var a = [50, 183, 24, ...];
var b = [255, 230, 81, ...];
Image example:
var a = Image(100, 100);
var b = Image.from(a);
Any combination example:
var a = File('../images/tiger.jpg');
var b = Uri.parse('https://fujifilm-x.com/wp-content/uploads/2019/08/x-t30_sample-images03.jpg');
Select an algorithm (from classes section). The default is PixelMatching()
Compare the images:
var result = awaitcompareImages(src1: a, src2: b, algorithm: ChiSquareDistanceHistogram())
// or compare one image source to a list of othersvar results = awaitlistCompare(target: a, list: [a, b], algorithm: IMED(blurRatio: 0.1));
Algorithm Specifics:
Note:
All algorithms return percentage difference (0.0 - no difference, 1.0 - 100% difference), but their meanings are different
PixelMatching({double tolerance = 0.05})
About
Images are resized to the same dimensions (if dimensions don't match) and each [src1] pixel's RGB value is checked to see if it falls within 5% (of 256) of [src2] pixel's RGB value.
Best with images of similar aspect ratios and dimensions
Compare for exactness (if two images are identical)
Result
Percentage of pixels that do not have overlapping RGB values between the images
EuclideanColorDistance()
About
Images are resized to the same dimensions (if dimensions don't match) and euclidean difference between [src1] RGB values and [src2] RGB values for each pixel is summed.
Best with images of similar aspect ratios and dimensions
Compare for exactness (if two images are identical)
Result
Sum of euclidean distances between each pixel (RGB value), bounded by the maximum distance possible given two images.
Images are resized to the same dimensions (if dimensions don't match) and are grayscaled. A gaussian blur is applied when calculating distance between pixel intensities. Spatial relationship is taken into account within the gaussian function to reduce the effect of minor perturbations (ignores minor differences).
Gaussian blur has been modified: area decreased (Note)
Best with images of similar aspect ratios and dimensions
Does not handle transparent pixels
Compare for ~exactness (if two images are roughly identical)
Result
Sum of image euclidean distances between each pixel (RGB value), bounded by the maximum distance possible given two images.
ChiSquareDistanceHistogram()
About
Images are converted to histogram representations (x-axis intensity, y-axis frequency). The chi-square distance formula is applied to compute the distance between each of the 256 bins. There are four histograms per image (RGBA histograms).
Works with images of all aspect ratios and dimensions
Compare for similarity (if two images are similar based on their color distribution)
Result
Chi square distance between the normalized color distributions of two images
IntersectionHistogram()
About
Images are converted to histogram representations (x-axis intensity, y-axis frequency). Histograms are overlaid to calculate percentage overlap. There are four histograms per image (RGBA histograms).
Works with images of all aspect ratios and dimensions
Compare for similarity (if two images are similar based on their color distribution)
Result
Differences between the normalized color distributions of two images
Images are grayscaled and resized to 32x32. Then they are passed through a 1-dimension discrete cosine transformation.
The top 8x8 is only accounted for since it gives the generalized frequency of the image. With this, a hash is created.
This algorithm works great for images as described by phash.org "copyright protection, similarity search for media files, or even digital forensics". From our testing we also found it works great with pictures that have subjects inside and minimal white space.
Does not handle transparent pixels
Compare for exactness (if two images are identical)
Result
Structural differences between two hashed, grayscaled images, more precise than average and median hash