use of loci.formats.out.OMETiffWriter in project bioformats by openmicroscopy.
the class OrthogonalReader method readOrthogonalPlanes.
private void readOrthogonalPlanes() throws Exception {
// Setup logger
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
if (debug) {
root.setLevel(Level.DEBUG);
} else {
root.setLevel(Level.INFO);
}
ImageReader reader = this.initialiseReader(this.input);
reader.setSeries(0);
OMETiffWriter writer = this.initialiseWriter(this.output, reader);
int index;
// Write XZ planes
writer.setSeries(0);
for (int y = 0; y < reader.getSizeY(); y++) {
ByteBuffer bufferXZ = ByteBuffer.allocate((int) (0.125 * reader.getBitsPerPixel()) * reader.getSizeX() * reader.getSizeZ());
for (int z = 0; z < reader.getSizeZ(); z++) {
index = reader.getIndex(z, 0, 0);
byte[] line = reader.openBytes(index, 0, y, reader.getSizeX(), 1);
bufferXZ.put(line);
}
log.debug("y: {}, {}", y, bufferXZ.array().length);
writer.saveBytes(y, bufferXZ.array());
}
// Write YZ planes
writer.setSeries(1);
for (int x = 0; x < reader.getSizeX(); x++) {
ByteBuffer bufferYZ = ByteBuffer.allocate((int) (0.125 * reader.getBitsPerPixel()) * reader.getSizeY() * reader.getSizeZ());
for (int z = 0; z < reader.getSizeZ(); z++) {
index = reader.getIndex(z, 0, 0);
byte[] line = reader.openBytes(index, x, 0, 1, reader.getSizeY());
bufferYZ.put(line);
}
log.debug("x: {}, {}", x, bufferYZ.array().length);
writer.saveBytes(x, bufferYZ.array());
}
reader.close();
writer.close();
}
Aggregations