SimilarityImageComparator extends ImageComparator<SimilarityComparisonParameters> { @Override protected List<Point> compare(BufferedImage image1, BufferedImage image2, int offsetX, int offsetY) { return null; } SimilarityImageComparator();   SimilarityImageComparator(SimilarityComparisonParameters parameters); @Override ImageComparedResult compare(BufferedImage img1, Rectangle img1Area, BufferedImage img2, Rectangle img2Area);  }
@Test public void testCompareLessThanParam() throws Exception { BufferedImage expectedImage = ImageIO.read(getClass().getResource("hifive_logo.png")); BufferedImage targetImage = ImageIO.read(getClass().getResource("hifive_logo_similar.png")); double pixleByPixelThreshold = 1.00; double featherMatrixThreshold = 0.98; double thresDiffThreshold = 0.98; double totalDiffThreshold = 0.97; SimilarityComparisonParameters param = new SimilarityComparisonParameters(pixleByPixelThreshold, featherMatrixThreshold, thresDiffThreshold, totalDiffThreshold); SimilarityImageComparator similarityImageComparator = new SimilarityImageComparator(param); ImageComparedResult result = similarityImageComparator.compare(expectedImage, targetImage); assertThat(result.isSucceeded(), is(false)); }
@Test public void testCompareEqualParam() throws Exception { BufferedImage expectedImage = ImageIO.read(getClass().getResource("hifive_logo.png")); BufferedImage targetImage = ImageIO.read(getClass().getResource("hifive_logo_similar.png")); double pixleByPixelThreshold = 0.99; double featherMatrixThreshold = 0.97; double thresDiffThreshold = 0.97; double totalDiffThreshold = 0.96; SimilarityComparisonParameters param = new SimilarityComparisonParameters(pixleByPixelThreshold, featherMatrixThreshold, thresDiffThreshold, totalDiffThreshold); SimilarityImageComparator similarityImageComparator = new SimilarityImageComparator(param); ImageComparedResult result = similarityImageComparator.compare(expectedImage, targetImage); assertThat(result.isSucceeded(), is(true)); }
@Test public void testCompareGreaterThanParam() throws Exception { BufferedImage expectedImage = ImageIO.read(getClass().getResource("hifive_logo.png")); BufferedImage targetImage = ImageIO.read(getClass().getResource("hifive_logo_similar.png")); double pixleByPixelThreshold = 0.98; double featherMatrixThreshold = 0.96; double thresDiffThreshold = 0.96; double totalDiffThreshold = 0.95; SimilarityComparisonParameters param = new SimilarityComparisonParameters(pixleByPixelThreshold, featherMatrixThreshold, thresDiffThreshold, totalDiffThreshold); SimilarityImageComparator similarityImageComparator = new SimilarityImageComparator(param); ImageComparedResult result = similarityImageComparator.compare(expectedImage, targetImage); assertThat(result.isSucceeded(), is(true)); }