hipspy / hips

Python library to handle HiPS
https://hips.readthedocs.io
12 stars 16 forks source link

Add test cases for grayscale JPEG #88

Open cdeil opened 7 years ago

cdeil commented 7 years ago

Just now I noticed that there are HiPS JPEG tiles that are grayscale, i.e. don't have the 3 color channels. Example:

>>> from skimage import io
>>> io.imread('../hips-extra/datasets/samples/IRAC4/Norder3/Dir0/Npix299.jpg').shape
(512, 512)

I think that currently we don't process those correctly, because here we assume with JPEG we always have 3 channels: https://github.com/hipspy/hips/blob/fce110c0e2bf31baba5d9050ccf08a9c67493dff/hips/tiles/tile.py#L52

So the task here is to add test cases for the already parameterized tests using this example, in test_tile.py and test_draw.py, and then possibly to fix the handling of the shape to return a 2-dim image without color channels in that case.

cdeil commented 7 years ago

So as mentioned on https://github.com/hipspy/hips-extra/issues/6#issuecomment-318153188 this is actually a publicly available HiPS that people will want to use.

But I now get this:

>>> from skimage.io import imread
>>> imread('http://alasky.u-strasbg.fr/IRAC4/Norder3/Dir0/Npix0.jpg').shape
(512, 512, 3)
>>> imread('https://github.com/hipspy/hips-extra/raw/master/datasets/samples/IRAC4/Norder3/Dir0/Npix299.jpg').shape
(512, 512)

It looks like the tiles we have in hips-extra are different (single channel) from the ones on the CDS server (3 channel as for other JPEG).

@tboch - I'm assigning this issue to you: please clarify if we need to change our code to handle single-channel JPEG. And if it's not the case, then we should update the example dataset in hips-extra for IRAC4.

cdeil commented 5 years ago

@tboch - Can you please comment here? Are there JPEG HiPS tiles that are 2D, or are they always 3D with the RGB color channel?

tboch commented 5 years ago

@cdeil : the HiPS standard says nothing about the layout of the JPEG tiles, thus we should expect to have 3 channels or a single channel. I think most of the JPEP grayscale tiles are encoded on 3 channels nevertheless.

In the very case you mention, I'm quite surprised that we have a mix between 1-channel and 3-channels tiles.