[ome-users] writing tif in tiles

MEYENHOFER Felix felix.meyenhofer at unifr.ch
Tue Oct 13 15:38:19 BST 2015


Hi 

I recently bumped the bio-formats versions up to 5.1.4 And observed some weird behaviour when writing tiles in my plugins. To analyse what what happens during the writing process I took the code from
http://www.openmicroscopy.org/site/support/bio-formats5.1/developers/export.html

public class BioFormatTest {

    public static void main(String[] args) throws DependencyException, ServiceException, IOException, FormatException {
        MetadataStore metadata;
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        metadata = service.createOMEXMLMetadata();

        IFormatReader reader = new ImageReader();
        reader.setMetadataStore(metadata);
        // Take the  from File > Open Samples > Fluorescent Cells (collapse the colors or extract one and save as tif)
        reader.setId("");
        reader.setSeries(0);

        // create a writer that will automatically handle any supported output format
        IFormatWriter writer = new ImageWriter();
        writer.setMetadataRetrieve((MetadataRetrieve)reader.getMetadataStore());
        writer.setId("/Users/turf/Desktop/mb/bftest/test.ome.tif");

        int tileWidth = reader.getSizeX() /2;
        int tileHeight = reader.getSizeY() /2;

        int tileRows = reader.getSizeY() / tileHeight;
        int tileColumns = reader.getSizeX() / tileWidth;

        for (int image=0; image<reader.getImageCount(); image++) {
            for (int row=0; row<tileRows; row++) {
                for (int col=0; col<tileColumns; col++) {
                    int xCoordinate = col * tileWidth;
                    int yCoordinate = row * tileHeight;
                    byte[] tile = reader.openBytes(image, xCoordinate, yCoordinate, tileWidth, tileHeight);
                    writer.saveBytes(image, tile, xCoordinate, yCoordinate, tileWidth, tileHeight);
                }
            }
        }

        reader.close();
        writer.close();
    }
}

The result looks like this
https://drive.switch.ch/public.php?service=files&t=eb9e1fdcdd3e0d9eeeeba4ca66f941cd
https://drive.switch.ch/public.php?service=files&t=0ae325e0327c551b8a668392c1e86f08

So it seems like only the last column is written out independent of the number of tiles I choose. Am I missing something, or is this a bug?

Best,

Felix


More information about the ome-users mailing list