opencvtiff

Possible to save TIFF using CCITT (Group4) compression with OpenCV?


Is it possible to use OpenCV to save a TIFF using CCITT (Group 4) compression?

There appears to be a limitation (or missing code) allow these 1 bpp images to be saved.


Solution

  • I'll give you the same answer here that I gave you in the forum.

    OpenCV doesn't have a boolean array type. The least type is CV_8U, which is also used for mask data (0 and 255 values only).

    imwrite() goes by the element type of the passed matrix, so that path doesn't let you do what you want.

    You'd want to look for flags to imwrite that modulate how TIFFs are written. I don't see an appropriate flag yet. You could propose that (issue on github), discuss the implementation with the core devs (in the issue on github), work on a PR, and so on.

    When proposing a new flag, for the naming scheme, you might want to keep possible future extensions in mind... if there are obvious ways to extend the idea.