I have been looking at the code that exports images as OME-TIFF. I noticed that for larger images the export seems to geometrically slow down. I decided to investigate this by adding some export timings to the Blitz log for the components/blitz/src/ome.services.blitz.impl.ExporterI class within the do_tiff(...) method.
I did a lot of reading of the code in the process and noticed that the sequential flag was not set on the BioFormats ImageWriter. This means that each time a new plane is written to the TIFF file, BioFormats reads the entire file to locate the positions of all the current IFD entries (see method loci.formats.tiff.TiffSaver.writeImageIFD(...)). If the current plane being written is less than the total count of IFD entries then the correct IFD entry is extracted for use.
Since the planes are written using incremental plane numbers I do not think this condition will ever be met. Thus it is safe to set the sequential flag to true.
I have tested this by adding the following code to ome.services.blitz.impl.ExporterI.do_Tiff(...):
- Code: Select all
writer = new ImageWriter();
writer.setMetadataRetrieve(retrieve);
writer.setWriteSequentially(true); // New code
writer.setId(file.getAbsolutePath());
Note: The call to setWriteSequentially(...) must be made before the call to setId(...) because that method initialises the TiffSaver object with the current sequential flag value.
Here are some timings generated using some artificial images of set sizes (timings are in seconds):
- Code: Select all
Size (MB) Off On Speed-up (Off / On)
0.5 0.306 0.323 0.948
1 0.133 0.272 0.488
2 0.529 0.672 0.786
4 0.654 0.636 1.030
8 1.290 1.217 1.060
16 2.624 2.357 1.113
32 5.776 4.517 1.279
64 13.620 9.049 1.505
128 36.041 18.024 2.000
256 106.802 35.596 3.000
512 354.905 71.353 4.974
As you can see the flag makes the export times scale linearly instead of geometrically. There is a significant 5 fold difference to a 500MB file. I expect the performance gains to be even better for larger files.
I have verified that the exported images render exactly the same in ImageJ for my test images and also some valid microscope images imported from DeltaVision files.
Can you verifiy if there is any reason why this flag should not be set? I assume you have a set of test cases that you can run to validate export.
I am using OMERO 4.3.0. If this fix has already been done as part of the work on exporting TIFFs larger than 4GB then at least I learned something about the code.
Regards,
Alex