Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

How to calculate the Euclidean distance?

tao_y_1
Beginner
541 Views

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
541 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

0 Kudos
1 Reply
Zhen_Z_Intel
Employee
542 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.

0 Kudos
Reply