Hausdorff Distance between images

Started by
11 comments, last by Dmytry 17 years, 8 months ago
Well, pow() also handles cubes and other powers, not just squares. So it's not surprising that it's slower than multiplication.

And if it is ment be this:

maxDistAB *= 1/(widthA*heightA)

Then, I'd change that to:

maxDistAB /= (widthA*heightA)

The compiler would probably optimize that out and the difference wouldn't be much but, I think it also makes it clearer.
Advertisement
Quote:Original post by dnaxx
The pow-function* from "math.h" is even slower than "normal" multiplication.


'even' slower than normal multiplication? im pretty sure multiplication is a one-cycle instruction. pow is probably more in the range of 100 cycles.
pow can raise to arbitrary powers (and on floats, it probably could raise to floating point power), kinda overkill to use it for square.

As for speed, the problem is that algorithm is inefficient.
For every point in one image you iterate over all points in other image, and so you're doing about n^2 operations (the complexity is O(N^2)). It is possible to speed up if you do spatial subdivision / "divide and conquer" style algorithm. Such algorithms can work in O(N*log(N)) which is much faster.

This topic is closed to new replies.

Advertisement