use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.
the class ImportProcess method getOMEXML.
/**
* Valid only after {@link ImportStep#READER}.
*/
public String getOMEXML() {
if (omeXML == null) {
// NB: Extract the OME-XML once, then keep it cached.
try {
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
omeXML = service.getOMEXML(getOMEMetadata());
} catch (DependencyException de) {
} catch (ServiceException se) {
}
}
return omeXML;
}
use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.
the class Memoizer method getService.
// Copied from OMETiffReader.
protected OMEXMLService getService() throws MissingLibraryException {
if (service == null) {
try {
ServiceFactory factory = new ServiceFactory();
service = factory.getInstance(OMEXMLService.class);
} catch (DependencyException de) {
throw new MissingLibraryException(OMEXMLServiceImpl.NO_OME_XML_MSG, de);
}
}
return service;
}
use of loci.formats.services.OMEXMLService 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.formats.services.OMEXMLService 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.formats.services.OMEXMLService 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();
}
}
Aggregations