opencv频域相乘

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
int main()
{
    bool LAB = false;
    bool HOG = true;
    bool FIXEDWINDOW = false;
    bool MULTISCALE = true;
    cv::hal;
    int w=10;
    int h=10;
       float cbufi[h*w];
    for (size_t i = 0; i < h; i++) {
        for (size_t j = 0; j < w; j++) {
            cbufi[i*w+j]= i*j*0.2+1;
        }
    }
    float cbuf[h*w];
 for (size_t i = 0; i < h; i++) {
     for (size_t j = 0; j < w; j++) {
            cbuf[i*w+j]= i*j*0.1+1;
     }
 }
    float cbuf2i[h*w];
    for (size_t i = 0; i < h; i++) {
        for (size_t j = 0; j < w; j++) {
                cbuf2i[i*w+j]= i*j*0.9+2;
        }
    }
    float cbuf2[h*w];
    for (size_t i = 0; i < h; i++) {
        for (size_t j = 0; j < w; j++) {
                cbuf2[i*w+j]= i*j*0.5+2;
        }
    }
    cv::Mat r1(h, w, CV_32FC1, cbuf);
      cv::Mat r2(h, w, CV_32FC1, cbufi);
       std::vector<cv::Mat> pa;
       pa.push_back(r1);
        pa.push_back(r2);
         cv::Mat com;
         cv::merge(pa,com);
//     cv::Mat com1=  complexMultiplication(com,r2);
     cv::Mat r3(h, w, CV_32FC1, cbuf2);
       cv::Mat r4(h, w, CV_32FC1, cbuf2i);
       std::vector<cv::Mat> pb;
       pb.push_back(r3);
        pb.push_back(r4);
         cv::Mat com2;
         cv::merge(pb,com2);
// cv::Mat com2=  complexMultiplication(r3,r4);
      KCFTracker tracker(HOG, FIXEDWINDOW, MULTISCALE, LAB);
      cv::Mat caux;
          cv::mulSpectrums(com,com2, caux, 0, true);
          std::vector<cv::Mat> resv;
          cv::split(caux, resv);
         cv::Mat realMat=resv[0];
          cv::Mat imaginaryMat=resv[1];
          for (int i=0;irows;i++)
             {
                 for (int j=0;jcols;j++)
                 {
//                    float num = caux.at(i,j);
                   float realf=  realMat.at<uchar>(i,j);
                     float imaginaryf= imaginaryMat.at<uchar>(i,j);
                      printf("%f+%fi ",realf,imaginaryf);
                 }
                  printf("\n");
             }


}

你可能感兴趣的:(opencv基础)