@Test public void testScalingIfNeed() throws Exception { BufferedImage img1 = makeRandomBufferedImage(true); BufferedImage img2 = makeRandomBufferedImage(false); int w1 = 60, h1 = 110, ch1 = 6; ImageLoader loader1 = new ImageLoader(h1, w1, ch1); BufferedImage scaled1 = loader1.scalingIfNeed(img1, true); assertEquals(w1, scaled1.getWidth()); assertEquals(h1, scaled1.getHeight()); assertEquals(BufferedImage.TYPE_4BYTE_ABGR, scaled1.getType()); assertEquals(4, scaled1.getSampleModel().getNumBands()); BufferedImage scaled2 = loader1.scalingIfNeed(img1, false); assertEquals(w1, scaled2.getWidth()); assertEquals(h1, scaled2.getHeight()); assertEquals(BufferedImage.TYPE_3BYTE_BGR, scaled2.getType()); assertEquals(3, scaled2.getSampleModel().getNumBands()); BufferedImage scaled3 = loader1.scalingIfNeed(img2, true); assertEquals(w1, scaled3.getWidth()); assertEquals(h1, scaled3.getHeight()); assertEquals(BufferedImage.TYPE_3BYTE_BGR, scaled3.getType()); assertEquals(3, scaled3.getSampleModel().getNumBands()); BufferedImage scaled4 = loader1.scalingIfNeed(img2, false); assertEquals(w1, scaled4.getWidth()); assertEquals(h1, scaled4.getHeight()); assertEquals(BufferedImage.TYPE_3BYTE_BGR, scaled4.getType()); assertEquals(3, scaled4.getSampleModel().getNumBands()); int w2 = 70, h2 = 120, ch2 = 6; ImageLoader loader2 = new ImageLoader(h2, w2, ch2); BufferedImage scaled5 = loader2.scalingIfNeed(img1, true); assertEquals(w2, scaled5.getWidth()); assertEquals(h2, scaled5.getHeight(), h2); assertEquals(BufferedImage.TYPE_4BYTE_ABGR, scaled5.getType()); assertEquals(4, scaled5.getSampleModel().getNumBands()); BufferedImage scaled6 = loader2.scalingIfNeed(img1, false); assertEquals(w2, scaled6.getWidth()); assertEquals(h2, scaled6.getHeight()); assertEquals(BufferedImage.TYPE_3BYTE_BGR, scaled6.getType()); assertEquals(3, scaled6.getSampleModel().getNumBands()); }
protected BufferedImage scalingIfNeed(BufferedImage image, boolean needAlpha) { return scalingIfNeed(image, height, width, channels, needAlpha); }
ImageLoader extends BaseImageLoader { protected BufferedImage scalingIfNeed(BufferedImage image, boolean needAlpha) { return scalingIfNeed(image, height, width, channels, needAlpha); } }
ImageLoader extends BaseImageLoader { protected BufferedImage scalingIfNeed(BufferedImage image, boolean needAlpha) { return scalingIfNeed(image, height, width, channels, needAlpha); } ImageLoader();  ImageLoader(long height, long width);  ImageLoader(long height, long width, long channels);  ImageLoader(long height, long width, long channels, boolean centerCropIfNeeded); }
ImageLoader extends BaseImageLoader { protected BufferedImage scalingIfNeed(BufferedImage image, boolean needAlpha) { return scalingIfNeed(image, height, width, channels, needAlpha); } ImageLoader();  ImageLoader(long height, long width);  ImageLoader(long height, long width, long channels);  ImageLoader(long height, long width, long channels, boolean centerCropIfNeeded); INDArray asRowVector(File f); INDArray asRowVector(InputStream inputStream); INDArray asRowVector(BufferedImage image); INDArray toRaveledTensor(File file); INDArray toRaveledTensor(InputStream is); INDArray toRaveledTensor(BufferedImage image); INDArray toBgr(File file); INDArray toBgr(InputStream inputStream); INDArray toBgr(BufferedImage image); INDArray asMatrix(File f); @Override INDArray asMatrix(File f, boolean nchw); INDArray asMatrix(InputStream inputStream); @Override INDArray asMatrix(InputStream inputStream, boolean nchw); @Override org.datavec.image.data.Image asImageMatrix(File f); @Override org.datavec.image.data.Image asImageMatrix(File f, boolean nchw); @Override org.datavec.image.data.Image asImageMatrix(InputStream inputStream); @Override org.datavec.image.data.Image asImageMatrix(InputStream inputStream, boolean nchw); INDArray asMatrix(BufferedImage image); INDArray asImageMiniBatches(File f, int numMiniBatches, int numRowsPerSlice); int[] flattenedImageFromFile(File f); int[][] fromFile(File file); int[][][] fromFileMultipleChannels(File file); static BufferedImage toImage(INDArray matrix); void toBufferedImageRGB(INDArray arr, BufferedImage image); static BufferedImage toBufferedImage(Image img, int type); BufferedImage centerCropIfNeeded(BufferedImage img); }
ImageLoader extends BaseImageLoader { protected BufferedImage scalingIfNeed(BufferedImage image, boolean needAlpha) { return scalingIfNeed(image, height, width, channels, needAlpha); } ImageLoader();  ImageLoader(long height, long width);  ImageLoader(long height, long width, long channels);  ImageLoader(long height, long width, long channels, boolean centerCropIfNeeded); INDArray asRowVector(File f); INDArray asRowVector(InputStream inputStream); INDArray asRowVector(BufferedImage image); INDArray toRaveledTensor(File file); INDArray toRaveledTensor(InputStream is); INDArray toRaveledTensor(BufferedImage image); INDArray toBgr(File file); INDArray toBgr(InputStream inputStream); INDArray toBgr(BufferedImage image); INDArray asMatrix(File f); @Override INDArray asMatrix(File f, boolean nchw); INDArray asMatrix(InputStream inputStream); @Override INDArray asMatrix(InputStream inputStream, boolean nchw); @Override org.datavec.image.data.Image asImageMatrix(File f); @Override org.datavec.image.data.Image asImageMatrix(File f, boolean nchw); @Override org.datavec.image.data.Image asImageMatrix(InputStream inputStream); @Override org.datavec.image.data.Image asImageMatrix(InputStream inputStream, boolean nchw); INDArray asMatrix(BufferedImage image); INDArray asImageMiniBatches(File f, int numMiniBatches, int numRowsPerSlice); int[] flattenedImageFromFile(File f); int[][] fromFile(File file); int[][][] fromFileMultipleChannels(File file); static BufferedImage toImage(INDArray matrix); void toBufferedImageRGB(INDArray arr, BufferedImage image); static BufferedImage toBufferedImage(Image img, int type); BufferedImage centerCropIfNeeded(BufferedImage img);  }