Allow bilevel images to be saved in PNG (Patch #2301)


Added by Costantino Grana over 12 years ago. Updated over 12 years ago.


Status:Done Start date:2012-08-24
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:highgui-images
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

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.


bilevel_png.patch (4.2 kB) Costantino Grana, 2012-08-24 04:06 pm


Associated revisions

Revision bb936510
Added by Vadim Pisarevsky over 12 years ago

added support for bi-level PNG's (patch #2301; thanks to Costantino Grana)

Revision 5a8363a4
Added by Roman Donchenko about 11 years ago

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

Also available in: Atom PDF