Ask Your Question
0

What means NaN when using minMaxLox

asked 2017-06-17 19:51:00 -0600

waschbaer gravatar image

Hi,

I am wondering what is the meaning of NaN when using minMaxLoc, is NaN means negativ infinity, or positive infinity, or it is just not a number and will be ignored automatically?

Best, waschbaer

edit retag flag offensive close merge delete

Comments

2

If a number is equal to NaN It means that you have problem. Processing NaN is dangerous.

Better way is to insert some test in your algorithm to process indeterminate form.

LBerger gravatar imageLBerger ( 2017-06-18 02:00:58 -0600 )edit
1

Thank you.

waschbaer gravatar imagewaschbaer ( 2017-06-18 10:36:02 -0600 )edit

1 answer

Sort by » oldest newest most voted
2

answered 2017-06-18 02:20:58 -0600

berak gravatar image

updated 2017-06-18 02:23:01 -0600

unfortunately, nanand ìnfare the result of "undefined behaviour", and will just get propagated as is.

// let's make one :)
float inf = 1.0/0.0;
cerr << inf << endl;
float nan = 0.0*inf;
cerr << nan << endl;

from here:

General note about OpenCV implementations: Using of NaN values

will provide undefined behavior and should be avoided if there is no special NaN-related note in function/algorithm documentation.

to find out, if your Mat contains NaN's, compare it to itself:

 Mat m = ...
 Mat mask = (m != m);
 int numNaNs = countNonZero(mask);

if you find any, you should remove them, using patchNaNs() before the next step of your algorithm.

edit flag offensive delete link more

Comments

1

Thank you berak.

waschbaer gravatar imagewaschbaer ( 2017-06-18 10:36:10 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-06-17 19:51:00 -0600

Seen: 2,108 times

Last updated: Jun 18 '17