Community
cancel
Showing results for 
Search instead for 
Did you mean: 
tao_y_1
Beginner
164 Views

How to calculate the Euclidean distance?

Jump to solution

Hi,

I try to program with opencv and ipp to calculate the Euclidean distance between image patches(grayscale) to search for similar patches.

I firstly store the pixel information in a row matrix, like : Mat m1=(Mat_<double>(1, 4) << a,b,c,d); Mat m2=.......

and then use norm(m1,m2,CV_L2) to calculate  the Euclidean distance. That is how i calculate it with only opencv.

Now the problem is i dont know how to program it in ipp, should I use ippiNorm_L2 or SqrDistanceNorm?

Very appreciate for helping. An example would  be better.

Besides: i don't have  printf_2D_32f  function from the given example in the following link, is there something wrong with it?

https://software.intel.com/en-us/node/504335

Thanks.

regards

Tao

0 Kudos
1 Solution
Zhen_Z_Intel
Employee
164 Views

The 'SqrDistanceNorm' function is used to calculate distance between source image & template image, more relevant to feature detection. It is similar with template matching (CV_TM_SQDIFF_NORMED) in Opencv.

The 'ippiNorm_L2' is used to calculate one image pixels l2 norm value.

Seems you would like to calculate L2 norm between two image. If so, I recommend to use 'ippiNormDiff_L2', or you could use 'ippiNormRel_L2' is you would like to calculate relative error of L2 norm.

The 'printf_2D_32f ' is not IPP function, just a self-designed function. You could re-write it.

View solution in original post

1 Reply
Zhen_Z_Intel
Employee
165 Views

The 'SqrDistanceNorm' function is used to calculate distance between source image & template image, more relevant to feature detection. It is similar with template matching (CV_TM_SQDIFF_NORMED) in Opencv.

The 'ippiNorm_L2' is used to calculate one image pixels l2 norm value.

Seems you would like to calculate L2 norm between two image. If so, I recommend to use 'ippiNormDiff_L2', or you could use 'ippiNormRel_L2' is you would like to calculate relative error of L2 norm.

The 'printf_2D_32f ' is not IPP function, just a self-designed function. You could re-write it.

View solution in original post

Reply