Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

@trucna why not split the original multi-channel matrices into individual matrices within a vector<Mat>, then multiply the individual correspondent channels and finally re-merge the final outcome into a multi-channel matrix again. Example, pseudo code:

Mat a;
Mat b;
Mat c;

vector<Mat> a_channels;
vector<Mat> b_channels;
vector<Mat> c_channels;

split(a, a_channels);
split(b, b_channels);

for(i = 0; i < a_channels.size() || b_channels.size(); i++)
{
    c_channels.push_back(a_channels[i] * b_channels[i]);
}

merge(c_channels, c);

and then you have your result.

@trucna why not split the original multi-channel matrices into individual matrices within a vector<Mat>, then multiply the individual correspondent channels by using the mul() and finally re-merge the final outcome into a multi-channel matrix again. Example, pseudo code:

Mat a;
Mat b;
Mat c;

vector<Mat> a_channels;
vector<Mat> b_channels;
vector<Mat> c_channels;

split(a, a_channels);
split(b, b_channels);

for(i = 0; i < a_channels.size() || b_channels.size(); i++)
{
    c_channels.push_back(a_channels[i] * b_channels[i]);
c_channels.push_back(a_channels[i].mul(b_channels[i]));
}

merge(c_channels, c);

and then you have your result.

@trucna why not split the original multi-channel matrices into individual matrices within a vector<Mat>, then multiply the individual correspondent channels by using the mul() and finally re-merge the final outcome into a multi-channel matrix again. Example, pseudo code:

Mat a;
Mat b;
Mat c;

vector<Mat> a_channels;
vector<Mat> b_channels;
vector<Mat> c_channels;

split(a, a_channels);
split(b, b_channels);

for(i = 0; i < a_channels.size() || b_channels.size(); i++)
{
    c_channels.push_back(a_channels[i].mul(b_channels[i]));
}

merge(c_channels, c);

and then you have your result.