Ask Your Question
1

How to generate/convertto 1 bit depth image

asked 2013-11-01 16:12:02 -0600

mahabudhi gravatar image

I am new to OpenCV, I am trying to generate a 1 bit image using OpenCV APIs. Is this possible? Can someone point me to right API.

Thank you

MB

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-11-01 16:18:09 -0600

Douglas Gatti gravatar image

updated 2013-11-01 16:19:57 -0600

Are talking about thresholding?

cvThreshold(const CvArr* src, CvArr* dst, double threshold, double max_value, int threshold_type)

http://docs.opencv.org/2.4.5/modules/imgproc/doc/miscellaneous_transformations.html?highlight=threshold#void adaptiveThreshold(InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C)

edit flag offensive delete link more

Comments

Thank you Douglas, but when I write the Mat (the resultant Mat) object using imwrite to a file as PNG file, the file properties show the 'bit depth' as '8' rather than '1'.

Is there special way I need to use imwrite to accomplish this or some other technique exists.

Thanks

MB

mahabudhi gravatar imagemahabudhi ( 2013-11-01 16:54:12 -0600 )edit

threshold, and then save as pbm, not png

berak gravatar imageberak ( 2013-11-02 05:51:43 -0600 )edit

I am trying to do the same thing. I tried saving as .pbm but that still outputs a 8 bit image. The original image I open is a 1 bit image, monchrome, which I can save to any graphics format I want and I can increase the bit depth. Just can't save as is, which is a bit depth of 1. Mat sourceImage = imread(inputFile, CV_LOAD_IMAGE_UNCHANGED) does not leave it unchanged as it implies. Any way to do it?

jarger gravatar imagejarger ( 2014-01-07 10:42:15 -0600 )edit

Question Tools

Stats

Asked: 2013-11-01 16:12:02 -0600

Seen: 2,302 times

Last updated: Nov 01 '13