use of loci.formats.ImageReader 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();
}
use of loci.formats.ImageReader in project bioformats by openmicroscopy.
the class DumpOMEXML method dumpOMEXML.
public static void dumpOMEXML(String path) throws FormatException, IOException, DependencyException, ServiceException {
ServiceFactory serviceFactory = new ServiceFactory();
OMEXMLService omexmlService = serviceFactory.getInstance(OMEXMLService.class);
IMetadata meta = omexmlService.createOMEXMLMetadata();
ImageReader r = new ImageReader();
r.setMetadataStore(meta);
r.setOriginalMetadataPopulated(true);
r.setId(path);
r.close();
String xml = omexmlService.getOMEXML(meta);
System.out.println(xml);
}
use of loci.formats.ImageReader in project bioformats by openmicroscopy.
the class EditImageName method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.out.println("Usage: java EditImageName file");
return;
}
ImageReader reader = new ImageReader();
// record metadata to OME-XML format
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata omexmlMeta = service.createOMEXMLMetadata();
reader.setMetadataStore(omexmlMeta);
String id = args[0];
System.out.print("Reading metadata ");
reader.setId(id);
System.out.println(" [done]");
// get image name
String name = omexmlMeta.getImageName(0);
System.out.println("Initial Image name = " + name);
// change image name (reverse it)
char[] arr = name.toCharArray();
for (int i = 0; i < arr.length / 2; i++) {
int i2 = arr.length - i - 1;
char c = arr[i];
char c2 = arr[i2];
arr[i] = c2;
arr[i2] = c;
}
name = new String(arr);
// save altered name back to OME-XML structure
omexmlMeta.setImageName(name, 0);
System.out.println("Updated Image name = " + name);
// output full OME-XML block
System.out.println("Full OME-XML dump:");
String xml = service.getOMEXML(omexmlMeta);
System.out.println(xml);
}
use of loci.formats.ImageReader in project bioformats by openmicroscopy.
the class LosslessJPEG2000Test method testEquivalentPixels8Bit.
@Test
public void testEquivalentPixels8Bit() throws Exception {
ImageReader reader = new ImageReader();
reader.setId(FILE_8);
byte[] plane = reader.openBytes(0);
assertEquals(plane.length, PIXELS_8.length);
for (int q = 0; q < plane.length; q++) {
assertEquals(plane[q], PIXELS_8[q]);
}
reader.close();
}
use of loci.formats.ImageReader in project bioformats by openmicroscopy.
the class LosslessJPEG2000Test method testEquivalentPixels16Bit.
@Test
public void testEquivalentPixels16Bit() throws Exception {
ImageReader reader = new ImageReader();
reader.setId(FILE_16);
byte[] plane = reader.openBytes(0);
assertEquals(plane.length, PIXELS_16.length);
for (int q = 0; q < plane.length; q++) {
assertEquals(plane[q], PIXELS_16[q]);
}
reader.close();
}
Aggregations