Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

ImagesComparator



The ImagesComparator class allows to compare two images.

The comparator uses a ImagesComparator.Params parameters to configure the comparison. The result is a ImagesComparator.Result.
imagescomparator

Configuration

The ImagesComparator.Params class has the following properties:
By default the images are checked for strict equality:

sizeType

The ImagesComparator.Params.sizeType specifies how images of not identical sizes should be treated: For example, with the two following images:
imagescompsize

Examples

To compare two image files to check for strict equality:
   URL fileA = ...
   URL fileB = ...      
   ImagesComparator comparator = new ImagesComparator();
   ImagesComparator.Result result = comparator.compareImages(fileA, fileB);
   boolean isEqual = result.isEquals(); // true if the two images are strictly equal
To compare two image files to check that no more than 50 pixels are different:
   URL fileA = ...
   URL fileB = ...            
   ImagesComparator comparator = new ImagesComparator();
   ImagesComparator.Params params = comparator.getParams();
   params.deltaPixels = 50;
   ImagesComparator.Result result = comparator.compareImages(fileA, fileB);
   boolean isEqual = result.isEquals(); // true if no more than 50 pixels are different

See also


Categories: Awt.image | Packages

Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences