 # Rationale behind trueEdmHeight function

Hello! I have been reading the MaximumFinder code for some inspiration, and found the `trueEdmHeight` function (I also report it below for convenience). I was wondering if someone could provide a bit of insight on the rationale behind it, especially these bits:

``````For simplicity, we don't care about the Sqrt(5) distance here although this would be more accurate
``````
``````float trueH = v + 0.5f*SQRT2;           //true height can never by higher than this
``````
``````if (v>=v1 && v>=v2) {
ridgeOrMax = true;
h = (v1 + v2)/2;
} else {
h = Math.min(v1, v2);
}
h += (d%2==0) ? 1 : SQRT2;          //in diagonal directions, distance is sqrt2
``````

Also, I do not understand why the value is changed if the point of interest is a ridge or max in any direction, but its value is replaced by the largest trueH, which might be from a direction where the point is not a ridge/max. Or maybe this scenario is actually not possible and I am missing the whole point?

Sorry for the naive question(s). I am particularly interested in understanding this as it looks like a great improvement when using float EDM (the number of local maxima is nicely reduced, at least in my study cases).

Cheers 