CCITT group 4 (Fax4) decoding support#229
Conversation
|
Probably check |
|
OK. I've done some research and found that
To conform with how everything in the wild I'd argue we just keep this hardcoded the way it is? |
|
hahaha. Yea, I think just keep it as is. |
fintelia
left a comment
There was a problem hiding this comment.
Left some comments. I think might also be a missing check that fax compression is only used for bilevel images?
|
Ideally, I'd like to see the |
|
I don't see a reason why incremental decoding could not be implemented. It would be pretty easy to write something like |
|
Yeah, I think an interface like that would work. Then it could be wrapped in another object that implemented |
|
Appreciate the feedback and all the back-and-forth here. I'm happy to help out as much as I can here to push this forward, but I don't want to step on @s3bk's feet if he's working on these changes. |
|
@stephenjudkins I pushed changes to the fax repo. There are strange differences with the last line again. I need to re-encode my samples with libtiff to check if the error is in the sample data or my code. But you should be able to use the code to adapt this PR to the next version. |
|
What is the state of this? Anything one can do? |
|
I don't know, but from what a I remember, the fax tests are all passing now. |
|
Seems that something with the |
|
Sorry! I dropped this but would like to pick it back up. Can we confirm that the upstream |
|
OK, I've made some changes, and I've gotta say...I'm putting in a lot of work to support 1-bit samples, both here and in the If you feel strongly on keeping the 1-bit image option I'll add the flag but there are a lot of edge cases I'm pretty worried about testing. Are you sure that you want this? It's frustrating to write a bunch of code that I suspect will never be used by anyone and might introduce bugs into other code paths. |
|
@stephenjudkins I assume that refers to images like this, with 1 bit per sample?: If so, that is exactly what I am looking for... |
|
Files are decoded and encoded correctly, but bit-wise verification fails for some files that have a strange EOF. |
|
OK. I'm still working on this, and, since this code does not currently support < 8 bit samples it's introducing some significant and pervasive changes across several code paths that I don't reasonably expect to be able to test. Would you like to help me by finding some other files that could test this? Do you know of any 1-bit tile-based (instead of strip-based) files I could check? |
|
@stephenjudkins I made a fix to the sub 8-bpp decoding in #252. It should now be working. If you want to make test images, you can use gdal_translate: For instance, this is a fax4 compressed version of the test image from that other PR: tiled-gray-i1-fax4.tif.zip (inside a ZIP archive because GitHub doesn't allow uploading TIFF files) |
|
Alright, I've added support for bit-sized samples as well as an optional flag (a la the PNG crate) to expand these to 8bpp. I've confirmed in the upstream |
|
See draft PR https://github.com/image-rs/image/pull/2377/files |
|
This adds |
just an FYI here, the TIFF versions of NOAA's marine weather charts are all in Group 4 format. Those charts also happen to be all set as |
|
Hi @stephenjudkins. Do you still have capacity to continue working on this? I was chasing another issue. Apparently, it is solved by this PR. |
42b2eb6 to
cf0a595
Compare
Reuse the allocation of bits for every row though
|
I see the PR got reworked and the test image that ultimately made it into the repo has This contradicts the research done in #229 (comment) and diverges from other TIFF Fax4 decoders. This also breaks the test image from libtiff, see image-rs/image#1822 (comment) |
|
The test image added in this PR has Meanwhile ImageMagick 6.9.11 decodes both correctly, as does GIMP. I also could not reproduce the issue with imagemagick reportedly writing broken files. Here's the output of It has It seems the photometric interpretation needs to be read and honored after all. Either that, or we're the only ones honoring it and THAT is causing bugs. |
This adds support for decoding CCIT group 4 tiff images by using the
faxcrate.I've found that the photometric interpretation tag is ignored by all the extant decoders I've found, and attempting to correctly interpret it will break some subset of images. Unfortunate, but I suspect it's best to follow the herd here?