Search in sources :

Example 6 with BufferedImageReader

use of loci.formats.gui.BufferedImageReader in project bioformats by openmicroscopy.

the class SumPlanes method main.

public static void main(String[] args) throws Exception {
    String id = args[0];
    BufferedImageReader r = new BufferedImageReader();
    System.out.print("Reading " + id);
    r.setId(id);
    int imageCount = r.getImageCount();
    BufferedImage[] images = new BufferedImage[imageCount];
    for (int i = 0; i < imageCount; i++) {
        System.out.print(".");
        images[i] = r.openImage(i);
    }
    r.close();
    System.out.println(" [done]");
    String outId = id + ".tif";
    BufferedImageWriter w = new BufferedImageWriter();
    System.out.print("Writing " + outId);
    w.setId(outId);
    w.saveImage(0, sum(images));
    w.close();
    System.out.println(" [done]");
}
Also used : BufferedImageWriter(loci.formats.gui.BufferedImageWriter) BufferedImageReader(loci.formats.gui.BufferedImageReader)

Example 7 with BufferedImageReader

use of loci.formats.gui.BufferedImageReader in project digilib by robcast.

the class BioFormatsDocuImage method loadImage.

@Override
public void loadImage(ImageInput ii) throws FileOpException {
    logger.debug("loadImage: " + ii);
    this.input = ii;
    reader = new ImageReader();
    try {
        // construct the object that stores OME-XML metadata
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        meta = service.createOMEXMLMetadata();
        // set up the reader and associate it with the input file
        reader = new ImageReader();
        reader.setMetadataStore(meta);
        reader.setId(ii.getFile().getAbsolutePath());
        BufferedImageReader biReader = BufferedImageReader.makeBufferedImageReader(reader);
        img = biReader.openImage(0);
        logger.debug("image loaded: " + img);
    } catch (FormatException e) {
        throw new FileOpException("Unable to load image format: " + e);
    } catch (IOException e) {
        throw new FileOpException("Unable to load image file: " + e);
    } catch (ServiceException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DependencyException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ServiceException(loci.common.services.ServiceException) ServiceFactory(loci.common.services.ServiceFactory) FileOpException(digilib.io.FileOpException) BufferedImageReader(loci.formats.gui.BufferedImageReader) IOException(java.io.IOException) ImageReader(loci.formats.ImageReader) BufferedImageReader(loci.formats.gui.BufferedImageReader) DependencyException(loci.common.services.DependencyException) OMEXMLService(loci.formats.services.OMEXMLService) FormatException(loci.formats.FormatException)

Aggregations

BufferedImageReader (loci.formats.gui.BufferedImageReader)7 FileStitcher (loci.formats.FileStitcher)4 ServiceException (loci.common.services.ServiceException)3 ImageReader (loci.formats.ImageReader)3 File (java.io.File)2 DependencyException (loci.common.services.DependencyException)2 ServiceFactory (loci.common.services.ServiceFactory)2 FormatException (loci.formats.FormatException)2 IFormatReader (loci.formats.IFormatReader)2 Memoizer (loci.formats.Memoizer)2 OMEXMLService (loci.formats.services.OMEXMLService)2 SkipException (org.testng.SkipException)2 Test (org.testng.annotations.Test)2 FileOpException (digilib.io.FileOpException)1 GenericDialog (ij.gui.GenericDialog)1 Checkbox (java.awt.Checkbox)1 Dimension (java.awt.Dimension)1 Panel (java.awt.Panel)1 IOException (java.io.IOException)1 JPanel (javax.swing.JPanel)1