use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.
the class ZeissZVIReader method initPOIService.
private void initPOIService() throws FormatException, IOException {
try {
ServiceFactory factory = new ServiceFactory();
poi = factory.getInstance(POIService.class);
} catch (DependencyException de) {
throw new FormatException("POI library not found", de);
}
poi.initialize(Location.getMappedId(getCurrentFile()));
}
use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.
the class GetPhysicalMetadata method main.
public static void main(String[] args) throws Exception {
// parse command line arguments
if (args.length < 1) {
System.err.println("Usage: java GetMetadata imageFile [seriesNo]");
System.exit(1);
}
String id = args[0];
int series = args.length > 1 ? Integer.parseInt(args[1]) : 0;
// create OME-XML metadata store
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();
// create format reader
IFormatReader reader = new ImageReader();
reader.setMetadataStore(meta);
// initialize file
System.out.println("Initializing " + id);
reader.setId(id);
int seriesCount = reader.getSeriesCount();
if (series < seriesCount)
reader.setSeries(series);
series = reader.getSeries();
System.out.println("\tImage series = " + series + " of " + seriesCount);
printPixelDimensions(reader);
printPhysicalDimensions(meta, series);
}
use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.
the class MinimumWriter method main.
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.out.println("Please specify an output file name.");
System.exit(1);
}
String id = args[0];
// create blank 512x512 image
System.out.println("Creating random image...");
int w = 512, h = 512, c = 1;
int pixelType = FormatTools.UINT16;
byte[] img = new byte[w * h * c * FormatTools.getBytesPerPixel(pixelType)];
// fill with random data
for (int i = 0; i < img.length; i++) img[i] = (byte) (256 * Math.random());
// create metadata object with minimum required metadata fields
System.out.println("Populating metadata...");
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();
MetadataTools.populateMetadata(meta, 0, null, false, "XYZCT", FormatTools.getPixelTypeString(pixelType), w, h, 1, c, 1, c);
// write image plane to disk
System.out.println("Writing image to '" + id + "'...");
IFormatWriter writer = new ImageWriter();
writer.setMetadataRetrieve(meta);
writer.setId(id);
writer.saveBytes(0, img);
writer.close();
System.out.println("Done.");
}
use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.
the class ParallelRead method run.
public void run() {
try {
ImageReader r = new ImageReader();
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();
r.setMetadataStore(meta);
r.setId(id);
System.out.println(Thread.currentThread().getName() + ": id=" + id + ", sizeX=" + r.getSizeX() + ", sizeY=" + r.getSizeY() + ", sizeZ=" + r.getSizeZ() + ", sizeT=" + r.getSizeT() + ", sizeC=" + r.getSizeC() + ", imageName=" + meta.getImageName(0));
r.close();
} catch (Exception exc) {
exc.printStackTrace();
}
}
use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.
the class PrintROIs method main.
public static void main(String[] args) throws Exception {
ImageReader reader = new ImageReader();
IMetadata omexml;
try {
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
omexml = service.createOMEXMLMetadata();
} catch (DependencyException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
} catch (ServiceException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
}
reader.setMetadataStore(omexml);
reader.setId(args[0]);
printAllROIs(omexml);
System.out.println();
for (int series = 0; series < reader.getSeriesCount(); series++) {
printSeriesROIs(omexml, series);
}
reader.close();
}
Aggregations