saalfeldlab / n5-spark

Spark-driven processing utilities for N5 datasets.
BSD 2-Clause "Simplified" License
3 stars 7 forks source link

Cannot convert label N5 datasets to slice TIFF (uint64) #21

Closed igorpisarev closed 4 years ago

igorpisarev commented 4 years ago

Conversion to slice TIFF is done using ImageJ toolkit, so the only supported types are uint8, uint16, and float32. Attempting to convert a uint64 dataset produces the following error:

net.imglib2.exception.ImgLibException: net.imglib2.img.imageplus.ImagePlusImg: has no ImagePlus instance, it is not a standard type of ImagePlus
    at net.imglib2.img.imageplus.ImagePlusImg.getImagePlus(ImagePlusImg.java:154)
    at org.janelia.saalfeldlab.n5.spark.N5ToSliceTiffSpark.lambda$convert$589f7882$1(N5ToSliceTiffSpark.java:172)
    ...

A possible solution could be to save as uint16 TIFF, which should be sufficient in most cases. If the value range is beyond uint16, most likely the label IDs are sparse, so in this case the value range can be remapped to 1..N.

igorpisarev commented 4 years ago

Fixed in #22 without remapping the values. Instead, the converter tries to directly write the input values into the most suitable output type. If the values are out of the valid range (for example, uint64 values can easily be outside the range 0-65535), the converter will fail. But this should be sufficient for most cases.