### Question:
ImageLoader extends BaseImageLoader { public void toBufferedImageRGB(INDArray arr, BufferedImage image) { if (arr.rank() < 3) throw new IllegalArgumentException("Arr must be 3d"); image = scalingIfNeed(image, arr.size(-2), arr.size(-1), image.getType(), true); for (int i = 0; i < image.getHeight(); i++) { for (int j = 0; j < image.getWidth(); j++) { int r = arr.slice(2).getInt(i, j); int g = arr.slice(1).getInt(i, j); int b = arr.slice(0).getInt(i, j); int a = 1; int col = (a << 24) | (r << 16) | (g << 8) | b; image.setRGB(j, i, col); } } } 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);  }### Answer:
@Test public void testToBufferedImageRGB() { BufferedImage img = makeRandomBufferedImage(false); int w = img.getWidth(); int h = img.getHeight(); int ch = 3; ImageLoader loader = new ImageLoader(0, 0, ch); INDArray arr = loader.toINDArrayBGR(img); BufferedImage img2 = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR); loader.toBufferedImageRGB(arr, img2); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { int srcColor = img.getRGB(j, i); int restoredColor = img2.getRGB(j, i); assertEquals(srcColor, restoredColor); } } }