Ask Your Question

What means NaN when using minMaxLox

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

waschbaer gravatar image


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



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 -0500 )edit

Thank you.

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

1 answer

Sort by » oldest newest most voted

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

berak gravatar image

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

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



Thank you berak.

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

Question Tools

1 follower


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

Seen: 1,466 times

Last updated: Jun 18 '17