|
58 | 58 | #endif
|
59 | 59 | #endif
|
60 | 60 |
|
| 61 | +#if defined(_MSC_VER) |
| 62 | +# pragma warning(disable:4702) // unreachable code |
| 63 | +#endif |
| 64 | + |
61 | 65 | namespace cv
|
62 | 66 | {
|
63 | 67 | namespace text
|
@@ -1319,150 +1323,6 @@ void computeNMChannels(InputArray _src, CV_OUT OutputArrayOfArrays _channels, in
|
1319 | 1323 | /* -------------------------------- ER Grouping Algorithm -----------------------------*/
|
1320 | 1324 | /* ------------------------------------------------------------------------------------*/
|
1321 | 1325 |
|
1322 |
| - |
1323 |
| -/* NFA approximation functions */ |
1324 |
| - |
1325 |
| -// ln(10) |
1326 |
| -#ifndef M_LN10 |
1327 |
| -#define M_LN10 2.30258509299404568401799145468436421 |
1328 |
| -#endif |
1329 |
| -// Doubles relative error factor |
1330 |
| -#define RELATIVE_ERROR_FACTOR 100.0 |
1331 |
| - |
1332 |
| -// Compare doubles by relative error. |
1333 |
| -static int double_equal(double a, double b) |
1334 |
| -{ |
1335 |
| - double abs_diff,aa,bb,abs_max; |
1336 |
| - |
1337 |
| - /* trivial case */ |
1338 |
| - if( a == b ) return true; |
1339 |
| - |
1340 |
| - abs_diff = fabs(a-b); |
1341 |
| - aa = fabs(a); |
1342 |
| - bb = fabs(b); |
1343 |
| - abs_max = aa > bb ? aa : bb; |
1344 |
| - |
1345 |
| - /* DBL_MIN is the smallest normalized number, thus, the smallest |
1346 |
| - number whose relative error is bounded by DBL_EPSILON. For |
1347 |
| - smaller numbers, the same quantization steps as for DBL_MIN |
1348 |
| - are used. Then, for smaller numbers, a meaningful "relative" |
1349 |
| - error should be computed by dividing the difference by DBL_MIN. */ |
1350 |
| - if( abs_max < DBL_MIN ) abs_max = DBL_MIN; |
1351 |
| - |
1352 |
| - /* equal if relative error <= factor x eps */ |
1353 |
| - return (abs_diff / abs_max) <= (RELATIVE_ERROR_FACTOR * DBL_EPSILON); |
1354 |
| -} |
1355 |
| - |
1356 |
| - |
1357 |
| -/* |
1358 |
| - Computes the natural logarithm of the absolute value of |
1359 |
| - the gamma function of x using the Lanczos approximation. |
1360 |
| - See http://www.rskey.org/gamma.htm |
1361 |
| -*/ |
1362 |
| -static double log_gamma_lanczos(double x) |
1363 |
| -{ |
1364 |
| - static double q[7] = { 75122.6331530, 80916.6278952, 36308.2951477, |
1365 |
| - 8687.24529705, 1168.92649479, 83.8676043424, |
1366 |
| - 2.50662827511 }; |
1367 |
| - double a = (x+0.5) * log(x+5.5) - (x+5.5); |
1368 |
| - double b = 0.0; |
1369 |
| - int n; |
1370 |
| - |
1371 |
| - for(n=0;n<7;n++) |
1372 |
| - { |
1373 |
| - a -= log( x + (double) n ); |
1374 |
| - b += q[n] * pow( x, (double) n ); |
1375 |
| - } |
1376 |
| - return a + log(b); |
1377 |
| -} |
1378 |
| - |
1379 |
| -/* |
1380 |
| - Computes the natural logarithm of the absolute value of |
1381 |
| - the gamma function of x using Windschitl method. |
1382 |
| - See http://www.rskey.org/gamma.htm |
1383 |
| -*/ |
1384 |
| -static double log_gamma_windschitl(double x) |
1385 |
| -{ |
1386 |
| - return 0.918938533204673 + (x-0.5)*log(x) - x |
1387 |
| - + 0.5*x*log( x*sinh(1/x) + 1/(810.0*pow(x,6.0)) ); |
1388 |
| -} |
1389 |
| - |
1390 |
| -/* |
1391 |
| - Computes the natural logarithm of the absolute value of |
1392 |
| - the gamma function of x. When x>15 use log_gamma_windschitl(), |
1393 |
| - otherwise use log_gamma_lanczos(). |
1394 |
| -*/ |
1395 |
| -#define log_gamma(x) ((x)>15.0?log_gamma_windschitl(x):log_gamma_lanczos(x)) |
1396 |
| - |
1397 |
| -// Size of the table to store already computed inverse values. |
1398 |
| -#define TABSIZE 100000 |
1399 |
| - |
1400 |
| -/* |
1401 |
| - Computes -log10(NFA). |
1402 |
| - NFA stands for Number of False Alarms: |
1403 |
| -*/ |
1404 |
| -static double NFA(int n, int k, double p, double logNT) |
1405 |
| -{ |
1406 |
| - static double inv[TABSIZE]; /* table to keep computed inverse values */ |
1407 |
| - double tolerance = 0.1; /* an error of 10% in the result is accepted */ |
1408 |
| - double log1term,term,bin_term,mult_term,bin_tail,err,p_term; |
1409 |
| - int i; |
1410 |
| - |
1411 |
| - if (p<=0) |
1412 |
| - p = std::numeric_limits<double>::min(); |
1413 |
| - if (p>=1) |
1414 |
| - p = 1 - std::numeric_limits<double>::epsilon(); |
1415 |
| - |
1416 |
| - /* check parameters */ |
1417 |
| - if( n<0 || k<0 || k>n || p<=0.0 || p>=1.0 ) |
1418 |
| - { |
1419 |
| - CV_Error(Error::StsBadArg, "erGrouping wrong n, k or p values in NFA call!"); |
1420 |
| - } |
1421 |
| - |
1422 |
| - /* trivial cases */ |
1423 |
| - if( n==0 || k==0 ) return -logNT; |
1424 |
| - if( n==k ) return -logNT - (double) n * log10(p); |
1425 |
| - |
1426 |
| - /* probability term */ |
1427 |
| - p_term = p / (1.0-p); |
1428 |
| - |
1429 |
| - /* compute the first term of the series */ |
1430 |
| - log1term = log_gamma( (double) n + 1.0 ) - log_gamma( (double) k + 1.0 ) |
1431 |
| - - log_gamma( (double) (n-k) + 1.0 ) |
1432 |
| - + (double) k * log(p) + (double) (n-k) * log(1.0-p); |
1433 |
| - term = exp(log1term); |
1434 |
| - |
1435 |
| - /* in some cases no more computations are needed */ |
1436 |
| - if( double_equal(term,0.0) ) /* the first term is almost zero */ |
1437 |
| - { |
1438 |
| - if( (double) k > (double) n * p ) /* at begin or end of the tail? */ |
1439 |
| - return -log1term / M_LN10 - logNT; /* end: use just the first term */ |
1440 |
| - else |
1441 |
| - return -logNT; /* begin: the tail is roughly 1 */ |
1442 |
| - } |
1443 |
| - |
1444 |
| - /* compute more terms if needed */ |
1445 |
| - bin_tail = term; |
1446 |
| - for(i=k+1;i<=n;i++) |
1447 |
| - { |
1448 |
| - bin_term = (double) (n-i+1) * ( i<TABSIZE ? |
1449 |
| - ( inv[i]!=0.0 ? inv[i] : ( inv[i] = 1.0 / (double) i ) ) : |
1450 |
| - 1.0 / (double) i ); |
1451 |
| - |
1452 |
| - mult_term = bin_term * p_term; |
1453 |
| - term *= mult_term; |
1454 |
| - bin_tail += term; |
1455 |
| - if(bin_term<1.0) |
1456 |
| - { |
1457 |
| - err = term * ( ( 1.0 - pow( mult_term, (double) (n-i+1) ) ) / |
1458 |
| - (1.0-mult_term) - 1.0 ); |
1459 |
| - if( err < tolerance * fabs(-log10(bin_tail)-logNT) * bin_tail ) break; |
1460 |
| - } |
1461 |
| - } |
1462 |
| - return -log10(bin_tail) - logNT; |
1463 |
| -} |
1464 |
| - |
1465 |
| - |
1466 | 1326 | // Minibox : smallest enclosing box of a set of n points in d dimensions
|
1467 | 1327 |
|
1468 | 1328 | class Minibox {
|
@@ -2480,8 +2340,8 @@ void MaxMeaningfulClustering::build_merge_info(double *Z, double *X, int N, int
|
2480 | 2340 |
|
2481 | 2341 | int MaxMeaningfulClustering::nfa(float sigma, int k, int N)
|
2482 | 2342 | {
|
2483 |
| - // use an approximation for the nfa calculations (faster) |
2484 |
| - return -1*(int)NFA( N, k, (double) sigma, 0); |
| 2343 | + CV_UNUSED(sigma); CV_UNUSED(k); CV_UNUSED(N); |
| 2344 | + CV_Error(Error::StsNotImplemented, "text: NFA computation code has been removed due license conflict. Details: https://github.com/opencv/opencv_contrib/issues/2235"); |
2485 | 2345 | }
|
2486 | 2346 |
|
2487 | 2347 |
|
|
0 commit comments