Create a 1bpp (bit per pixel) image in OpenCV with C++

2.6k Views Asked by At

I am trying to create a 1bpp image (1 bit per pixel) mask in C++ for a project, however I am stuck on how I can do this with OpenCV?

The code I am trying with is:

int WIDTH=640; int HEIGHT=480;
Mat mask = Mat::zeros( cv::Size( WIDTH, HEIGHT ), CV_8UC1 );
mask( Rect( 50,50,100,100 ) ) = 1;

I am not sure if this is the right way to create a 1 bpp mask though. Does anyone know if this is possible using OpenCV or in C++ at all?

0

There are 0 best solutions below