loci.formats.FormatTools Java Examples
The following examples show how to use
loci.formats.FormatTools.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageFileHeader.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
/** Reads the header of the image file at {@code filepath} * using an {@link IFormatReader} from the bio-formats library, * and then extracts the {link #width}, {@link #height} and {@link #type} * of the image. If the type is not one supported by TrakEM2, the {@link #type} * is set to the value returned by {@link IFormatReader#getPixelType()}. * * @param filepath * @throws Exception */ public ImageFileHeader(final String filepath) throws Exception { fr = new ChannelSeparator(); fr.setGroupFiles(false); try { fr.setId(filepath); width = fr.getSizeX(); height = fr.getSizeY(); if (fr.isRGB()) { type = ImagePlus.COLOR_RGB; } else { switch (fr.getPixelType()) { case FormatTools.INT8: case FormatTools.UINT8: if (fr.isIndexed() || fr.isFalseColor()) { type = ImagePlus.COLOR_256; } else { type = ImagePlus.GRAY8; } break; case FormatTools.INT16: case FormatTools.UINT16: type = ImagePlus.GRAY16; break; case FormatTools.FLOAT: type = ImagePlus.GRAY32; break; default: type = fr.getPixelType(); break; } } } finally { fr.close(); } }