Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why most of basic operations with cv::Mat with number of channels > 4 do not work ?

Hello opencv users and developers,

I just wonder why these cases does not work (version 2.4.6) :

1) cv::Mat a(10,12, CV_32FC(5), cv::Scalar::all(0)); // OK, here the answer is related to cv::Scalar that is 4-component vector...

2) cv::Mat a = cv::Mat::ones(10, 12, CV_32FC(5)); // Assertion failed cn <= 4

Even if one manages to define cv::Mat a = cv::Mat::zeros(10, 12, CV_32FC(5)) and

3) cv::Mat b = a - 10; // The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array')

So, my question is why the usage of cv::Mat matrices with more than 4 channels becomes as diffcult ?

The background of my problem is that, in the input I can get an image with 1,3,4,5,7 bands and I would like to have similar processing for all cases...

Cheers, Victor

Why most of some basic operations with cv::Mat with number of channels > 4 do not work ?

Hello opencv users and developers,

I just wonder why these cases does not work (version 2.4.6) :

1) cv::Mat a(10,12, CV_32FC(5), cv::Scalar::all(0)); // OK, here the answer is related to cv::Scalar that is 4-component vector...

2) cv::Mat a = cv::Mat::ones(10, 12, CV_32FC(5)); // Assertion failed cn <= 4

Even if one manages to define cv::Mat a = cv::Mat::zeros(10, 12, CV_32FC(5)) and

3) cv::Mat b = a - 10; // The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array')

So, my question is why the usage of cv::Mat matrices with more than 4 channels becomes as diffcult ?

The background of my problem is that, in the input I can get an image with 1,3,4,5,7 bands and I would like to have similar processing for all cases...

Cheers, Victor