Ask Your Question
1

Is it possible to create a BGR image from predefined 3 (1-channel) image

asked 2018-08-14 10:41:48 -0600

nobot gravatar image

updated 2018-08-14 10:48:28 -0600

I am trying to create 1 CV_8UC3 image from 3 different CV_8UC1 images that I already have, i.e I am trying to allocate the different single channel images that I already have into a single 1 Multi-Dimensional Image

Mat image3c(width, height, CV_8UC3, **data**)

Is it either possible to-

  1. give the data directly during the CV_8UC3 creation

  2. std::vector<Mat> channels{ channelB, channelG, channelR }; // already have individual channels BGR in CV_8UC1 format merge(channels, image3c);

  3. splitting the image3c Mat and then copying the predefined CV_8UC1 into the channels and then merging is possible, but trying best to avoid that

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-08-14 10:51:49 -0600

berak gravatar image

just use cv::merge here:

std::vector<Mat> channels { channelB, channelG, channelR };
Mat bgr;
cv::merge(channels, bgr);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-08-14 10:41:48 -0600

Seen: 490 times

Last updated: Aug 14 '18