18 #ifndef PIC_METRICS_MSE_HPP 19 #define PIC_METRICS_MSE_HPP 23 #include "../base.hpp" 24 #include "../image.hpp" 25 #include "../metrics/base.hpp" 39 if(ori == NULL || cmp == NULL) {
51 int size = ori->
size();
58 if(!bLargeDifferences) {
59 largeDifferences = FLT_MAX;
63 for(
int i = 0; i < size; i++) {
67 double delta = double(o_val - c_val);
69 if(delta <= largeDifferences) {
75 return acc / double(count);
89 if(ori == NULL || cmp == NULL) {
101 float invGamma = 1.0f / gamma;
102 float exposure = powf(2.0f, fstop);
107 unsigned long long acc = 0;
109 int nValues = (1 << nBit) - 1;
110 float nValuesf = float(nValues);
112 for(
int i = 0; i < size; i++) {
113 int oriLDR = int(nValuesf * (powf(ori->
data[i] * exposure, invGamma)));
114 int cmpLDR = int(nValuesf * (powf(cmp->
data[i] * exposure, invGamma)));
116 oriLDR =
CLAMPi(oriLDR, 0, nValues);
117 cmpLDR =
CLAMPi(cmpLDR, 0, nValues);
119 int delta = cmpLDR - oriLDR;
121 acc += delta * delta;
124 return (
double(acc) /
double(area));
137 return sqrt(
MSE(ori, cmp, bLargeDifferences, type));
int size() const
size computes the number of values.
Definition: image.hpp:481
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
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
PIC_INLINE double MSE(Image *ori, Image *cmp, bool bLargeDifferences=false, METRICS_DOMAIN type=MD_LIN)
MSE computes the mean square error (MSE) between two images.
Definition: mse.hpp:37
#define PIC_INLINE
Definition: base.hpp:33
The Image class stores an image as buffer of float.
Definition: image.hpp:60
#define CLAMPi(x, a, b)
Definition: math.hpp:81
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...
METRICS_DOMAIN
Definition: base.hpp:30
const float C_LARGE_DIFFERENCESf
Definition: base.hpp:28
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80