SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces
compare.hpp File Reference

Provides some algorithms to compare ranges. More...

#include <algorithm>
#include <numeric>
#include <cassert>
#include <cmath>
#include <functional>
#include "Array.hpp"
#include "Array2d.hpp"
#include "Vector.hpp"
#include "stl_algo_ext.hpp"
#include "statistics.hpp"
Include dependency graph for compare.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  slip::L1_dist< _Rp, _Tp >
 Computes the L1 distance between two values x and y: $ |x - y|$. More...
 
struct  slip::L2_dist< _Rp, _Tp >
 Computes the L2 distance between two values x and y: $ \sqrt{(x - y)^2}$. More...
 
struct  slip::L22_dist< _Rp, _Tp >
 Computes the L22 distance between two values x and y: $ (x - y)^2$. More...
 
struct  slip::Relative_error_L1< _Rp, _Tp >
 Computes the L1 relative error between two values x and y: $ \frac{|x - y|}{|x|}$. More...
 
struct  slip::Relative_error_L2< _Rp, _Tp >
 Computes the L2 relative error between two values x and y: $ \frac{\sqrt{(x - y)^2}}{|x|}$. More...
 
struct  slip::Relative_error_L22< _Rp, _Tp >
 Computes the Relative L22 error between two values x and y: $ \frac{(x - y)^2}{x^2}$. More...
 
struct  slip::L1_dist_vect< Vector >
 Computes the L1 distance between two Vectors x and y: $ \sum_i |x_i - y_i|$. More...
 
struct  slip::L2_dist_vect< Vector >
 Computes the L2 distance between two Vectors x and y: $ \sqrt{\sum_i (x_i - y_i)^2}$. More...
 
struct  slip::L22_dist_vect< Vector >
 Computes the L22 distance between two Vectors x and y: $ \sum_i (x_i - y_i)^2$. More...
 

Namespaces

 slip
 This namespace corresponds to the kernel of the Simple Library on Image Processing (SLIP). That is to say that it contains the data structures and the algorithms needed by these data strucutres.
 

Functions

Generic distance algorithms
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename BinaryFunctor >
Real slip::distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryFunctor distance)
 Computes the sum of the pointwise distances of two ranges: $ \sum_i d(s_i, b_i)$ according to the distance d. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename BinaryFunctor , typename MaskIterator >
Real slip::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: $ \sum_i d(s_i, b_i)$ according to the distance d and the given mask range. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename BinaryFunctor , typename Predicate >
Real slip::distance_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryFunctor distance, Predicate pred)
 Computes the sum of the pointwise distances of two ranges: $ \sum_i d(s_i, b_i)$ according to the distance d and the given predicate. More...
 
Generic distance map algorithms
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename BinaryFunctor >
void slip::distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryFunctor distance)
 Computes the pointwise distances of two ranges: $ d(s_i, b_i)$. More...
 
template<typename InputIterator1 , typename InputIterator2 , typename MaskIterator , typename OutputIterator , typename BinaryFunctor >
void slip::distance_mask (InputIterator1 first1, InputIterator1 last1, MaskIterator mask_first, InputIterator2 first2, OutputIterator result, BinaryFunctor distance, typename std::iterator_traits< MaskIterator >::value_type value=typename std::iterator_traits< MaskIterator >::value_type(1))
 Computes the pointwise distances of two ranges: $ d(s_i, b_i)$ according to a given mask range. More...
 
template<typename _InputIterator1 , typename _InputIterator2 , typename _OutputIterator , typename _BinaryOperation , typename _Predicate >
void slip::distance_if (_InputIterator1 first1, _InputIterator1 last1, _InputIterator2 first2, _OutputIterator result, _BinaryOperation distance, _Predicate pred)
 Computes the pointwise distances of two ranges: $ d(s_i, b_i)$ according to a Predicate. More...
 
Specific distance algorithms
template<typename Value_T , typename InputIterator1 , typename InputIterator2 >
Value_T slip::mean_square_diff (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the mean square of the pointwise difference of two ranges of size N: $ \frac{1}{N}\sum_i^N (xi - yi)^2 $. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 sequence : $ \frac{1}{N_{mask}}\sum_{i / mask_i = value} (xi - yi)^2 $. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::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 : $ \frac{1}{N_{pred}}\sum_{i / pred=true} (xi - yi)^2 $. More...
 
template<typename Value_T , typename InputIterator1 , typename InputIterator2 >
Value_T slip::mean_abs_diff (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the mean absolute difference of two range of size N: $(1/ N)\sum_i^N |xi - yi|$. More...
 
template<typename Value_T , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Value_T slip::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 : $(1/ N_{mask})\sum_{i / mask_i = value} |xi - yi|$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::mean_abs_diff_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the mean absolute difference of two ranges according to a Predicate. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::snr (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the signal to noise ration (snr) of two ranges : $\sum_i \frac{s_i*s_i}{(s_i - b_i)^2}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $\sum_{i / mask_i = value} \frac{s_i*s_i}{(s_i - b_i)^2}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::snr_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the signal to noise ration (snr) of two ranges according to a Predicate. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::snr_dB (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the decibel signal to noise ration (snr) of two ranges : $ 20.0*\log{\sum_i \frac{s_i*s_i}{(s_i - b_i)^2}}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ 20.0*\log{\sum_{i / mask_i = value} \frac{s_i*s_i}{(s_i - b_i)^2}}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::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: $ 20.0*\log{\sum_{i / pred = true} \frac{s_i*s_i}{(s_i - b_i)^2}}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::L22_distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the square euclidian distance of two ranges: $ \sum_i (s_i - b_i)^2$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ \sum_{i / mask_i = value} (s_i - b_i)^2$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::L22_distance_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the square eucludian distance of two ranges according to a Predicate. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::L2_distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the Euclidian distance of two ranges : $ \sqrt{\sum_i (s_i - b_i)^2}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ \sqrt{\sum_{i / mask_i = value} (s_i - b_i)^2}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::L2_distance_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the eucludian distance of two ranges according to a Predicate. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::L1_distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the L1 distance of two ranges : $ \sum_i |s_i - b_i|$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ \sum_{i / mask_i = value} |s_i - b_i|$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::L1_distance_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the L1 distance of two ranges according to a Predicate. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::Minkowski_distance (const std::size_t n, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the Minkowski order n distance of two ranges : $ (\sum_i |s_i - b_i|^n)^\frac{1}{n}$ Use L1 and L2 distance for n=1 or 2. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ (\sum_{i / mask_i = value} |s_i - b_i|^n)^\frac{1}{n}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::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. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::Linf_distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the Linfinite distance of two ranges : $ sup \{|s_i - b_i|\}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ sup_{mask_i = value} \{|s_i - b_i|\}$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::Linf_distance_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the Linfinite distance of two ranges according to a Predicate. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::KullbackLeibler_distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the Kullback-Leibler "distance" of two ranges : $ \sum_i (s_i log2(s_i/b_i))$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ \sum_{i / mask_i = value} (s_i log2(s_i/b_i))$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::KullbackLeibler_distance_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the Kullback-Leibler "distance" of two ranges according to a Predicate. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::Chi2_distance (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
 Computes the Chi2 "distance" of two ranges : $ \sum_i ((s_i-b_i)*(s_i-b_i)/s_i)$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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 : $ \sum_{i / mask_i = value} ((s_i-b_i)*(s_i-b_i)/s_i)$. More...
 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::Chi2_distance_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred)
 Computes the Chi2 "distance" of two ranges according to a Predicate. More...
 
template<typename Value_T , typename InputIterator1 , typename InputIterator2 >
Value_T slip::psnr (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Value_T d=static_cast< Value_T >(255))
 
template<typename Value_T , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Value_T slip::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))
 
template<typename Value_T , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Value_T slip::psnr_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Predicate pred, Value_T d=static_cast< Value_T >(255))
 
template<typename Real , typename InputIterator1 , typename InputIterator2 >
Real slip::SSIM (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, Real d=static_cast< Real >(255))
 Computes the Structural SIMilarity (SSIM) beetween two data ranges

\[ SSIM(x,y) = \frac{(2\mu_x\mu_y + c_1)(2cov_{xy}+c_2)}{(\mu_x^2+\mu_y^2+c_1)(\sigma_x^2+\sigma_y^2+c_2)} \]

where. More...

 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename MaskIterator >
Real slip::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

\[ SSIM(x,y) = \frac{(2\mu_x\mu_y + c_1)(2cov_{xy}+c_2)}{(\mu_x^2+\mu_y^2+c_1)(\sigma_x^2+\sigma_y^2+c_2)} \]

where. More...

 
template<typename Real , typename InputIterator1 , typename InputIterator2 , typename Predicate >
Real slip::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

\[ SSIM(x,y) = \frac{(2\mu_x\mu_y + c_1)(2cov_{xy}+c_2)}{(\mu_x^2+\mu_y^2+c_1)(\sigma_x^2+\sigma_y^2+c_2)} \]

where. More...

 

Detailed Description

Provides some algorithms to compare ranges.

Definition in file compare.hpp.