@Override public void wrap(ImageBase image) { if( this.sb == null ) { this.sb = FactoryGImageGray.wrap((ImageGray)image); } else { this.sb.wrap((ImageGray)image); } }
public static GImageMultiBand wrap( ImageGray image ) { return new GSingleToMB(FactoryGImageGray.wrap(image)); }
public static GImageGray wrap(ImageGray image , GImageGray output ) { if( output == null ) return wrap(image); if( image.getClass() == GrayU8.class ) ((GSingle_U8)output).image = (GrayU8)image; else if( image.getClass() == GrayS8.class ) ((GSingle_S8)output).image = (GrayS8)image; else if( image.getClass() == GrayU16.class ) ((GSingle_U16)output).image = (GrayU16)image; else if( image.getClass() == GrayS16.class ) ((GSingle_S16)output).image = (GrayS16)image; else if( image.getClass() == GrayS32.class ) ((GSingle_S32)output).image = (GrayS32)image; else if( image.getClass() == GrayS64.class ) ((GSingle_I64)output).image = (GrayS64)image; else if( image.getClass() == GrayF32.class ) ((GSingle_F32)output).image = (GrayF32)image; else if( image.getClass() == GrayF64.class ) ((GSingle_F64)output).image = (GrayF64)image; else throw new IllegalArgumentException("Unknown image type: "+image.getClass()); return output; }
public static void printDiff(ImageGray imgA, ImageGray imgB) { GImageGray a = FactoryGImageGray.wrap(imgA); GImageGray b = FactoryGImageGray.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(); } }
public static void checkBorderZero(ImageGray outputImage, int border) { GImageGray img = FactoryGImageGray.wrap(outputImage); for (int y = 0; y < img.getHeight(); y++) { if (y >= border && y < img.getHeight() - border) continue; for (int x = 0; x < img.getWidth(); x++) { if (x >= border && x < img.getWidth() - border) continue; if (img.get(x, y).intValue() != 0) throw new RuntimeException("The border is not zero: "+x+" "+y); } } }
public static void checkBorderZero(ImageGray outputImage, int borderX0 , int borderY0 , int borderX1 , int borderY1 ) { GImageGray img = FactoryGImageGray.wrap(outputImage); for (int y = 0; y < img.getHeight(); y++) { if (y >= borderY0 && y < img.getHeight() - borderY1) continue; for (int x = 0; x < img.getWidth(); x++) { if (x >= borderX0 && x < img.getWidth() - borderX1) continue; if (img.get(x, y).intValue() != 0) throw new RuntimeException("The border is not zero: "+x+" "+y); } } }
@Override public void wrap(ImageBase image) { if( this.image == null ) { this.image = (Planar) image; bandWrappers = new GImageGray[this.image.getNumBands()]; for (int i = 0; i < bandWrappers.length; i++) { bandWrappers[i] = FactoryGImageGray.wrap(this.image.getBand(i)); } } else { this.image = (Planar) image; for (int i = 0; i < bandWrappers.length; i++) { bandWrappers[i].wrap(this.image.getBand(i)); } } }
/** * Checks to see if only the image borders are equal to each other within tolerance */ public static void assertEqualsBorder(ImageGray imgA, ImageGray 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"); GImageGray a = FactoryGImageGray.wrap(imgA); GImageGray b = FactoryGImageGray.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); } } }