2

This problem comes from function getRectSubPix_8u32f in OpenCV. Basically, the target is to interpolate following pixel's intensity(denote as I(a,b)): enter image description here

but what puzzled me was the code snippet:

    float a = center.x - ip.x;
    float b = center.y - ip.y;
    a = MAX(a,0.0001f);

Why manually setting a floor 0.0001 here? To my understanding, intensity of p should be I(0,0) if p is exactly located at (0,0). So what is the material thought here? And why not set a floor for b?

Finley
  • 795
  • 1
  • 8
  • 26
  • they divide by `a` when calculating `s` so `a` must not be `0`. – Alan Birtles Jan 14 '19 at 08:05
  • @AlanBirtles, if the `div-by-zero` is the problem, then it should have been `MAX(a,1.0f)`, as division by 1 would return what we started from. With `0.0001f`, we get something `10000 times` larger now. – Duck Dodgers Jan 14 '19 at 08:38
  • @JoeyMallone not necessarily, the code is doing some kind of funky interpolation. the value of `s` isn't used directly and is used to calculate `prev` instead. – Alan Birtles Jan 14 '19 at 10:29
  • @AlanBirtles Hi, is it viable to replace `0.0001` with [`FLT_EPSILON`](http://www.cplusplus.com/reference/cfloat/)?because I think it will lessen the discrepancy as much as possible. – Finley Jan 14 '19 at 14:39
  • No idea, you are probably better off asking on the OpenCV developer mailing lists, I'm just guessing based on looking at the code – Alan Birtles Jan 14 '19 at 15:42

0 Answers0