Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for HiPS tile <-> Numpy conversions #140

Merged
merged 3 commits into from
Jan 8, 2019
Merged

Conversation

cdeil
Copy link
Contributor

@cdeil cdeil commented Jan 8, 2019

Today I wanted to make the healpix_to_hips work for RGB JPEG and RGBA PNG data. I'll make a pull request for that shortly.

However, I noticed that there seems to be a bug in our HipsTile.from_numpy or HipsTile.to_numpy for the RGB JPEG case. This PR shows the issue via a regression test. It works for FITS and also for RGBA PNG as expected.

Looking for old issues I saw #112, possibly this is the same issue. I did try adding .copy calls before and after the flipud calls in from_numpy, no change, so transposed Numpy arrays don't seem to be the issue.

@tboch and maybe if you have time @adl1995 or @adonath - If you have time, could you please have a look at this and comment if you have any idea?

This is blocking the work on HEALPix -> HiPS and the v0.3 release, so we should try to figure this out ASAP.

@cdeil cdeil added the bug label Jan 8, 2019
@cdeil cdeil added this to the 0.3 milestone Jan 8, 2019
@cdeil cdeil self-assigned this Jan 8, 2019
@cdeil cdeil requested a review from tboch January 8, 2019 15:07
@cdeil
Copy link
Contributor Author

cdeil commented Jan 8, 2019

Actually it looks like the issue is just "JPEG encoding noise", if I change the example to larger integer numbers in the unit8 range (e.g. 0, 100, 200 instead of 0, 1, 2) they approximately round-trip.

https://nbviewer.jupyter.org/gist/cdeil/c5401336d7d5eb477263fb8b7b358de1

@adl1995
Copy link
Member

adl1995 commented Jan 8, 2019

@cdeil - Thanks for looking into this.

Could this possibly have something to do with JPEG being a lossy format? We currently save the image using the Image.save function from Pillow, without providing any extra parameters for controlling the image quality.

This documentation for JPEG file format lists other keyword parameters that can be used e.g. dpi and quality (which is a number from 0 to 100, default is set to 75).

Maybe you could try setting this to 100 and see if it affects the output?

@cdeil cdeil removed the bug label Jan 8, 2019
@cdeil cdeil merged commit 3719ae4 into hipspy:master Jan 8, 2019
@cdeil
Copy link
Contributor Author

cdeil commented Jan 8, 2019

This is not changing any behaviour. It's just adding tests that prove that tile Numpy array conversions are working OK and doing some (accidentally applied) code formatting.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 95.675% when pulling 83d3174 on cdeil:tile-numpy into a9660bd on hipspy:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants