YuZ
YuZ

Reputation: 445

initializing 3 channel Mat with ones

I'm trying to initialize a 3 channel Mat with ones, but

Mat img_l=Mat::ones(2048,3072,CV_8UC3)
cout << (uint)img_l.at<Vec3b>(4,4)[0] << (uint)img_l.at<Vec3b>(4,4)[1] << (uint)img_l.at<Vec3b>(4,4)[2] << endl;

returns 1 0 0

How can I initialize G, B and R channels?

Upvotes: 0

Views: 1494

Answers (1)

Andrey  Smorodov
Andrey Smorodov

Reputation: 10852

Just assign Scalar to matrix, like this:

img_l=Scalar::all(1);

or

img_l=Scalar(1,1,1,1);

Upvotes: 2

Related Questions