ImageUtils { static List<Rectangle> convertDiffPointsToAreas(DiffPoints diffPoints) { if (diffPoints == null) { return new ArrayList<Rectangle>(); } List<Rectangle> areas = convertDiffPointsToAreas(diffPoints.getDiffPoints()); areas.addAll(convertSizeDiffPointsToAreas(diffPoints.getSizeDiffPoints())); return areas; } private  ImageUtils(); static ImageComparedResult compare(BufferedImage image1, Rectangle imageArea1, BufferedImage image2,
			Rectangle imageArea2, CompareOption[] options); static boolean isContained(BufferedImage entireImage, BufferedImage partImage); static double[][] calcIntegralImage(BufferedImage source); static boolean imageEquals(BufferedImage image1, BufferedImage image2); static BufferedImage getMaskedImage(BufferedImage image, List<Rectangle> maskAreas); static BufferedImage getMarkedImage(BufferedImage image, DiffPoints diffPoints); static BufferedImage getDiffImage(BufferedImage leftImage, BufferedImage rightImage, DiffPoints diffPoints); static BufferedImage trim(BufferedImage image, int trimTop, int trimLeft, int trimBottom, int trimRight); static BufferedImage verticalMerge(List<BufferedImage> images); static BufferedImage merge(List<List<BufferedImage>> images); static int[] getRGB(BufferedImage image, int width, int height); static int[] toARGB(int pixel); static int toPixel(int[] argb); static int toPixel(int r, int g, int b); static int toPixel(int a, int r, int g, int b); static int detectBackgroundColor(BufferedImage b); static boolean getObjectRectangle(BufferedImage image, Rectangle rectangle); static double norm(int pixel1, int pixel2); static double[] countSubpixel(BufferedImage bimage); static void removeRedundantRectangles(List<Rectangle> rectangles, int xLimit, int yLimit); static void removeOverlappingRectangles(List<Rectangle> rectangles); static void reshapeRect(Rectangle rectangle, int xLimit, int yLimit); static Rectangle getTightDiffArea(Rectangle rectangle, int xLimit, int yLimit); static List<Rectangle> convertObjectGroupsToAreas(List<ObjectGroup> objectGroups); static List<ObjectGroup> convertDiffPointsToObjectGroups(DiffPoints DP, int group_distance); static BufferedImage getSubImage(BufferedImage image, Rectangle rectangle); static Offset findDominantOffset(BufferedImage expectedImage, BufferedImage actualImage, double diffThreshold); static BufferedImage getDominantImage(BufferedImage expectedImage, BufferedImage actualImage, Offset offset); static int getSizeRelationType(int expectedWidth, int expectedHeight, int actualWidth, int actualHeight);  }
@Test public void testConvertDiffPointsToAreas() throws Exception { BufferedImage image1 = ImageIO .read(getClass().getResource("ImageUtilsTest_convert_diff_points_to_areas_expected.png")); Rectangle rectangle1 = new Rectangle(0, 0, image1.getWidth(), image1.getHeight()); BufferedImage image2 = ImageIO .read(getClass().getResource("ImageUtilsTest_convert_diff_points_to_areas_actual.png")); Rectangle rectangle2 = new Rectangle(0, 0, image2.getWidth(), image2.getHeight()); ImageComparedResult result = new DefaultImageComparator().compare(image1, rectangle1, image2, rectangle2); List<Point> points = ((DiffPoints) result).getDiffPoints(); DiffPoints diffPoints = new DiffPoints(points, new ArrayList<Point>()); int x = 1; int y = 0; int width = 3; int height = 2; int margin = DEFAULT_GROUP_DISTANCE / 2; List<Rectangle> expected = new ArrayList<Rectangle>(); expected.add(new Rectangle(x - margin, y - margin, 2 * margin + width, 2 * margin + height)); List<Rectangle> actual; actual = ImageUtils.convertDiffPointsToAreas(diffPoints); assertThat(actual, is(expected)); actual = ImageUtils.convertDiffPointsToAreas(points); assertThat(actual, is(expected)); }