/** * Retrieves the bit width of a particular <code>PixelsType</code>. * * @param type * a pixel type. * @return width of a single pixel value in bits. */ public static int getBitDepth(String type) { int value = FormatTools.pixelTypeFromString(type); switch(value) { case FormatTools.INT8: case FormatTools.UINT8: return 8; case FormatTools.INT16: case FormatTools.UINT16: return 16; case FormatTools.INT32: case FormatTools.UINT32: case FormatTools.FLOAT: return 32; case FormatTools.DOUBLE: return 64; case FormatTools.BIT: return 1; } throw new RuntimeException("Pixels type '" + type + "' unsupported by nio."); }
/** * Retrieves the number of bytes per pixel in the current plane. * @param pixelType the pixel type, as a String. * @return the number of bytes per pixel. * @see #pixelTypeFromString(String) * @see #getBytesPerPixel(int) */ public static int getBytesPerPixel(String pixelType) { return getBytesPerPixel(pixelTypeFromString(pixelType)); }
/** * Returns the pixels type as a int. * * @param type The type. * @return See above. */ private static int getPixelType(PixelsType type) { if (type == null) return -1; return FormatTools.pixelTypeFromString(type.getValue()); }
/** * Returns the number of byte per pixel for the pixel data. * * @return See above. */ public int bytesPerPixel() { int type = FormatTools.pixelTypeFromString(pixelsType); return FormatTools.getBytesPerPixel(type); }
/** * Retrieves the number of bytes per pixel in the current plane. * @param pixelType the pixel type, as a String. * @return the number of bytes per pixel. * @see #pixelTypeFromString(String) * @see #getBytesPerPixel(int) */ public static int getBytesPerPixel(String pixelType) { return getBytesPerPixel(pixelTypeFromString(pixelType)); }
if (type == null) return minmax; String typeAsString = type.getValue(); int bfPixelsType = FormatTools.pixelTypeFromString(typeAsString);
@Override public int getPlaneCount() { MetadataRetrieve retrieve = getMetadataRetrieve(); int c = getSamplesPerPixel(); int type = FormatTools.pixelTypeFromString( retrieve.getPixelsType(series).toString()); int bytesPerPixel = FormatTools.getBytesPerPixel(type); if (bytesPerPixel > 1 && c != 1 && c != 3) { return super.getPlaneCount() * c; } return super.getPlaneCount(); }
private byte[] getTile(byte[] buf, Region tileParams, Region srcParams) { MetadataRetrieve retrieve = getMetadataRetrieve(); int type = FormatTools.pixelTypeFromString(retrieve.getPixelsType(series).toString()); int channel_count = getSamplesPerPixel(); int bytesPerPixel = FormatTools.getBytesPerPixel(type); int tileSize = tileParams.width * tileParams.height * bytesPerPixel * channel_count; byte [] returnBuf = new byte[tileSize]; for (int row = tileParams.y; row != tileParams.y + tileParams.height; row++) { for (int sampleoffset = 0; sampleoffset < (tileParams.width * channel_count); sampleoffset++) { int channel_index = sampleoffset / tileParams.width; int channel_offset = (sampleoffset - (tileParams.width * channel_index)) * bytesPerPixel; int full_row_width = srcParams.width * bytesPerPixel; int full_plane_size = full_row_width * srcParams.height; int xoffset = (tileParams.x - srcParams.x) * bytesPerPixel; int yoffset = (row - srcParams.y) * full_row_width; int row_offset = (row - tileParams.y) * tileParams.width * bytesPerPixel; int src_index = yoffset + xoffset + channel_offset + (channel_index * full_plane_size); int dest_index = (tileParams.height * tileParams.width * channel_index * bytesPerPixel) + row_offset; for (int pixelByte = 0; pixelByte < bytesPerPixel; pixelByte++) { returnBuf[dest_index + channel_offset + pixelByte] = buf[src_index + pixelByte]; } } } return returnBuf; }
private byte[] getTile(byte[] buf, Region tileParams, Region srcParams) { MetadataRetrieve retrieve = getMetadataRetrieve(); int type = FormatTools.pixelTypeFromString(retrieve.getPixelsType(series).toString()); int channel_count = getSamplesPerPixel(); int bytesPerPixel = FormatTools.getBytesPerPixel(type); int tileSize = tileParams.width * tileParams.height * bytesPerPixel * channel_count; byte [] returnBuf = new byte[tileSize]; for (int row = tileParams.y; row != tileParams.y + tileParams.height; row++) { for (int sampleoffset = 0; sampleoffset < (tileParams.width * channel_count); sampleoffset++) { int channel_index = sampleoffset / tileParams.width; int channel_offset = (sampleoffset - (tileParams.width * channel_index)) * bytesPerPixel; int full_row_width = srcParams.width * bytesPerPixel; int full_plane_size = full_row_width * srcParams.height; int xoffset = (tileParams.x - srcParams.x) * bytesPerPixel; int yoffset = (row - srcParams.y) * full_row_width; int row_offset = (row - tileParams.y) * tileParams.width * bytesPerPixel; int src_index = yoffset + xoffset + channel_offset + (channel_index * full_plane_size); int dest_index = (tileParams.height * tileParams.width * channel_index * bytesPerPixel) + row_offset; for (int pixelByte = 0; pixelByte < bytesPerPixel; pixelByte++) { returnBuf[dest_index + channel_offset + pixelByte] = buf[src_index + pixelByte]; } } } return returnBuf; }
@Override public int getPlaneCount() { MetadataRetrieve retrieve = getMetadataRetrieve(); int c = getSamplesPerPixel(); int type = FormatTools.pixelTypeFromString( retrieve.getPixelsType(series).toString()); int bytesPerPixel = FormatTools.getBytesPerPixel(type); if (bytesPerPixel > 1 && c != 1 && c != 3) { return super.getPlaneCount() * c; } return super.getPlaneCount(); }
/** * Seek to the given (x, y) coordinate of the image that starts at * the given offset. */ protected void seekToPlaneOffset(long baseOffset, int x, int y) throws IOException { out.seek(baseOffset); MetadataRetrieve r = getMetadataRetrieve(); int samples = getSamplesPerPixel(); int pixelType = FormatTools.pixelTypeFromString(r.getPixelsType(series).toString()); int bpp = FormatTools.getBytesPerPixel(pixelType); if (interleaved) bpp *= samples; try { int sizeX = getSizeX(); out.skipBytes(bpp * (y * sizeX + x)); } catch (FormatException e) { throw new IOException(e); } }
/** * Seek to the given (x, y) coordinate of the image that starts at * the given offset. */ protected void seekToPlaneOffset(long baseOffset, int x, int y) throws IOException { out.seek(baseOffset); MetadataRetrieve r = getMetadataRetrieve(); int samples = getSamplesPerPixel(); int pixelType = FormatTools.pixelTypeFromString(r.getPixelsType(series).toString()); int bpp = FormatTools.getBytesPerPixel(pixelType); if (interleaved) bpp *= samples; try { int sizeX = getSizeX(); out.skipBytes(bpp * (y * sizeX + x)); } catch (FormatException e) { throw new IOException(e); } }
MetadataRetrieve r = getMetadataRetrieve(); String type = r.getPixelsType(series).toString(); int pixelType = FormatTools.pixelTypeFromString(type); int bytes = FormatTools.getBytesPerPixel(pixelType);
MetadataRetrieve r = getMetadataRetrieve(); String type = r.getPixelsType(series).toString(); int pixelType = FormatTools.pixelTypeFromString(type); int bytes = FormatTools.getBytesPerPixel(pixelType);
int height = meta.getPixelsSizeY(series).getValue().intValue(); String pixelType = meta.getPixelsType(series).toString(); int type = FormatTools.pixelTypeFromString(pixelType); PositiveInteger nChannels = meta.getChannelSamplesPerPixel(series, 0); if (nChannels == null) {
int height = meta.getPixelsSizeY(series).getValue().intValue(); String pixelType = meta.getPixelsType(series).toString(); int type = FormatTools.pixelTypeFromString(pixelType); PositiveInteger nChannels = meta.getChannelSamplesPerPixel(series, 0); if (nChannels == null) {
FormatTools.pixelTypeFromString( retrieve.getPixelsType(series).toString())); int nChannels = getSamplesPerPixel();
@Test(groups = {"all", "fast", "automated"}) public void testPixelType() { if (config == null) throw new SkipException("No config tree"); String testName = "PixelType"; if (!initFile()) result(testName, false, "initFile"); for (int i=0; i<reader.getSeriesCount(); i++) { reader.setSeries(i); config.setSeries(i); if (reader.getPixelType() != FormatTools.pixelTypeFromString(config.getPixelType())) { result(testName, false, "Series " + i + " (expected " + config.getPixelType() + ", actual " + FormatTools.getPixelTypeString(reader.getPixelType()) + ")"); } } result(testName, true); }
int sizeC = retrieve.getPixelsSizeC(i).getValue(); int sizeT = retrieve.getPixelsSizeT(i).getValue(); int type = FormatTools.pixelTypeFromString( retrieve.getPixelsType(i).toString()); long bpp = FormatTools.getBytesPerPixel(type);
ms0.dimensionOrder = dorder; ms0.imageCount = planes; ms0.pixelType = FormatTools.pixelTypeFromString(ptype);