1 | initial version |
do something like this:
Mat bgr = ... //
// preallocate the blob:
int siz[] = {1, 3, bgr.rows, bgr.cols};
Mat blob(4, siz, bgr.depth());
// get pointers to preallocated image planes
vector<Mat> slices = {
Mat(bgr.rows, bgr.cols, bgr.depth(), blob.ptr<uchar>(0,0)), // beware, hardcoded type here !
Mat(bgr.rows, bgr.cols, bgr.depth(), blob.ptr<uchar>(0,1)),
Mat(bgr.rows, bgr.cols, bgr.depth(), blob.ptr<uchar>(0,2)),
};
// split color planes
split(bgr, slices);
2 | No.2 Revision |
do something like this:
Mat bgr = ... //
// you probably need to resize / crop it here
// preallocate the blob:
int siz[] = {1, 3, bgr.rows, bgr.cols};
Mat blob(4, siz, bgr.depth());
// get pointers to preallocated image planes
vector<Mat> slices = {
Mat(bgr.rows, bgr.cols, bgr.depth(), blob.ptr<uchar>(0,0)), // beware, hardcoded type here !
Mat(bgr.rows, bgr.cols, bgr.depth(), blob.ptr<uchar>(0,1)),
Mat(bgr.rows, bgr.cols, bgr.depth(), blob.ptr<uchar>(0,2)),
};
// split color planes
split(bgr, slices);