cgohlke / imagecodecs

Image transformation, compression, and decompression codecs
https://pypi.org/project/imagecodecs
BSD 3-Clause "New" or "Revised" License
111 stars 21 forks source link

Fix indexing in updated CMS implementation #57

Closed Entropy512 closed 1 year ago

Entropy512 commented 1 year ago

The new implementation used tf.shape[0], which led to truncated TRCs if there were three independent TRCs since tf.shape[0] == 3 in that case

Use tf.shape[tf.ndims-1] instead. tf.shape[-1] does not appear to function correctly, likely due to cython having somewhat different indexing than python?

Also, the indexing into tf.data remains in bytes, so the size of the data items must be taken into account, and each TRC starts at jsizeof(dataitem)tf.shape[tf.ndims-1] - not sure if there's a cython equivalent for sizeof()?

cgohlke commented 1 year ago

Please try v2022.12.24.

Entropy512 commented 1 year ago

Yup, working well for float32. Haven't tested int16 but the code looks good for that at least.