SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compare.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
67 
68 
76 #ifndef SLIP_COMPARE_HPP
77 #define SLIP_COMPARE_HPP
78 
79 
80 #include <algorithm>
81 #include <numeric>
82 #include <cassert>
83 #include <cmath>
84 #include <functional>
85 #include "Array.hpp"
86 #include "Array2d.hpp"
87 #include "Vector.hpp"
88 #include "stl_algo_ext.hpp"
89 #include "statistics.hpp"
90 
91 namespace slip
92 {
93 
94 
95 
97  /* @{ */
98 
99 
145  template<typename Real,
146  typename InputIterator1,
147  typename InputIterator2,
148  typename BinaryFunctor>
149  inline
150  Real distance(InputIterator1 first1,
151  InputIterator1 last1,
152  InputIterator2 first2,
153  BinaryFunctor distance)
154  {
155  assert(first1 != last1);
156  Real init = Real(0);
157  for (; first1 != last1; ++first1, ++first2)
158  {
159  init += distance(*first1,*first2);
160  }
161  return init;
162  }
163 
205 template<typename Real,
206  typename InputIterator1,
207  typename InputIterator2,
208  typename BinaryFunctor,
209  typename MaskIterator>
210  inline
211  Real distance_mask(InputIterator1 first1,
212  InputIterator1 last1,
213  MaskIterator mask_first,
214  InputIterator2 first2,
215  BinaryFunctor distance,
216  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1)
217 )
218  {
219  assert(first1 != last1);
220  Real init = Real(0);
221  for (; first1 != last1; ++first1, ++first2,++mask_first)
222  {
223  if(*mask_first == value)
224  {
225  init += distance(*first1,*first2);
226  }
227  }
228  return init;
229  }
230 
231 
274 template<typename Real,
275  typename InputIterator1,
276  typename InputIterator2,
277  typename BinaryFunctor,
278  typename Predicate>
279 
280  Real distance_if(InputIterator1 first1, InputIterator1 last1,
281  InputIterator2 first2,
282  BinaryFunctor distance,
283  Predicate pred)
284  {
285  assert(first1 != last1);
286  Real init = Real(0);
287  for (; first1 != last1; ++first1, ++first2)
288  {
289  if(pred(*first1))
290  {
291  init += distance(*first1,*first2);
292  }
293  }
294  return init;
295  }
296 
297  /* @} */
298 
300  /* @{ */
337  template<typename InputIterator1,
338  typename InputIterator2,
339  typename OutputIterator,
340  typename BinaryFunctor>
341  inline
342  void distance(InputIterator1 first1,
343  InputIterator1 last1,
344  InputIterator2 first2,
345  OutputIterator result,
346  BinaryFunctor distance)
347  {
348  assert(first1 != last1);
349  std::transform(first1,last1,first2,result,distance);
350  }
351 
396  template<typename InputIterator1,
397  typename InputIterator2,
398  typename MaskIterator,
399  typename OutputIterator,
400  typename BinaryFunctor>
401  inline
402  void distance_mask(InputIterator1 first1,
403  InputIterator1 last1,
404  MaskIterator mask_first,
405  InputIterator2 first2,
406  OutputIterator result,
407  BinaryFunctor distance,
408  typename std::iterator_traits<MaskIterator>::value_type
409  value=typename std::iterator_traits<MaskIterator>::value_type(1))
410  {
411  assert(first1 != last1);
412  slip::transform_mask_bin(first1,last1,mask_first,first2,result,distance,value);
413  }
414 
461  template<typename _InputIterator1,
462  typename _InputIterator2,
463  typename _OutputIterator,
464  typename _BinaryOperation,
465  typename _Predicate>
466  inline
467  void
468  distance_if(_InputIterator1 first1, _InputIterator1 last1,
469  _InputIterator2 first2,
470  _OutputIterator result,
471  _BinaryOperation distance,
472  _Predicate pred)
473  {
474  assert(first1 != last1);
475  slip::transform_if(first1,last1,first2,result,distance,pred);
476  }
477 
478  /* @} */
479 
481  /* @{ */
505  template< typename Value_T, typename InputIterator1, typename InputIterator2>
506  inline
507  Value_T mean_square_diff(InputIterator1 first1,
508  InputIterator1 last1,
509  InputIterator2 first2)
510  {
511  assert(first1 != last1);
512  Value_T init = Value_T(0);
513  Value_T count = Value_T(0);
514  for (; first1 != last1; ++first1, ++first2)
515  {
516  init = init + (*first1 - *first2) * (*first1 - *first2);
517  count += Value_T(1);
518  }
519  return init/count;
520  }
521 
550 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
551  inline
552 
553 Real mean_square_diff_mask(InputIterator1 first1,
554  InputIterator1 last1,
555  MaskIterator mask_first,
556  InputIterator2 first2,
557  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
558 
559 {
560  assert(first1 != last1);
561  Real init = Real(0);
562  Real count = Real(0);
563  for (; first1 != last1; ++first1, ++first2,++mask_first)
564  {
565  if(*mask_first == value)
566  {
567  init = init + (*first1 - *first2) * (*first1 - *first2);
568  count += Real(1);
569  }
570  }
571  return init/count;
572  }
573 
574 
605 template<typename Real,
606  typename InputIterator1,
607  typename InputIterator2,
608  typename Predicate>
609 
610  Real mean_square_diff_if(InputIterator1 first1, InputIterator1 last1,
611  InputIterator2 first2,
612  Predicate pred)
613 {
614  assert(first1 != last1);
615  Real init = Real(0);
616  Real count = Real(0);
617  for (; first1 != last1; ++first1, ++first2)
618  {
619  if(pred(*first1))
620  {
621  init = init + (*first1 - *first2) * (*first1 - *first2);
622  count += Real(1);
623  }
624  }
625  return init/count;
626  }
627 
651  template<typename Value_T, typename InputIterator1, typename InputIterator2>
652  inline
653  Value_T mean_abs_diff(InputIterator1 first1,
654  InputIterator1 last1,
655  InputIterator2 first2)
656  {
657  assert(first1 != last1);
658  Value_T init = Value_T(0);
659  Value_T count = Value_T(0);
660  for (; first1 != last1; ++first1, ++first2)
661  {
662  init = init + std::abs(*first1 - *first2);
663  count += Value_T(1);
664  }
665  return init/count;
666  }
667 
696 template<typename Value_T, typename InputIterator1, typename InputIterator2,typename MaskIterator>
697  inline
698 Value_T mean_abs_diff_mask(InputIterator1 first1,
699  InputIterator1 last1,
700  MaskIterator mask_first,
701  InputIterator2 first2,
702  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
703 
704 {
705  assert(first1 != last1);
706  Value_T init = Value_T(0);
707  Value_T count = Value_T(0);
708  for (; first1 != last1; ++first1, ++first2,++mask_first)
709  {
710  if(*mask_first == value)
711  {
712  init = init + std::abs(*first1 - *first2);
713  count += Value_T(1);
714  }
715  }
716  return init/count;
717  }
718 
719 
720 
751 template<typename Real,
752  typename InputIterator1,
753  typename InputIterator2,
754  typename Predicate>
755 
756  Real mean_abs_diff_if(InputIterator1 first1, InputIterator1 last1,
757  InputIterator2 first2,
758  Predicate pred)
759 {
760  assert(first1 != last1);
761  Real init = Real(0);
762  Real count = Real(0);
763  for (; first1 != last1; ++first1, ++first2)
764  {
765  if(pred(*first1))
766  {
767  init = init + std::abs(*first1 - *first2);
768  count += Real(1);
769  }
770  }
771  return init/count;
772  }
773 
797  template<typename Real, typename InputIterator1, typename InputIterator2>
798  inline
799  Real snr(InputIterator1 first1,
800  InputIterator1 last1,
801  InputIterator2 first2)
802  {
803  assert(first1 != last1);
804 
805  Real s_variance = Real(0);
806  Real sb_variance = Real(0);
807 
808  for (; first1 != last1; ++first1, ++first2)
809  {
810  s_variance = s_variance + ((*first1) * (*first1));
811  sb_variance = sb_variance + (*first1 - *first2) * (*first1 - *first2);
812  }
813  return (s_variance / sb_variance);
814  }
815 
843 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
844  inline
845  Real snr_mask(InputIterator1 first1,
846  InputIterator1 last1,
847  MaskIterator mask_first,
848  InputIterator2 first2,
849  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
850 
851 {
852  assert(first1 != last1);
853 
854  Real s_variance = Real(0);
855  Real sb_variance = Real(0);
856 
857  for (; first1 != last1; ++first1, ++first2,++mask_first)
858  {
859  if(*mask_first == value)
860  {
861  s_variance = s_variance + ((*first1) * (*first1));
862  sb_variance = sb_variance + (*first1 - *first2) * (*first1 - *first2);
863  }
864  }
865  return (s_variance / sb_variance);
866  }
867 
898 template<typename Real,
899  typename InputIterator1,
900  typename InputIterator2,
901  typename Predicate>
902 
903  Real snr_if(InputIterator1 first1, InputIterator1 last1,
904  InputIterator2 first2,
905  Predicate pred)
906 {
907  assert(first1 != last1);
908 
909  Real s_variance = Real(0);
910  Real sb_variance = Real(0);
911 
912  for (; first1 != last1; ++first1, ++first2)
913  {
914  if(pred(*first1))
915  {
916  s_variance = s_variance + ((*first1) * (*first1));
917  sb_variance = sb_variance + (*first1 - *first2) * (*first1 - *first2);
918  }
919  }
920  return (s_variance / sb_variance);
921  }
922 
946  template<typename Real, typename InputIterator1, typename InputIterator2>
947  inline
948  Real snr_dB(InputIterator1 first1,
949  InputIterator1 last1,
950  InputIterator2 first2)
951  {
952  return 20.0 * std::log10(slip::snr<Real>(first1,last1,first2));
953  }
954 
955 
982 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
983  inline
984  Real snr_dB_mask(InputIterator1 first1,
985  InputIterator1 last1,
986  MaskIterator mask_first,
987  InputIterator2 first2,
988  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
989 {
990  return 20.0 * std::log10(slip::snr_mask<Real>(first1,last1,mask_first,first2,value));
991 }
1022 template<typename Real,
1023  typename InputIterator1,
1024  typename InputIterator2,
1025  typename Predicate>
1026 
1027  Real snr_dB_if(InputIterator1 first1, InputIterator1 last1,
1028  InputIterator2 first2,
1029  Predicate pred)
1030 {
1031 return 20.0 * std::log10(slip::snr_if<Real>(first1,last1,first2,pred));
1032 }
1033 
1057  template<typename Real, typename InputIterator1, typename InputIterator2>
1058  inline
1059  Real L22_distance(InputIterator1 first1,
1060  InputIterator1 last1,
1061  InputIterator2 first2)
1062  {
1063  assert(first1 != last1);
1064  Real init = Real(0);
1065  for (; first1 != last1; ++first1, ++first2)
1066  {
1067  init += (*first1 - *first2) * (*first1 - *first2);
1068  }
1069  return init;
1070  }
1099 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
1100  inline
1101  Real L22_distance_mask(InputIterator1 first1,
1102  InputIterator1 last1,
1103  MaskIterator mask_first,
1104  InputIterator2 first2,
1105  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1)
1106  )
1107  {
1108  assert(first1 != last1);
1109  Real init = Real(0);
1110  for (; first1 != last1; ++first1, ++first2,++mask_first)
1111  {
1112  if(*mask_first == value)
1113  {
1114  init += (*first1 - *first2) * (*first1 - *first2);
1115  }
1116  }
1117  return init;
1118  }
1119 
1120 
1151 template<typename Real,
1152  typename InputIterator1,
1153  typename InputIterator2,
1154  typename Predicate>
1155 
1156  Real L22_distance_if(InputIterator1 first1, InputIterator1 last1,
1157  InputIterator2 first2,
1158  Predicate pred)
1159  {
1160  assert(first1 != last1);
1161  Real init = Real(0);
1162  for (; first1 != last1; ++first1, ++first2)
1163  {
1164  if(pred(*first1))
1165  {
1166  init += (*first1 - *first2) * (*first1 - *first2);
1167  }
1168  }
1169  return init;
1170  }
1171 
1195  template<typename Real, typename InputIterator1, typename InputIterator2>
1196  inline
1197  Real L2_distance(InputIterator1 first1,
1198  InputIterator1 last1,
1199  InputIterator2 first2)
1200  {
1201  return std::sqrt(slip::L22_distance<Real>(first1,last1,first2));
1202  }
1203 
1204 
1232 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
1233  inline
1234  Real L2_distance_mask(InputIterator1 first1,
1235  InputIterator1 last1,
1236  MaskIterator mask_first,
1237  InputIterator2 first2,
1238 
1239  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
1240  {
1241  return std::sqrt(slip::L22_distance_mask<Real>(first1,last1,mask_first,first2,value));
1242  }
1243 
1244 
1245 
1276 template<typename Real,
1277  typename InputIterator1,
1278  typename InputIterator2,
1279  typename Predicate>
1280 
1281  Real L2_distance_if(InputIterator1 first1, InputIterator1 last1,
1282  InputIterator2 first2,
1283  Predicate pred)
1284 {
1285  return std::sqrt(slip::L22_distance_if<Real>(first1,last1,first2,pred));
1286  }
1287 
1311  template<typename Real, typename InputIterator1, typename InputIterator2>
1312  inline
1313  Real L1_distance(InputIterator1 first1,
1314  InputIterator1 last1,
1315  InputIterator2 first2)
1316  {
1317  assert(first1 != last1);
1318  Real init = Real(0);
1319  for (; first1 != last1; ++first1, ++first2)
1320  {
1321  init += std::abs(*first1 - *first2) ;
1322  }
1323  return init;
1324  }
1325 
1353 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
1354  inline
1355  Real L1_distance_mask(InputIterator1 first1,
1356  InputIterator1 last1,
1357  MaskIterator mask_first,
1358  InputIterator2 first2,
1359  typename std::iterator_traits<MaskIterator>::value_type value=typename
1360  std::iterator_traits<MaskIterator>::value_type(1))
1361  {
1362  assert(first1 != last1);
1363  Real init = Real(0);
1364  for (; first1 != last1; ++first1, ++first2,++mask_first)
1365  {
1366  if(*mask_first == value)
1367  {
1368  init += std::abs(*first1 - *first2) ;
1369  }
1370  }
1371  return init;
1372  }
1373 
1374 
1375 
1407 template<typename Real,
1408  typename InputIterator1,
1409  typename InputIterator2,
1410  typename Predicate>
1411 
1412  Real L1_distance_if(InputIterator1 first1, InputIterator1 last1,
1413  InputIterator2 first2,
1414  Predicate pred)
1415  {
1416  assert(first1 != last1);
1417  Real init = Real(0);
1418  for (; first1 != last1; ++first1, ++first2)
1419  {
1420  if(pred(*first1))
1421  {
1422  init += std::abs(*first1 - *first2) ;
1423  }
1424  }
1425  return init;
1426  }
1427 
1428 
1455  template<typename Real, typename InputIterator1, typename InputIterator2>
1456  inline
1457  Real Minkowski_distance(const std::size_t n,
1458  InputIterator1 first1,
1459  InputIterator1 last1,
1460  InputIterator2 first2)
1461  {
1462  assert(first1 != last1);
1463  assert(n > 0);
1464  Real init = Real(0);
1465  Real tmp = Real(1);
1466  Real tmp2 = Real(1);
1467 
1468  for (; first1 != last1; ++first1, ++first2)
1469  {
1470  tmp = std::abs(*first1 - *first2);
1471  tmp2 = Real(1);
1472  for (std::size_t i = 0; i < n; ++i){
1473  tmp2 *= tmp;
1474  }
1475 
1476  init += tmp2 ;
1477  }
1478  return std::pow(init,1/Real(n));
1479  }
1510 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
1511  inline
1512 Real Minkowski_distance_mask(const std::size_t n,
1513  InputIterator1 first1,
1514  InputIterator1 last1,
1515  MaskIterator mask_first,
1516  InputIterator2 first2,
1517  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
1518 
1519 {
1520  assert(first1 != last1);
1521  assert(n > 0);
1522  Real init = Real(0);
1523  Real tmp = Real(1);
1524  Real tmp2 = Real(1);
1525 
1526  for (; first1 != last1; ++first1, ++first2,++mask_first)
1527  {
1528  if(*mask_first == value)
1529  {
1530  tmp = std::abs(*first1 - *first2);
1531  tmp2 = Real(1);
1532  for (std::size_t i = 0; i < n; ++i)
1533  {
1534  tmp2 *= tmp;
1535  }
1536 
1537  init += tmp2 ;
1538  }
1539  }
1540  return std::pow(init,1/Real(n));
1541  }
1542 
1543 
1544 
1576 template<typename Real,
1577  typename InputIterator1,
1578  typename InputIterator2,
1579  typename Predicate>
1580 inline
1581 Real Minkowski_distance_if(const std::size_t n,
1582  InputIterator1 first1,
1583  InputIterator1 last1,
1584  InputIterator2 first2,
1585  Predicate pred)
1586 {
1587  assert(first1 != last1);
1588  assert(n > 0);
1589  Real init = Real(0);
1590  Real tmp = Real(1);
1591  Real tmp2 = Real(1);
1592 
1593  for (; first1 != last1; ++first1, ++first2)
1594  {
1595  if(pred(*first1))
1596  {
1597  tmp = std::abs(*first1 - *first2);
1598  tmp2 = Real(1);
1599  for (std::size_t i = 0; i < n; ++i)
1600  {
1601  tmp2 *= tmp;
1602  }
1603 
1604  init += tmp2 ;
1605  }
1606  }
1607  return std::pow(init,1/Real(n));
1608  }
1609 
1610 
1634  template<typename Real, typename InputIterator1, typename InputIterator2>
1635  inline
1636  Real Linf_distance(InputIterator1 first1,
1637  InputIterator1 last1,
1638  InputIterator2 first2)
1639  {
1640  assert(first1 != last1);
1641  Real init = Real(0);
1642  Real tmp = Real(0);
1643  for (; first1 != last1; ++first1, ++first2)
1644  {
1645  tmp = std::abs(*first1 - *first2);
1646  if (tmp > init) init = tmp;
1647  }
1648  return init;
1649  }
1677 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
1678  inline
1679  Real Linf_distance_mask(InputIterator1 first1,
1680  InputIterator1 last1,
1681  MaskIterator mask_first,
1682  InputIterator2 first2,
1683 
1684  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
1685 {
1686  assert(first1 != last1);
1687  Real init = Real(0);
1688  Real tmp = Real(0);
1689  for (; first1 != last1; ++first1, ++first2,++mask_first)
1690  {
1691  if(*mask_first == value)
1692  {
1693  tmp = std::abs(*first1 - *first2);
1694  if (tmp > init) init = tmp;
1695  }
1696  }
1697  return init;
1698  }
1699 
1730 template<typename Real,
1731  typename InputIterator1,
1732  typename InputIterator2,
1733  typename Predicate>
1734 
1735  Real Linf_distance_if(InputIterator1 first1, InputIterator1 last1,
1736  InputIterator2 first2,
1737  Predicate pred)
1738 {
1739  assert(first1 != last1);
1740  Real init = Real(0);
1741  Real tmp = Real(0);
1742  for (; first1 != last1; ++first1, ++first2)
1743  {
1744  if(pred(*first1))
1745  {
1746  tmp = std::abs(*first1 - *first2);
1747  if (tmp > init)
1748  {
1749  init = tmp;
1750  }
1751  }
1752  }
1753  return init;
1754 }
1778  template<typename Real, typename InputIterator1, typename InputIterator2>
1779  inline
1780  Real KullbackLeibler_distance(InputIterator1 first1,
1781  InputIterator1 last1,
1782  InputIterator2 first2)
1783  {
1784  assert(first1 != last1);
1785  Real init = Real(0);
1786  for (; first1 != last1; ++first1, ++first2)
1787  {
1788  init += (*first1) * log2((*first1) / (*first2));
1789  }
1790  return init;
1791  }
1792 
1821 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
1822  inline
1823 Real KullbackLeibler_distance_mask(InputIterator1 first1,
1824  InputIterator1 last1,
1825  MaskIterator mask_first,
1826  InputIterator2 first2,
1827  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
1828  {
1829  assert(first1 != last1);
1830  Real init = Real(0);
1831  for (; first1 != last1; ++first1, ++first2,++mask_first)
1832  {
1833  if(*mask_first == value)
1834  {
1835  init += (*first1) * log2((*first1) / (*first2));
1836  }
1837  }
1838  return init;
1839  }
1840 
1841 
1842 
1873 template<typename Real,
1874  typename InputIterator1,
1875  typename InputIterator2,
1876  typename Predicate>
1877  inline
1878 Real KullbackLeibler_distance_if(InputIterator1 first1,
1879  InputIterator1 last1,
1880  InputIterator2 first2,
1881  Predicate pred)
1882 {
1883 assert(first1 != last1);
1884  Real init = Real(0);
1885  for (; first1 != last1; ++first1, ++first2)
1886  {
1887  if(pred(*first1))
1888  {
1889  init += (*first1) * log2((*first1) / (*first2));
1890  }
1891  }
1892  return init;
1893 }
1894 
1895 
1919  template<typename Real, typename InputIterator1, typename InputIterator2>
1920  inline
1921  Real Chi2_distance(InputIterator1 first1,
1922  InputIterator1 last1,
1923  InputIterator2 first2)
1924  {
1925  assert(first1 != last1);
1926  Real init = Real(0);
1927  for (; first1 != last1; ++first1, ++first2)
1928  {
1929  init += (*first1 - *first2) * (*first1 - *first2) / (*first1);
1930  }
1931 
1932  return init;
1933  }
1962 template<typename Real, typename InputIterator1, typename InputIterator2,typename MaskIterator>
1963  inline
1964 Real Chi2_distance_mask(InputIterator1 first1,
1965  InputIterator1 last1,
1966  MaskIterator mask_first,
1967  InputIterator2 first2,
1968  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1))
1969 
1970 {
1971  assert(first1 != last1);
1972  Real init = Real(0);
1973  for (; first1 != last1; ++first1, ++first2,++mask_first)
1974  {
1975  if(*mask_first == value)
1976  {
1977  init += (*first1 - *first2) * (*first1 - *first2) / (*first1);
1978  }
1979  }
1980 
1981  return init;
1982  }
1983 
2015 template<typename Real,
2016  typename InputIterator1,
2017  typename InputIterator2,
2018  typename Predicate>
2019  inline
2020 Real Chi2_distance_if(InputIterator1 first1,
2021  InputIterator1 last1,
2022  InputIterator2 first2,
2023  Predicate pred)
2024 {
2025  assert(first1 != last1);
2026  Real init = Real(0);
2027  for (; first1 != last1; ++first1, ++first2)
2028  {
2029  if(pred(*first1))
2030  {
2031  init += (*first1 - *first2) * (*first1 - *first2) / (*first1);
2032  }
2033  }
2034 
2035  return init;
2036  }
2037 
2038 
2039 
2063  template< typename Value_T,
2064  typename InputIterator1,
2065  typename InputIterator2>
2066  inline
2067  Value_T psnr(InputIterator1 first1,
2068  InputIterator1 last1,
2069  InputIterator2 first2,
2070  Value_T d = static_cast<Value_T>(255))
2071 
2072  {
2073  Value_T d_carre = d*d;
2074  Value_T EQM = slip::mean_square_diff<Value_T>(first1, last1, first2);
2075  Value_T result = static_cast<Value_T>(10) * std::log10(d_carre/EQM);
2076  return result;
2077 
2078  }
2079 
2107  template< typename Value_T,
2108  typename InputIterator1,
2109  typename InputIterator2,
2110  typename MaskIterator>
2111  inline
2112  Value_T psnr_mask(InputIterator1 first1,
2113  InputIterator1 last1,
2114  MaskIterator mask1,
2115  InputIterator2 first2,
2116  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1),
2117  Value_T d = static_cast<Value_T>(255))
2118  {
2119  Value_T d_carre = d*d;
2120 
2121  Value_T EQM = slip::mean_square_diff_mask<Value_T>(first1, last1, mask1,first2, value);
2122 
2123  Value_T result = static_cast<Value_T>(10) * std::log10(d_carre/EQM);
2124  return result;
2125 
2126  }
2127 
2158  template<typename Value_T,
2159  typename InputIterator1,
2160  typename InputIterator2,
2161  typename Predicate>
2162  inline
2163  Value_T psnr_if(InputIterator1 first1, InputIterator1 last1,
2164  InputIterator2 first2,
2165  Predicate pred,
2166  Value_T d = static_cast<Value_T>(255))
2167  {
2168 
2169  Value_T d_carre = d*d;
2170 
2171  Value_T EQM = slip::mean_square_diff_if<Value_T>(first1, last1, first2, pred);
2172 
2173  Value_T result = static_cast<Value_T>(10) * std::log10(d_carre/EQM);
2174  return result;
2175 
2176  }
2177 
2178 
2218  template<typename Real,
2219  typename InputIterator1,
2220  typename InputIterator2>
2221  inline
2222  Real SSIM(InputIterator1 first1,
2223  InputIterator1 last1,
2224  InputIterator2 first2,
2225  Real d = static_cast<Real>(255))
2226  {
2227  Real c1 = d*static_cast<Real>(0.01) * d*static_cast<Real>(0.01);
2228  Real c2 = d*static_cast<Real>(0.03) * d*static_cast<Real>(0.03);
2229  Real meanFirst1 = slip::mean<Real>(first1, last1);
2230  Real meanFirst2 = slip::mean<Real>(first2, first2 + (last1 - first1));
2231  Real varFirst1 = slip::variance(first1, last1, meanFirst1);
2232  Real varFirst2 = slip::variance(first2, first2 + (last1 - first1), meanFirst2);
2233  Real cov = slip::covariance(first1, last1, first2, meanFirst1, meanFirst2);
2234 
2235  return ((static_cast<Real>(2) * meanFirst1 * meanFirst2 + c1) * (static_cast<Real>(2) * cov + c2)) / (( meanFirst1 * meanFirst1 + meanFirst2 * meanFirst2 + c1) * (varFirst1 * varFirst1 + varFirst2 * varFirst2 + c2));
2236 
2237  }
2238 
2239 
2283  template<typename Real,
2284  typename InputIterator1,
2285  typename InputIterator2,
2286  typename MaskIterator>
2287  inline
2288  Real SSIM_mask(InputIterator1 first1,
2289  InputIterator1 last1,
2290  MaskIterator maskFirst,
2291  InputIterator2 first2,
2292  typename std::iterator_traits<MaskIterator>::value_type value=typename std::iterator_traits<MaskIterator>::value_type(1),
2293  Real d = static_cast<Real>(255) )
2294 
2295 
2296  {
2297 
2298  Real c1 = d*static_cast<Real>(0.01) * d*static_cast<Real>(0.01);
2299  Real c2 = d*static_cast<Real>(0.03) * d*static_cast<Real>(0.03);
2300 
2301  Real meanFirst1 = slip::mean_mask<Real>(first1, last1, maskFirst, value);
2302  Real meanFirst2 = slip::mean_mask<Real>(first2, first2 + (last1 - first1), maskFirst, value);
2303  Real varFirst1 = slip::variance_mask(first1, last1,
2304  maskFirst, meanFirst1, value);
2305  Real varFirst2 = slip::variance_mask(first2, first2 + (last1 - first1),
2306  maskFirst, meanFirst2, value);
2307  Real cov = slip::covariance_mask(first1, last1,
2308  first2,
2309  maskFirst,
2310  meanFirst1, meanFirst2, value);
2311 
2312  return ((static_cast<Real>(2) * meanFirst1 * meanFirst2 + c1) * (static_cast<Real>(2) * cov + c2)) / (( meanFirst1 * meanFirst1 + meanFirst2 * meanFirst2 + c1) * (varFirst1 * varFirst1 + varFirst2 * varFirst2 + c2));
2313 
2314  }
2315 
2362  template<typename Real,
2363  typename InputIterator1,
2364  typename InputIterator2,
2365  typename Predicate>
2366  inline
2367  Real SSIM_if(InputIterator1 first1,
2368  InputIterator1 last1,
2369  InputIterator2 first2,
2370  Predicate pred,
2371  Real d = 255)
2372  {
2373 
2374  Real c1 = d*static_cast<Real>(0.01) * d*static_cast<Real>(0.01);
2375  Real c2 = d*static_cast<Real>(0.03) * d*static_cast<Real>(0.03);
2376 
2377  Real meanFirst1 = slip::mean_if<Real>(first1, last1, pred);
2378  Real meanFirst2 = slip::mean_if<Real>(first2,first2 + (last1 - first1), pred);
2379  Real varFirst1 = slip::variance_if(first1, last1, meanFirst1, pred);
2380  Real varFirst2 = slip::variance_if(first2, first2 + (last1 - first1), meanFirst2, pred);
2381  Real cov = slip::covariance_if(first1, last1, first2, meanFirst1, meanFirst2, pred);
2382 
2383  return ((2 * meanFirst1 * meanFirst2 + c1) * (2 * cov + c2)) / (( meanFirst1 * meanFirst1 + meanFirst2 * meanFirst2 + c1) * (varFirst1 * varFirst1 + varFirst2 * varFirst2 + c2));
2384 
2385  }
2386 
2387 
2388 /* @} */
2389 
2390 
2392  /* @{ */
2393 
2404  template <class _Rp,class _Tp>
2405  struct L1_dist : public std::binary_function<_Rp, _Tp, _Tp>
2406  {
2407  _Rp
2408  operator()(const _Tp& x, const _Tp& y) const
2409  {
2410  return std::abs(x - y);
2411  }
2412  };
2413 
2424  template <class _Rp,class _Tp>
2425  struct L2_dist : public std::binary_function<_Rp, _Tp, _Tp>
2426  {
2427  _Rp
2428  operator()(const _Tp& x, const _Tp& y) const
2429 
2430  {
2431  _Tp diff = (x -y);
2432  return std::sqrt(diff * diff);
2433  }
2434  };
2435 
2445  template <typename _Rp,typename _Tp>
2446  struct L22_dist : public std::binary_function<_Rp, _Tp, _Tp>
2447  {
2448  _Rp
2449  operator()(const _Tp& x, const _Tp& y) const
2450 
2451  {
2452  _Tp diff = (x -y);
2453  return (diff * diff);
2454  }
2455  };
2456 
2468  template <typename _Rp,typename _Tp>
2469  struct Relative_error_L1 : public std::binary_function<_Rp, _Tp, _Tp>
2470  {
2471  _Rp
2472  operator()(const _Tp& x, const _Tp& y) const
2473 
2474  {
2475  if(x != _Tp())
2476  {
2477  return std::abs(x -y) / std::abs(x);
2478  }
2479  else
2480  {
2481  return std::abs(y);
2482  }
2483  }
2484  };
2496  template <typename _Rp,typename _Tp>
2497  struct Relative_error_L2 : public std::binary_function<_Rp, _Tp, _Tp>
2498  {
2499  _Rp
2500  operator()(const _Tp& x, const _Tp& y) const
2501 
2502  {
2503  if(x != _Tp())
2504  {
2505  _Tp diff = (x -y);
2506  return std::sqrt(diff * diff) / std::abs(x);
2507  }
2508  else
2509  {
2510  return std::abs(y);
2511  }
2512  }
2513  };
2514 
2526  template <typename _Rp,typename _Tp>
2527  struct Relative_error_L22 : public std::binary_function<_Rp, _Tp, _Tp>
2528  {
2529  _Rp
2530  operator()(const _Tp& x, const _Tp& y) const
2531 
2532  {
2533  if(x != _Tp())
2534  {
2535  _Tp diff = (x -y);
2536  return (diff * diff) / (x*x);
2537  }
2538  else
2539  {
2540  return y*y;
2541  }
2542  }
2543  };
2554  template <typename Vector>
2555 struct L1_dist_vect: public std::binary_function<typename Vector::value_type, Vector, Vector>
2556  {
2557  typename Vector::value_type
2558  operator()(const Vector& x,
2559  const Vector& y) const
2560 
2561  {
2562  typename Vector::value_type dist = slip::L1_distance<typename Vector::value_type>(x.begin(),x.end(),y.begin());
2563  return dist;
2564  }
2565  };
2566 
2577 template <typename Vector>
2578 struct L2_dist_vect: public std::binary_function<typename Vector::value_type, Vector, Vector>
2579  {
2580  typename Vector::value_type
2581  operator()(const Vector& x,
2582  const Vector& y) const
2583 
2584  {
2585  typename Vector::value_type dist = slip::L2_distance<typename Vector::value_type>(x.begin(),x.end(),y.begin());
2586  return dist;
2587  }
2588  };
2589 
2600 template <typename Vector>
2601 struct L22_dist_vect: public std::binary_function<typename Vector::value_type, Vector, Vector>
2602  {
2603  typename Vector::value_type
2604  operator()(const Vector& x,
2605  const Vector& y) const
2606 
2607  {
2608  typename Vector::value_type dist = slip::L22_distance<typename Vector::value_type>(x.begin(),x.end(),y.begin());
2609  return dist;
2610  }
2611  };
2612 
2613  /* @} */
2614 
2615 
2616 }//slip::
2617 
2618 
2619 
2620 #endif //SLIP_COMPARE_HPP
Vector::value_type operator()(const Vector &x, const Vector &y) const
Definition: compare.hpp:2604
Provides a class to manipulate 2d dynamic and generic arrays.
Real KullbackLeibler_distance_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the Kullback-Leibler "distance" of two ranges according to a mask sequence : ...
Definition: compare.hpp:1823
Real L2_distance_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the eucludian distance of two ranges according to a mask sequence : .
Definition: compare.hpp:1234
T covariance_mask(InputIterator first, InputIterator last, InputIterator2 first2, MaskIterator mask_first, T mean1, T mean2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the covariance of a two sequences over a mask .
Real KullbackLeibler_distance_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the Kullback-Leibler "distance" of two ranges according to a Predicate.
Definition: compare.hpp:1878
Real distance(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryFunctor distance)
Computes the sum of the pointwise distances of two ranges: according to the distance d...
Definition: compare.hpp:150
Real Minkowski_distance(const std::size_t n, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the Minkowski order n distance of two ranges : Use L1 and L2 distance for n=1 or 2...
Definition: compare.hpp:1457
Real L22_distance_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the square eucludian distance of two ranges according to a mask sequence : ...
Definition: compare.hpp:1101
Real snr_dB_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the decibel signal to noise ration (snr) of two ranges according to a predicate: ...
Definition: compare.hpp:1027
T variance_mask(InputIterator first, InputIterator last, MaskIterator mask_first, T mean, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the variance of a range over a mask .
Real Chi2_distance(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the Chi2 "distance" of two ranges : .
Definition: compare.hpp:1921
Value_T psnr(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Value_T d=static_cast< Value_T >(255))
Definition: compare.hpp:2067
Real Minkowski_distance_mask(const std::size_t n, InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the Minkowski order n distance of two ranges according to a mask sequence : ...
Definition: compare.hpp:1512
_OutputIterator transform_if(_InputIterator first, _InputIterator last, _OutputIterator result, _UnaryOperation unary_op, _Predicate pred)
Perform an operation on a sequence according to a Predicate.
Computes the L1 distance between two Vectors x and y: .
Definition: compare.hpp:2555
iterator end()
Returns a read/write iterator that points one past the last element in the Vector. Iteration is done in ordinary element order.
Definition: Vector.hpp:1481
Real mean_abs_diff_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the mean absolute difference of two ranges according to a Predicate.
Definition: compare.hpp:756
Real L2_distance(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the Euclidian distance of two ranges : .
Definition: compare.hpp:1197
Real L1_distance_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the L1 distance of two ranges according to a mask sequence : .
Definition: compare.hpp:1355
_OutputIterator transform_mask_bin(_InputIterator1 first1, _InputIterator1 last1, _MaskIterator mask_first, _InputIterator2 first2, _OutputIterator result, _BinaryOperation binary_op, typename std::iterator_traits< _MaskIterator >::value_type value=typename std::iterator_traits< _MaskIterator >::value_type(1))
Perform an operation on corresponding elements of two sequences according to a mask sequence...
Real snr_dB(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the decibel signal to noise ration (snr) of two ranges : .
Definition: compare.hpp:948
Real distance_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, BinaryFunctor distance, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the sum of the pointwise distances of two ranges: according to the distance d and the given...
Definition: compare.hpp:211
Computes the L22 distance between two values x and y: .
Definition: compare.hpp:2446
Real Minkowski_distance_if(const std::size_t n, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the Minkowski order n distance of two ranges according to a Predicate.
Definition: compare.hpp:1581
Vector::value_type operator()(const Vector &x, const Vector &y) const
Definition: compare.hpp:2558
Value_T psnr_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask1, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1), Value_T d=static_cast< Value_T >(255))
Definition: compare.hpp:2112
_Rp operator()(const _Tp &x, const _Tp &y) const
Definition: compare.hpp:2530
Real snr_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the signal to noise ration (snr) of two ranges according to a Predicate. ...
Definition: compare.hpp:903
Value_T psnr_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred, Value_T d=static_cast< Value_T >(255))
Definition: compare.hpp:2163
Real L1_distance_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the L1 distance of two ranges according to a Predicate.
Definition: compare.hpp:1412
Real Linf_distance(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the Linfinite distance of two ranges : .
Definition: compare.hpp:1636
Real L2_distance_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the eucludian distance of two ranges according to a Predicate.
Definition: compare.hpp:1281
HyperVolume< T > abs(const HyperVolume< T > &M)
Provides a class to manipulate 1d dynamic and generic arrays.
Real mean_square_diff_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the mean square of the pointwise difference of two ranges according to a Predicate : ...
Definition: compare.hpp:610
unsigned int log2(unsigned int x)
Calculates the log2 of an integer.
Definition: FFT.hpp:135
Real snr(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the signal to noise ration (snr) of two ranges : .
Definition: compare.hpp:799
T variance(InputIterator first, InputIterator last, T mean)
Computes the variance of a range .
Definition: statistics.hpp:535
Value_T mean_abs_diff(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the mean absolute difference of two range of size N: .
Definition: compare.hpp:653
T variance_if(InputIterator first, InputIterator last, T mean, Predicate pred)
Computes the variance of a range using a predicate .
Real snr_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the signal to noise ration (snr) of two ranges according to a mask sequence : ...
Definition: compare.hpp:845
Provides some statistics algorithms.
Computes the Relative L22 error between two values x and y: .
Definition: compare.hpp:2527
Real L22_distance_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the square eucludian distance of two ranges according to a Predicate.
Definition: compare.hpp:1156
Value_T mean_abs_diff_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the mean absolute difference of two ranges of size N according to a mask sequence : ...
Definition: compare.hpp:698
Numerical Vector class. This container statisfies the RandomAccessContainer concepts of the Standard ...
Definition: Vector.hpp:104
_Rp operator()(const _Tp &x, const _Tp &y) const
Definition: compare.hpp:2500
HyperVolume< T > sqrt(const HyperVolume< T > &M)
Provides some extension to STL algorithms.
Real snr_dB_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the decibel signal to noise ration (snr) of two ranges according to a mask sequence : ...
Definition: compare.hpp:984
Computes the L1 distance between two values x and y: .
Definition: compare.hpp:2405
Real Linf_distance_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the Linfinite distance of two ranges according to a Predicate.
Definition: compare.hpp:1735
Value_T mean_square_diff(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the mean square of the pointwise difference of two ranges of size N: .
Definition: compare.hpp:507
Real SSIM_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator maskFirst, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1), Real d=static_cast< Real >(255))
Computes the structural similarity beetween two data ranges according to a mask range where...
Definition: compare.hpp:2288
Computes the L1 relative error between two values x and y: .
Definition: compare.hpp:2469
T covariance_if(InputIterator first, InputIterator last, InputIterator2 first2, T mean1, T mean2, Predicate pred)
Computes the covariance of a two sequences using a predicate on the first one .
HyperVolume< T > log10(const HyperVolume< T > &M)
Computes the L2 distance between two Vectors x and y: .
Definition: compare.hpp:2578
_Rp operator()(const _Tp &x, const _Tp &y) const
Definition: compare.hpp:2449
T covariance(InputIterator first, InputIterator last, InputIterator2 first2, T mean1, T mean2)
Computes the covariance of a two sequences .
Definition: statistics.hpp:443
Real L22_distance(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the square euclidian distance of two ranges: .
Definition: compare.hpp:1059
Vector::value_type operator()(const Vector &x, const Vector &y) const
Definition: compare.hpp:2581
Real Linf_distance_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the Linfinite distance of two ranges according to a mask sequence : .
Definition: compare.hpp:1679
Computes the L2 distance between two values x and y: .
Definition: compare.hpp:2425
Real Chi2_distance_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
Computes the Chi2 "distance" of two ranges according to a Predicate.
Definition: compare.hpp:2020
Real mean_square_diff_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the mean square of the pointwise difference of two ranges of size N according to a mask sequ...
Definition: compare.hpp:553
_Rp operator()(const _Tp &x, const _Tp &y) const
Definition: compare.hpp:2408
Real distance_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryFunctor distance, Predicate pred)
Computes the sum of the pointwise distances of two ranges: according to the distance d and the given...
Definition: compare.hpp:280
Real SSIM_if(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred, Real d=255)
Computes the Sructural SIMilarity (SSIM) beetween two data ranges according to a predicate where...
Definition: compare.hpp:2367
Real SSIM(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Real d=static_cast< Real >(255))
Computes the Structural SIMilarity (SSIM) beetween two data ranges where.
Definition: compare.hpp:2222
Real Chi2_distance_mask(InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
Computes the Chi2 "distance" of two ranges according to a mask sequence : .
Definition: compare.hpp:1964
Computes the L2 relative error between two values x and y: .
Definition: compare.hpp:2497
Computes the L22 distance between two Vectors x and y: .
Definition: compare.hpp:2601
_Rp operator()(const _Tp &x, const _Tp &y) const
Definition: compare.hpp:2472
_Rp operator()(const _Tp &x, const _Tp &y) const
Definition: compare.hpp:2428
Real L1_distance(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the L1 distance of two ranges : .
Definition: compare.hpp:1313
Provides a class to manipulate numerical vectors.
iterator begin()
Returns a read/write iterator that points to the first element in the Vector. Iteration is done in or...
Definition: Vector.hpp:1474
Real KullbackLeibler_distance(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
Computes the Kullback-Leibler "distance" of two ranges : .
Definition: compare.hpp:1780