/** * 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); }
/** * 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); }
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(); }
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(); }
byte[] b = ImageTools.splitChannels(buf, i, nChannels, bytes, false, interleaved); byte[] encodedPix = compress(b);
byte[] b = ImageTools.splitChannels(buf, i, nChannels, bytes, false, interleaved); byte[] encodedPix = compress(b);
ImageTools.splitChannels(lastImage, strip, channel, c, bpp, false, isInterleaved(), strips == 1 ? w * h * bpp : strip.length); if (strips != 1) { ImageTools.splitChannels(lastImage, buf, channel, c, bpp, false, isInterleaved(), w * h * bpp);
for (int i=0; i<c; i++) { byte[] channel = ImageTools.splitChannels(b, i, c, bpp, false, interleave); Object pixels = DataTools.makeDataArray(channel, bpp, isFloat, isLittle); if (pixels instanceof byte[]) {
ImageTools.splitChannels(lastImage, strip, channel, c, bpp, false, isInterleaved(), strips == 1 ? w * h * bpp : strip.length); if (strips != 1) { ImageTools.splitChannels(lastImage, buf, channel, c, bpp, false, isInterleaved(), w * h * bpp);
@Override public byte[] openThumbBytes(int no) throws FormatException, IOException { FormatTools.assertId(getCurrentFile(), true, 2); int source = getOriginalIndex(no); byte[] thumb = reader.openThumbBytes(source); int c = getSizeC() / reader.getEffectiveSizeC(); int channel = no % c; int bpp = FormatTools.getBytesPerPixel(getPixelType()); return ImageTools.splitChannels(thumb, channel, c, bpp, false, reader.isInterleaved()); }
@Override public byte[] openThumbBytes(int no) throws FormatException, IOException { FormatTools.assertId(getCurrentFile(), true, 2); int source = getOriginalIndex(no); byte[] thumb = reader.openThumbBytes(source); int c = getSizeC() / reader.getEffectiveSizeC(); int channel = no % c; int bpp = FormatTools.getBytesPerPixel(getPixelType()); return ImageTools.splitChannels(thumb, channel, c, bpp, false, reader.isInterleaved()); }
for (int i=0; i<c; i++) { byte[] channel = ImageTools.splitChannels(b, i, c, bpp, false, interleave); Object pixels = DataTools.makeDataArray(channel, bpp, isFloat, isLittle); if (pixels instanceof byte[]) {
for (int i=0; i<c; i++) { byte[] channel = ImageTools.splitChannels(b, i, c, bpp, false, interleave); Object pixels = DataTools.makeDataArray(channel, bpp, isFloat, isLittle); if (pixels instanceof byte[]) {
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());
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());
/** * @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 (getSizeC() == 1) { return super.openBytes(no, buf, x, y, w, h); } byte[] b = delegate.openBytes(no / getSizeC(), x, y, w, h); int bpp = FormatTools.getBytesPerPixel(getPixelType()); int c = getZCTCoords(no)[1]; ImageTools.splitChannels( b, buf, c, getSizeC(), bpp, false, isInterleaved(), w * h * bpp); return buf; }
/** * @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 (getSizeC() == 1) { return super.openBytes(no, buf, x, y, w, h); } byte[] b = delegate.openBytes(no / getSizeC(), x, y, w, h); int bpp = FormatTools.getBytesPerPixel(getPixelType()); int c = getZCTCoords(no)[1]; ImageTools.splitChannels( b, buf, c, getSizeC(), bpp, false, isInterleaved(), w * h * bpp); return buf; }
pix = ImageTools.splitChannels(pix, lastChannel, getEffectiveSizeC(), bpp, false, true); pix = ImageTools.splitChannels(pix, lastChannel, getEffectiveSizeC(), bpp, false, true); System.arraycopy(pix, 0, buf, 0, pix.length);
prevRegion = region; ImageTools.splitChannels( prevBuf, buf, c, getSizeC(), bpp, false, false, w * h * bpp); prevChannel = c;
prevRegion = region; ImageTools.splitChannels( prevBuf, buf, c, getSizeC(), bpp, false, false, w * h * bpp); prevChannel = c;