Allow bilevel images to be saved in PNG (Patch #2301)
Description
PNG natively supports 1 bit depth images, but this is not available in OpenCV. I just added a new parameter define to allow for this.
By the way I believe that there were two very small bugs in the PngEncoder:
1) the compression level couldn't be set to 0 (because this was the default value used to set the default compression level
2) when setting compression the wrong function was called, namely png_set_compression_mem_level which is not related to compression level, but to memory usage.
These have been corrected.
Why is it useful to have bilevel PNGs? I often save binary masks of some segmentation or background/foreground processes. The output of these masks is at least 40% smaller if saved with
CV_IMWRITE_PNG_COMPRESSION = 9 (Z_BEST_COMPRESSION)
CV_IMWRITE_PNG_STRATEGY = 1 (Z_FILTERED)
CV_IMWRITE_PNG_BILEVEL = 1
I hope I correctly understood the Git patch procedure.
Associated revisions
added support for bi-level PNG's (patch #2301; thanks to Costantino Grana)
Merge pull request #2301 from jet47:fix-nonfree-build
History
Updated by Vadim Pisarevsky over 12 years ago
thanks! your patch was applied in b3408a
- Assignee set to Vadim Pisarevsky
- Category set to highgui-images
- Target version set to 2.4.3
- Status changed from Open to Done