# imwrite doesn't output correct PBM file format in the header.

I need opencv to write PBM file which the header should be 'P4' described in this web site.

However I checked OpenCV 2.4.6.1's source code grfmt_pxm.cpp

sprintf( buffer, "P%c\n%d %d\n%d\n",
'2' + (channels > 1 ? 1 : 0) + (isBinary ? 3 : 0),
width, height, (1 << depth) - 1 );


So I can see it can never be '4' after 'P'. So I'm asking here whether OpenCV support PBM file format, how should I write the file.

Currently I write my file like this,

Mat outputmask(mask.size(), CV_8UC1, Scalar::all(1)) ;