qupath / qupath

QuPath - Bioimage analysis & digital pathology
https://qupath.github.io
GNU General Public License v3.0
995 stars 267 forks source link

TileExporter with ImageJ TIFF can lose pixel size and channel color information #1516

Open petebankhead opened 1 month ago

petebankhead commented 1 month ago

Bug report

Describe the bug When using the TileExporter, pixel size and channel color information can be lost.

To Reproduce Use the TileExporter class to export fixed-size tiles as ImageJ TIFF, e.g. with this script applied to the LuCa sample image:

def path = buildPathInProject("tiles")
mkdirs(path)
def imageData = getCurrentImageData()
new TileExporter(imageData)
    .writeTiles(path)

Open the resulting TIFFs in ImageJ and see that no calibration is set.

Expected behavior Channel colors are preserved, and the image properties are set (pixel size and origin).

Desktop (please complete the following information):

Additional context Relates to https://github.com/qupath/qupath/issues/1503 but is not identical.

The relevant code is at https://github.com/qupath/qupath/blob/0ab5d054a2aac2e21d1bcc234306e164e44965bb/qupath-core/src/main/java/qupath/lib/images/writers/TileExporter.java#L786

The difficulty is guaranteeing that tiles have a fixed size, rather than risking an off-by-one error, when we can only define the region with an ImageServer and RegionRequest that can have an arbitrary downsample.