Ask Your Question
4

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

asked 2015-04-02 09:18:23 -0500

vfdev gravatar image

updated 2015-04-02 10:02:23 -0500

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-04-03 17:57:36 -0500

Guanta gravatar image

updated 2015-04-03 18:01:12 -0500

As much as I like OpenCV's matrices I also dislike them. Imho OpenCV should maybe have been used Eigen in the very first place, i.e. when introducing version 2.0, and only concentrate on real algorithms, but since they wanted to not relate on other libraries (which is of course a good point), you have the problem of a lot of code related to linear algebra which have to be maintained now. Allowing more than 4 channels came much later in OpenCV's history and apparently not everything has been updated. Feel free to update those parts of the library by making pull requests!

edit flag offensive delete link more

Comments

Thank you for the answer!

vfdev gravatar imagevfdev ( 2015-04-09 05:22:10 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-04-02 09:18:23 -0500

Seen: 894 times

Last updated: Apr 03 '15