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
RGB arrays mirror reversed when saved to 16-bit png using Freeimage plugin #1101
Comments
Provided code snippet: import numpy as np
from skimage import io, img_as_uint, img_as_ubyte
im = np.random.uniform(size=(256, 256, 3))
im[:128, :128] = 1
im = img_as_ubyte(im)
io.use_plugin('freeimage')
io.imsave('test_0.png', im) vs import numpy as np
from skimage import io, img_as_uint, img_as_ubyte
im = np.random.uniform(size=(256, 256, 3))
im[:128, :128] = 1
im = img_as_uint(im) # problem here, this works if ubyte
io.use_plugin('freeimage')
io.imsave('test_1.png', im) |
Likely culprit: I see comments like:
|
Thanks for adding my code snippets. Sorry, this is my first github issue report. Those comments don't sound good. I'm not sure why I would want my color components "swizzled" and my scanlines flipped. |
Having looked at the code a bit, this is because FreeImage uses a different internal representation. I think I've almost got it sorted. |
Please see if #1102 solves the problem for you. |
Seems to! Thanks stefanv. |
freeimage: Correctly handle saving uint16 images (closes gh-1101)
I am using
io.imsave
to output a numpy array to a 16-bit .png file (using the Freeimage plugin). If the array is MxNx3 (RGB) or MxNx4 (RGBA), the saved file is mirror reversed (both L-R and T-B). Works fine for greyscale (MxN).For more details see my question on stackoverflow.
I'm posting here as an issue, as suggested by ali_m on stackoverflow.
The text was updated successfully, but these errors were encountered: