/** Checks to see if only the image borders are equal to each other within tolerance */ public static void assertEqualsBorder( ImageSingleBand imgA, ImageSingleBand imgB, double tol, int borderX, int borderY) { if (imgA.getWidth() != imgB.getWidth()) throw new RuntimeException("Widths are not equals"); if (imgA.getHeight() != imgB.getHeight()) throw new RuntimeException("Heights are not equals"); GImageSingleBand a = FactoryGImageSingleBand.wrap(imgA); GImageSingleBand b = FactoryGImageSingleBand.wrap(imgB); for (int y = 0; y < imgA.getHeight(); y++) { for (int x = 0; x < borderX; x++) { compareValues(tol, a, b, x, y); } for (int x = imgA.getWidth() - borderX; x < imgA.getWidth(); x++) { compareValues(tol, a, b, x, y); } } for (int x = borderX; x < imgA.getWidth() - borderX; x++) { for (int y = 0; y < borderY; y++) { compareValues(tol, a, b, x, y); } for (int y = imgA.getHeight() - borderY; y < imgA.getHeight(); y++) { compareValues(tol, a, b, x, y); } } }
@Override public void wrap(ImageSingleBand image) { interpolate.setImage((T) image); inputWidth = image.getWidth(); inputHeight = image.getHeight(); }
public static void printDiff(ImageSingleBand imgA, ImageSingleBand imgB) { GImageSingleBand a = FactoryGImageSingleBand.wrap(imgA); GImageSingleBand b = FactoryGImageSingleBand.wrap(imgB); System.out.println("------- Difference -----------"); for (int y = 0; y < imgA.getHeight(); y++) { for (int x = 0; x < imgA.getWidth(); x++) { double diff = Math.abs(a.get(x, y).doubleValue() - b.get(x, y).doubleValue()); System.out.printf("%2d ", (int) diff); } System.out.println(); } }
/** * Renders a gray scale image using color values from cold to hot. * * @param disparity Input disparity image * @param dst Where the image is rendered into. If null a new BufferedImage will be created and * return. * @param minDisparity Minimum disparity that can be computed * @param maxDisparity Maximum disparity that can be computed * @param invalidColor RGB value for invalid pixels. Try 0xFF << 8 for green * @return Rendered image. */ public static BufferedImage disparity( ImageSingleBand disparity, BufferedImage dst, int minDisparity, int maxDisparity, int invalidColor) { if (dst == null) dst = new BufferedImage( disparity.getWidth(), disparity.getHeight(), BufferedImage.TYPE_INT_RGB); if (disparity.getDataType().isInteger()) { return disparity((ImageInteger) disparity, dst, minDisparity, maxDisparity, invalidColor); } else if (disparity instanceof ImageFloat32) { return disparity((ImageFloat32) disparity, dst, minDisparity, maxDisparity, invalidColor); } else { throw new RuntimeException("Add support"); } }