Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to deal with multi-channels Array

I have two arrays:

   A (rows:60, cols:62,dim:2,channel:32)  and  F(rows:9, cols:9,dim:2,channel:32).

I want to compute Convolution with A and F, but it failed because the channel of A is more than 3. So the official API filter2d() not support this input Array!!! Now, I implement this function with for-loop :

  1. Split A into vector vecA,and the vecA.size=A.channel = 32 , the same as F and vecF.
  2. for-loop for computing Convolution

    cv::Mat acc;

    for( int i=0 ; i < vecA.size() ; i++) {

    cv::Mat dst;

    filter2d( vecA[i], dst , vecA[i].depth(), vecF[i], Point(-1, -1), 0, BORDER_CONSTANT);

    cv::add(acc, dst ,acc);

}

It is very ugly and not Efficient , so anyone have some ideas help me???