计算2个像素之间的Luv值的欧氏距离

时间:2015-04-20 19:58:38

标签: c++ opencv euclidean-distance

在opencv c ++中,我试图弄清楚如何计算点i,j与3x3内核中所有点之间的欧氏距离。这是为了从Luv颜色空间创建显着性的对比图。我也尝试过规范功能无济于事。我对如何解决这个问题非常困惑,并希望得到一些反馈。

  Mat tmp1 = MeanShift_Luv.clone();

  int big_theta = 3; // kernel size / neighborhood to perform convolution on

  Mat gradient_1 = Mat::zeros(tmp1.rows, tmp1.cols, CV_64FC3);
  for (int i = 0; i < tmp1.rows; i++){
     for (int j = 0; j < tmp1.cols; j++){     
      double dist = 0;
      for (int m = -big_theta / 2; m < big_theta / 2; m++){  

          for(int n = -big_theta /2; n < big_theta / 2; n++){
              if (m == 0 || n == 0) continue;
              if (i + m < 0 || i + m >= tmp1.rows) continue;
              if (j + n < 0 || j + n >= tmp1.cols) continue;

              /* unsure what to do at this part
              Point a(i,j);
              Point b(i+m, j+n);
              */ 
         }
     }
     gradient_1.at<Vec3d>(i,j) = dist;
   }

0 个答案:

没有答案