Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem about the source codes of otsu-threshold

The codes from the files thresh.cpp, the function name is getThreshVal_Otsu_8u

if( std::min(q1,q2) < FLT_EPSILON || 
            std::max(q1,q2) > 1. - FLT_EPSILON )
            continue;

As far as I know,

q1 + q2 = 1--(1)
q1 = 1 - q2--(2)
q2 = 1 - q1--(3)

That means if

q1 < FLT_EPSILON

then 1 - q1 will satisfy

1 - q1 > 1 - FLT_EPSILON

In other words, if std::min(q1,q2) < FLT_EPSILON, then std::max(q1,q2) > 1. - FLT_EPSILON should satisfy too.So why do the codes need to do double check? Why don't just use

if( std::min(q1,q2) < FLT_EPSILON)
                continue;

Precison problem?

Problem about the source codes of otsu-threshold

The codes from the files thresh.cpp, the function name is getThreshVal_Otsu_8u

if( std::min(q1,q2) < FLT_EPSILON || 
            std::max(q1,q2) > 1. - FLT_EPSILON )
            continue;

As far as I know,

q1 + q2 = 1--(1)
q1 = 1 - q2--(2)
q2 = 1 - q1--(3)

That means if

q1 < FLT_EPSILON

then 1 - q1 will satisfy

1 - q1 > 1 - FLT_EPSILON

In other words, if std::min(q1,q2) < FLT_EPSILON, then std::max(q1,q2) > 1. - FLT_EPSILON should satisfy too.So why do the codes need to do double check? Why don't just use

if( std::min(q1,q2) < FLT_EPSILON)
                continue;

Precison problem?

click to hide/show revision 3
retagged

updated 2013-09-19 03:15:28 -0600

berak gravatar image

Problem about the source codes of otsu-threshold

The codes from the files thresh.cpp, the function name is getThreshVal_Otsu_8u

if( std::min(q1,q2) < FLT_EPSILON || 
            std::max(q1,q2) > 1. - FLT_EPSILON )
            continue;

As far as I know,

q1 + q2 = 1--(1)
q1 = 1 - q2--(2)
q2 = 1 - q1--(3)

That means if

q1 < FLT_EPSILON

then 1 - q1 will satisfy

1 - q1 > 1 - FLT_EPSILON

In other words, if std::min(q1,q2) < FLT_EPSILON, then std::max(q1,q2) > 1. - FLT_EPSILON should satisfy too.So why do the codes need to do double check? Why don't just use

if( std::min(q1,q2) < FLT_EPSILON)
                continue;