samskillman / pylibtiff

Automatically exported from code.google.com/p/pylibtiff
Other
0 stars 0 forks source link

Does work for 1bit compressed TIFF #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It seems that the library is working well for greyscale and color images, but 
as soon as a pure black&white (1bit/1plan) is given, it fails and renders a 
totally black image

I suppose there is something to do in read_image function cause I saw some 
comments in the code saying "TODO: check for correctness"

Original issue reported on code.google.com by rangoni....@gmail.com on 11 Mar 2011 at 4:07

GoogleCodeExporter commented 9 years ago
I wrote a patch to read group4 binary images... it might not work for other 
compression schemes, and gives an image with inverted colors.

Original comment by vcha...@gmail.com on 6 Nov 2011 at 12:33

Attachments:

GoogleCodeExporter commented 9 years ago
It works for my images! Thanks for the patch!

Original comment by rangoni....@gmail.com on 6 Nov 2011 at 4:55

GoogleCodeExporter commented 9 years ago
Even if it does not provide complete support for 1bit images
(no write support, the returned array is actually 8 bit array
because numpy does not have int1 type available)
I have applied the patch (with slight modification) to svn repo
because the patch is simple and it works for some applications.

Original comment by pearu.peterson on 6 Nov 2011 at 8:46

GoogleCodeExporter commented 9 years ago
There is no int1 type available, but there is numpy.bool for binary vectors...

Original comment by vcha...@gmail.com on 6 Nov 2011 at 9:03

GoogleCodeExporter commented 9 years ago
Sure, but numpy.bool has 8 bits, not 1, and thus it is equivalent to numpy.int8.
This makes writing numpy.bool arrays as 1 bit arrays tricky (need to use
bittools extension module to convert 8bit arrays to 1bit arrays before calling 
WriteStrip).

Original comment by pearu.peterson on 6 Nov 2011 at 9:25