18 #ifndef PIC_METRICS_PSNR_HPP 19 #define PIC_METRICS_PSNR_HPP 23 #include "../base.hpp" 24 #include "../image.hpp" 25 #include "../util/array.hpp" 26 #include "../metrics/base.hpp" 27 #include "../metrics/mse.hpp" 43 if(ori == NULL || cmp == NULL) {
55 if(max_value <= 0.0) {
56 float *max_value_ori = ori->
getMaxVal(NULL, NULL);
57 float *max_value_cmp = cmp->
getMaxVal(NULL, NULL);
63 max_value = double(
MAX(m_ori, m_cmp));
65 delete[] max_value_ori;
66 delete[] max_value_cmp;
69 double rmse_value =
RMSE(ori, cmp, bLargeDifferences, type);
71 max_value = double(
changeDomain(
float(max_value), type));
73 if(rmse_value > 0.0) {
74 return 20.0 * log10(max_value / rmse_value);
static T getMax(T *data, int size, int &ind)
getMax
Definition: array.hpp:516
int channels
Definition: image.hpp:80
bool isSimilarType(const Image *img)
isSimilarType checks if the current image is similar to img; i.e. if they have the same width...
float changeDomain(float x, METRICS_DOMAIN type=MD_LIN)
changeDomain
Definition: base.hpp:38
PIC_INLINE double RMSE(Image *ori, Image *cmp, bool bLargeDifferences=false, METRICS_DOMAIN type=MD_LIN)
RMSE computes the root mean squared error (RMSE) between two images.
Definition: mse.hpp:135
#define PIC_INLINE
Definition: base.hpp:33
The Image class stores an image as buffer of float.
Definition: image.hpp:60
Definition: bilateral_separation.hpp:25
bool isValid()
isValid checks if the current image is valid, which means if they have an allocated buffer or not...
#define MAX(a, b)
Definition: math.hpp:73
METRICS_DOMAIN
Definition: base.hpp:30
PIC_INLINE double PSNR(Image *ori, Image *cmp, double max_value=-1.0, bool bLargeDifferences=false, METRICS_DOMAIN type=MD_LIN)
PSNR computes the peak signal to noise ratio (PSNR) between two images.
Definition: psnr.hpp:41
float * getMaxVal(BBox *box, float *ret)
getMaxVal computes the maximum value for the current Image.