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

RGB image format doesn't follow the standard numpy RGB format #21

Closed
GoogleCodeExporter opened this issue Apr 3, 2015 · 2 comments
Closed

Comments

@GoogleCodeExporter
Copy link

write_image() supports RGB image if write_rgb=True is passed, but it expects an 
numpy array in the format 3xMxN for an image of MxN pixels, while the normal 
RGB images in numpy are encoded MxNx3. 

For reference, see the documentation here:
http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.imread.html

As a workaround, I currently send a view of my array with axes swapped to 
write_image. Like this:
image = scipy.ndimage.imread("test.jpg")
image_sw = image.swapaxes(2,0).swapaxes(2,1)
tif.write_image(image_sw, write_rgb=True)


I can try to provide a patch if you're interested.

Original issue reported on code.google.com by eric.p...@gmail.com on 9 Oct 2012 at 9:03

@GoogleCodeExporter
Copy link
Author

Please find here a patch (against the current svn HEAD) to fix this issue. It 
enhances the behaviour of TIFF.write_image() when write_rgb=True. 

Basically, when this flag is True, write_image() will always write a single 
image, and try its best to describe it as a RGB (or RGBA) image.

Note that it also modifies the orientation tag to the correct value, which 
fixes issue 18.

The patch is available also as a git commit here:
https://github.com/delmic/pylibtiff/commit/cc38e51ae0857b605c81e7f631279b5cd54de
55d

Original comment by eric.p...@gmail.com on 5 Aug 2013 at 2:08

Attachments:

@GoogleCodeExporter
Copy link
Author

Thanks! Patch applied to svn.

Original comment by pearu.peterson on 13 Sep 2014 at 10:11

  • Changed state: Fixed

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

No branches or pull requests

1 participant