Is it possible to save a 1 bpp TIFF image with OpenCV?
I’m trying to load a grayscale image (8 bpp), binarize (threshold) the image and then save a 1 bpp TIFF using CCIT (Group 4) compression.
It looks like grfmt_tiff.cpp needs an update to support this?
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.
1 Like
Thanks so much for the reply and the information. I’ll post an issue on GitHub and hopefully one of the core devs (you?) might be able to implement the feature.
heh I’m not one of them. most of them are Intel people or close to Intel in some way, getting paid for the work.
even if they rank this low on the list of priorities (not a bug, not architectural, not a trendy topic), someone from the community is bound to show interest.
if you haven’t browsed the OpenCV source yet, give it a look. this feature might be easier to implement than you think. it’s probably just a new flag, and a bit of code to map that to the API calls to libtiff.