Reputation: 1092
In OpenCV I'm working with some data that looks like this:
//label A B C
// 0 1 2 0
// 1 2 1 1
// 2 3 0 4
// 3 4 2 3
// 4 1 1 1
This data (columns A, B and C) can be stored in either a single-channel 5x3 matrix or in a 5x1 matrix with three channels. More concretely, for this example both definitions of data will do the job:
cv::Mat data(5, 3, CV_8UC1);
cv::Mat data(5, 1, CV_8UC3);
My question is: Is there a reason for choosing one of the declarations from above and not the other?
P.S.:This is a general doubt and not a question to a particular problem.
Upvotes: 0
Views: 84
Reputation: 17265
It really depends on what you want to do with this data.
Some OpenCV operations are easier to do on a single pixel plane but others might be multichannel oriented.
I would guess that single plane (C1
) would be more suitable for most situations though you can easily switch representations using cv::reshape()
. In fact, choose any one and use reshape()
to generate another view of the same memory.
Upvotes: 3