/** * Splits the given multi-channel array into a 2D array. * The "reverse" parameter is false if channels are in RGB order, true if * channels are in BGR order. */ public static byte[] splitChannels(byte[] array, int index, int c, int bytes, boolean reverse, boolean interleaved) { return splitChannels(array, null, index, c, bytes, reverse, interleaved, array.length / c); }
/** * Convert an arbitrary primitive type array with 3 samples per pixel to * an int array, i.e. RGB color with 8 bits per pixel. */ public static int[] make24Bits(Object pixels, int w, int h, boolean interleaved) { return make24Bits(pixels, w, h, interleaved, null, null); }
/** Perform autoscaling on the given BufferedImage. */ public static BufferedImage autoscale(BufferedImage img) { byte[][] pixels = getPixelBytes(img, true); double min = Double.MAX_VALUE; double max = 0.0; int bits = pixels[0].length / (img.getWidth() * img.getHeight()) * 8; for (int i=0; i<pixels.length; i++) { Double[] mm = ImageTools.scanData(pixels[0], bits, true); double tmin = mm[0].doubleValue(); double tmax = mm[1].doubleValue(); if (tmin < min) min = tmin; if (tmax > max) max = tmax; } return autoscale(img, (int) min, (int) max); }
planes = ImageTools.indexedToRGB(r.get8BitLookupTable(), plane); planes = new byte[r.getRGBChannelCount()][]; for (int c=0; c<planes.length; c++) { planes[c] = ImageTools.splitChannels(plane, c, r.getRGBChannelCount(), bpp, false, r.isInterleaved());
ImageTools.bgrToRgb(buf, isInterleaved(), bytes, getRGBChannelCount());
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); if (plane == null) { plane = new byte[FormatTools.getPlaneSize(this)]; ImageTools.interpolate( pix, plane, COLOR_MAP, getSizeX(), getSizeY(), isLittleEndian()); } try (RandomAccessInputStream s = new RandomAccessInputStream(plane)) { readPlane(s, x, y, w, h, buf); } return buf; }
byte[][] b = ImageTools.indexedToRGB(reader.get8BitLookupTable(), pix); if (isInterleaved()) { int pt = 0; short[][] s = ImageTools.indexedToRGB(reader.get16BitLookupTable(), pix, isLittleEndian());
byte[][] newBytes = new byte[b.length][width * height]; for (int i=0; i<b.length; i++) { newBytes[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); for (int i=0; i<b.length; i++) { newShorts[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); int[][] newInts = new int[b.length][width * height]; for (int i=0; i<b.length; i++) { newInts[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); for (int i=0; i<b.length; i++) { newFloats[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); for (int i=0; i<b.length; i++) { newDoubles[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height);
planes = ImageTools.indexedToRGB(r.get8BitLookupTable(), plane); planes = new byte[r.getRGBChannelCount()][]; for (int c=0; c<planes.length; c++) { planes[c] = ImageTools.splitChannels(plane, c, r.getRGBChannelCount(), bpp, false, r.isInterleaved());
ImageTools.bgrToRgb(buf, isInterleaved(), bytes, getRGBChannelCount());
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); if (plane == null) { plane = new byte[FormatTools.getPlaneSize(this)]; ImageTools.interpolate( pix, plane, COLOR_MAP, getSizeX(), getSizeY(), isLittleEndian()); } try (RandomAccessInputStream s = new RandomAccessInputStream(plane)) { readPlane(s, x, y, w, h, buf); } return buf; }
byte[][] b = ImageTools.indexedToRGB(reader.get8BitLookupTable(), pix); if (isInterleaved()) { int pt = 0; short[][] s = ImageTools.indexedToRGB(reader.get16BitLookupTable(), pix, isLittleEndian());
byte[][] newBytes = new byte[b.length][width * height]; for (int i=0; i<b.length; i++) { newBytes[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); for (int i=0; i<b.length; i++) { newShorts[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); int[][] newInts = new int[b.length][width * height]; for (int i=0; i<b.length; i++) { newInts[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); for (int i=0; i<b.length; i++) { newFloats[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height); for (int i=0; i<b.length; i++) { newDoubles[i] = ImageTools.padImage(b[i], false, 1, img.getWidth(), width, height);
/** * Splits the given multi-channel array into a 2D array. * The "reverse" parameter is false if channels are in RGB order, true if * channels are in BGR order. */ public static byte[] splitChannels(byte[] array, int index, int c, int bytes, boolean reverse, boolean interleaved) { return splitChannels(array, null, index, c, bytes, reverse, interleaved, array.length / c); }
/** * Convert an arbitrary primitive type array with 3 samples per pixel to * a 3 x (width * height) byte array. */ public static byte[][] make24Bits(Object pixels, int w, int h, boolean interleaved, boolean reverse) { return make24Bits(pixels, w, h, interleaved, reverse, null, null); }
ImageTools.bgrToRgb(buf, isInterleaved(), 2, getRGBChannelCount());
ImageTools.interpolate(pix, buf, colorMap, getSizeX(), getSizeY(), isLittleEndian());
/** Perform autoscaling on the given BufferedImage. */ public static BufferedImage autoscale(BufferedImage img) { byte[][] pixels = getPixelBytes(img, true); double min = Double.MAX_VALUE; double max = 0.0; int bits = pixels[0].length / (img.getWidth() * img.getHeight()) * 8; for (int i=0; i<pixels.length; i++) { Double[] mm = ImageTools.scanData(pixels[0], bits, true); double tmin = mm[0].doubleValue(); double tmax = mm[1].doubleValue(); if (tmin < min) min = tmin; if (tmax > max) max = tmax; } return autoscale(img, (int) min, (int) max); }
private void copyPixels(int x, int y, int w, int h, int bpp, int scanlinePad, byte[] pix, byte[] buf, boolean split) throws IOException { if (split) { pix = ImageTools.splitChannels(pix, lastChannel, getEffectiveSizeC(), bpp, false, true); } RandomAccessInputStream s = new RandomAccessInputStream(pix); readPlane(s, x, y, w, h, scanlinePad, buf); s.close(); }
/** * Convert an arbitrary primitive type array with 3 samples per pixel to * a 3 x (width * height) byte array. */ public static byte[][] make24Bits(Object pixels, int w, int h, boolean interleaved, boolean reverse) { return make24Bits(pixels, w, h, interleaved, reverse, null, null); }