Class ImageComparison


  • public class ImageComparison
    extends java.lang.Object
    Main class for comparison images.
    • Constructor Detail

      • ImageComparison

        public ImageComparison​(java.lang.String expected,
                               java.lang.String actual)
        Create a new instance of ImageComparison that can compare the given images.
        Parameters:
        expected - expected image to be compared
        actual - actual image to be compared
      • ImageComparison

        public ImageComparison​(java.awt.image.BufferedImage expected,
                               java.awt.image.BufferedImage actual,
                               java.io.File destination)
        Create a new instance of ImageComparison that can compare the given images.
        Parameters:
        expected - expected image to be compared
        actual - actual image to be compared
        destination - destination to save the result. If null, the result is shown in the UI.
      • ImageComparison

        public ImageComparison​(java.awt.image.BufferedImage expected,
                               java.awt.image.BufferedImage actual)
        Create a new instance of ImageComparison that can compare the given images.
        Parameters:
        expected - expected image to be compared
        actual - actual image to be compared
    • Method Detail

      • compareImages

        public ImageComparisonResult compareImages()
        Draw rectangles which cover the regions of the difference pixels.
        Returns:
        the result of the drawing.
      • createMask

        public java.util.List<Rectangle> createMask()
        Returns the list of rectangles that would be drawn as a diff image. If you submit two images that are the same barring the parts you want to excludedAreas you get a list of rectangles that can be used as said excludedAreas
        Returns:
        List of Rectangle
      • getPixelToleranceLevel

        public double getPixelToleranceLevel()
      • setPixelToleranceLevel

        public ImageComparison setPixelToleranceLevel​(double pixelToleranceLevel)
      • isDrawExcludedRectangles

        public boolean isDrawExcludedRectangles()
      • setDrawExcludedRectangles

        public ImageComparison setDrawExcludedRectangles​(boolean drawExcludedRectangles)
      • getThreshold

        public int getThreshold()
      • getDestination

        public java.util.Optional<java.io.File> getDestination()
      • setDestination

        public ImageComparison setDestination​(java.io.File destination)
      • getExpected

        public java.awt.image.BufferedImage getExpected()
      • getActual

        public java.awt.image.BufferedImage getActual()
      • getRectangleLineWidth

        public int getRectangleLineWidth()
      • setRectangleLineWidth

        public ImageComparison setRectangleLineWidth​(int rectangleLineWidth)
      • getMinimalRectangleSize

        public java.lang.Integer getMinimalRectangleSize()
      • setMinimalRectangleSize

        public ImageComparison setMinimalRectangleSize​(java.lang.Integer minimalRectangleSize)
      • getMaximalRectangleCount

        public java.lang.Integer getMaximalRectangleCount()
      • setMaximalRectangleCount

        public ImageComparison setMaximalRectangleCount​(java.lang.Integer maximalRectangleCount)
      • isFillDifferenceRectangles

        public boolean isFillDifferenceRectangles()
      • getPercentOpacityDifferenceRectangles

        public double getPercentOpacityDifferenceRectangles()
      • setDifferenceRectangleFilling

        public ImageComparison setDifferenceRectangleFilling​(boolean fillRectangles,
                                                             double percentOpacity)
      • isFillExcludedRectangles

        public boolean isFillExcludedRectangles()
      • getPercentOpacityExcludedRectangles

        public double getPercentOpacityExcludedRectangles()
      • setExcludedRectangleFilling

        public ImageComparison setExcludedRectangleFilling​(boolean fillRectangles,
                                                           double percentOpacity)
      • getAllowingPercentOfDifferentPixels

        public double getAllowingPercentOfDifferentPixels()
      • setAllowingPercentOfDifferentPixels

        public ImageComparison setAllowingPercentOfDifferentPixels​(double allowingPercentOfDifferentPixels)
      • getDifferenceRectangleColor

        public java.awt.Color getDifferenceRectangleColor()
      • setDifferenceRectangleColor

        public ImageComparison setDifferenceRectangleColor​(java.awt.Color differenceRectangleColor)
      • getExcludedRectangleColor

        public java.awt.Color getExcludedRectangleColor()
      • setExcludedRectangleColor

        public ImageComparison setExcludedRectangleColor​(java.awt.Color excludedRectangleColor)