loci.formats.IFormatReader Java Examples

The following examples show how to use loci.formats.IFormatReader. 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: Calibration.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
public Point[] getTileIndices(IFormatReader reader, int tileWidth, int tileHeight) {
    Rectangle region = new Rectangle(0, 0, reader.getSizeX()+1, reader.getSizeY() + 1);
    int minTileX = XToTileX(region.x,0,tileWidth);
    int maxTileX = XToTileX(region.x + region.width - 1,0,tileWidth);
    int minTileY = this.YToTileY(region.y,0,tileHeight);
    int maxTileY = this.YToTileY(region.y + region.height - 1,0,tileHeight);
    Point[] tileIndices = new Point[(maxTileY - minTileY + 1) * (maxTileX - minTileX + 1)];
    int tileIndexOffset = 0;

    for(int ty = minTileY; ty <= maxTileY; ++ty) {
        for(int tx = minTileX; tx <= maxTileX; ++tx) {
            tileIndices[tileIndexOffset++] = new Point(tx, ty);
        }
    }

    return tileIndices;
}
 
Example #2
Source File: OrbitImageBioformats.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
@Deprecated
private int getRealResolutionCount(IFormatReader imageReader) throws IOException, FormatException {
    ImageReader ir = new ImageReader();
    ir.setFlattenedResolutions(false);
    ir.setId(imageReader.getCurrentFile());
    ir.setSeries(imageReader.getSeries());
    int numRes = 1;
    for (int lev=imageReader.getResolutionCount()-1; lev>=0; lev--) {
        numRes = lev;
        ir.setResolution(lev);
        int thumbW = ir.getSizeX();
        int thumbH = ir.getSizeY();
        double diff = Math.abs((thumbW/(double)thumbH) - (imageReader.getSizeX()/(double)imageReader.getSizeY()));
        System.out.println("diff: "+diff);
        if (diff<0.001) break;
    }
    ir.close();
    return numRes;
}
 
Example #3
Source File: OrbitImageBioformats.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
private IFormatReader getIFormatReader(String filename, final OrbitModel orbitModel) {
    IFormatReader r;
    if (filename.toLowerCase().endsWith("ndpis")) {
        r = new NDPISReaderOrbit();
        if (orbitModel!=null) {
            // mIHC demuxing active?
            if (orbitModel.getFeatureDescription().isMihcActive()) {
                try {
                    BufferedImageReader bir = new BufferedImageReader(r);
                    bir.setId(filename);
                    double[] gains = NDPIUtils.getExposureTimesGain((NDPISReaderOrbit) r);
                    r.close();
                    MihcConfig mihcConfig = new MihcConfig(orbitModel.getFeatureDescription().getMihcMatrixChannelNames(),orbitModel.getFeatureDescription().getMihcMatrix(),orbitModel.getFeatureDescription().getMihcNormalGain());
                    r = new MultiplexImageReader(bir,mihcConfig,gains);
                    logger.info("multiplex reader used");
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }
        }
    } else if (filename.toLowerCase().endsWith("ndpi")) {
        // this check will become unnecessary when this bug is fixed: https://github.com/ome/bioformats/issues/3544
        // could then just use ImageReader() and allow it to auto-detect.
        r = new NDPIReader();
    } else {
        r = new ImageReader();
    }
    // r.setAllowOpenFiles(true);
    r.setFlattenedResolutions(false);
    return r;
}
 
Example #4
Source File: OrbitImageBioformats.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void close() throws IOException {
    synchronized (allReaders) {
        for (IFormatReader r: allReaders) {
            try {
                r.close();
            } catch (Exception e) {
            }
        }
    }
}
 
Example #5
Source File: OrbitImageBioformats.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public BufferedImage getThumbnail() {
  //  if (true) return new BufferedImage(100,60,BufferedImage.TYPE_INT_RGB);
     long thumbW=1;
     long thumbH=1;

    try {
        IFormatReader ir = getIFormatReader(reader.get().getCurrentFile(),null);
        ir.setId(reader.get().getCurrentFile());
        ir.setSeries(reader.get().getSeries());

        //int lev = numLevels-1;
        for (int lev=numLevels-1; lev>=0; lev--)
        {
            ir.setResolution(lev);
            thumbW = ir.getSizeX();
            thumbH = ir.getSizeY();
            double diff = Math.abs((thumbW/(double)thumbH) - (width/(double)height));
            logger.trace("thumb lev: "+lev+"  diff: "+diff+"  WxH: "+thumbW+"x"+thumbH);
            if (diff< THUMBNAIL_RATIO_DIFF) break; // 0.001
        }

        BufferedImageReader bir = BufferedImageReader.makeBufferedImageReader(ir);
        BufferedImage thumb = bir.openImage(0);
        bir.close();

        if (thumbW>maxThumbWidth) {
            int h = (int)(maxThumbWidth * (thumbH/(double)thumbW));
            BufferedImage img = new BufferedImage(maxThumbWidth,h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2d = (Graphics2D) img.getGraphics();
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
            g2d.drawImage(thumb,0,0,maxThumbWidth,h, null);
            thumb = img;
        }
        return thumb;
    } catch (IOException | FormatException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example #6
Source File: OrbitImageBioformats.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
@Deprecated
private int getIndex(IFormatReader r, int channel) {
    int[] nos = r.getZCTCoords(0);
    int z = nos[0], t = nos[2];
    return r.getIndex(z,channel,t);
}
 
Example #7
Source File: OrbitImageBioformats.java    From orbit-image-analysis with GNU General Public License v3.0 4 votes vote down vote up
private boolean doMergeChannels(IFormatReader r) {
  // return !r.isRGB();
   int c = r.getSizeC();
   return c > 1 && !r.isRGB();
}
 
Example #8
Source File: CommonFunctions.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
public static final double[] getPlanePosition( final IFormatReader r, final MetadataRetrieve retrieve, int series, int t )
{
	return getPlanePosition(r, retrieve, series, t, false, false, false);
}
 
Example #9
Source File: SlideBook6MetaData.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
private static void printMetaData( final IFormatReader r )
{
	printMetaData( r.getGlobalMetadata() );
}
 
Example #10
Source File: LightSheetZ1MetaData.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
public static void printMetaData( final IFormatReader r )
{
	printMetaData( r.getGlobalMetadata() );
}
 
Example #11
Source File: LegacyLightSheetZ1ImgLoader.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
public static IFormatReader instantiateImageReader()
{
	// should I use the ZeissCZIReader here directly?
	return new ChannelSeparator();// new ZeissCZIReader();
}
 
Example #12
Source File: LegacySlideBook6ImgLoader.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
public static IFormatReader instantiateImageReader()
{
	// should I use the ZeissCZIReader here directly?
	return new ChannelSeparator();// new ZeissCZIReader();
}
 
Example #13
Source File: SlideBook6MetaData.java    From SPIM_Registration with GNU General Public License v2.0 votes vote down vote up
public IFormatReader getReader() { return r; } 
Example #14
Source File: LightSheetZ1MetaData.java    From SPIM_Registration with GNU General Public License v2.0 votes vote down vote up
public IFormatReader getReader() { return r; }