use of loci.formats.meta.IMetadata in project bioformats by openmicroscopy.
the class FileExport method export.
/**
* Save a single 512x512 uint16 plane of random data.
*/
public void export() {
int width = 512, height = 512;
int pixelType = FormatTools.UINT16;
IMetadata omexml = initializeMetadata(width, height, pixelType);
// only save a plane if the file writer was initialized successfully
boolean initializationSuccess = initializeWriter(omexml);
if (initializationSuccess) {
savePlane(width, height, pixelType);
}
cleanup();
}
use of loci.formats.meta.IMetadata in project bioformats by openmicroscopy.
the class ReadPhysicalSize method readPhysicalSize.
/**
* Reads the physical dimensions of the input file provided then converts and displays them in micrometers
*
* @param inputFile the file to be read
* @throws FormatException if a parsing error occurs processing the file.
* @throws IOException if an I/O error occurs processing the file
*/
public static void readPhysicalSize(final String inputFile) throws FormatException, IOException {
final ImageReader reader = new ImageReader();
final IMetadata omeMeta = MetadataTools.createOMEXMLMetadata();
reader.setMetadataStore(omeMeta);
reader.setId(inputFile);
final Unit<Length> targetUnit = UNITS.MICROMETER;
for (int image = 0; image < omeMeta.getImageCount(); image++) {
final Length physSizeX = omeMeta.getPixelsPhysicalSizeX(image);
final Length physSizeY = omeMeta.getPixelsPhysicalSizeY(image);
final Length physSizeZ = omeMeta.getPixelsPhysicalSizeZ(image);
System.out.println("Physical calibration - Image: " + image);
if (physSizeX != null) {
final Length convertedSizeX = new Length(physSizeX.value(targetUnit), targetUnit);
System.out.println("\tX = " + physSizeX.value() + " " + physSizeX.unit().getSymbol() + " = " + convertedSizeX.value() + " " + convertedSizeX.unit().getSymbol());
}
if (physSizeY != null) {
final Length convertedSizeY = new Length(physSizeY.value(targetUnit), targetUnit);
System.out.println("\tY = " + physSizeY.value() + " " + physSizeY.unit().getSymbol() + " = " + convertedSizeY.value() + " " + convertedSizeY.unit().getSymbol());
}
if (physSizeZ != null) {
final Length convertedSizeZ = new Length(physSizeZ.value(targetUnit), targetUnit);
System.out.println("\tZ = " + physSizeZ.value() + " " + physSizeZ.unit().getSymbol() + " = " + convertedSizeZ.value() + " " + convertedSizeZ.unit().getSymbol());
}
}
reader.close();
}
Aggregations