18 #ifndef PIC_METRICS_M_PSNR_HPP 19 #define PIC_METRICS_M_PSNR_HPP 23 #include "../base.hpp" 25 #include "../util/array.hpp" 27 #include "../image.hpp" 28 #include "../tone_mapping/get_all_exposures.hpp" 29 #include "../metrics/base.hpp" 30 #include "../metrics/mse.hpp" 47 if(ori == NULL || cmp == NULL) {
59 std::vector<float> exposures;
67 if(minFstop == maxFstop) {
72 float *exposures_v = NULL;
73 Arrayf::genRange(
float(minFstop), 1.0f,
float(maxFstop), exposures_v, nExposures_v);
75 exposures.insert(exposures.begin(), exposures_v, exposures_v + nExposures_v);
80 for(
int i = minFstop; i <= maxFstop; i++) {
81 exposures.push_back(
float(i));
87 if(exposures.empty()) {
92 printf(
"-------------------------------------------------------\n");
93 printf(
"-- mPSNR:\n");
94 printf(
"-- min F-stop: %d \t max F-stop: %d\n", minFstop, maxFstop);
99 auto n = exposures.size();
101 for(
auto i = 0; i < n; i++) {
102 double mse_i =
MSE(ori, cmp, gamma, exposures[i], nBit);
105 printf(
"-- Pass: %d \t MSE: %g\n", i, mse_i);
113 int nValues = (1 << nBit) - 1;
114 double nValuesd = double(nValues);
115 double ret = 10.0 * log10((nValuesd * nValuesd) / mse);
118 printf(
"-- value: %f\n", ret);
119 printf(
"-------------------------------------------------------");
static T * genRange(T minVal, T step, T maxVal, T *ret, int &n)
genRange
Definition: array.hpp:156
int channels
Definition: image.hpp:80
PIC_INLINE double mPSNR(Image *ori, Image *cmp, MULTI_EXPOSURE_TYPE type, int minFstop=0, int maxFstop=0)
mPSNR computes the multiple-exposure peak signal-to-noise ratio (mPSNR) between two images...
Definition: m_psnr.hpp:45
bool isSimilarType(const Image *img)
isSimilarType checks if the current image is similar to img; i.e. if they have the same width...
Definition: m_psnr.hpp:34
PIC_INLINE void getMinMaxFstops(Image *imgIn, int &minFstop, int &maxFstop)
getMinMaxFstops computes the minimum and maximum f-stop values of an image.
Definition: get_all_exposures.hpp:39
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
PIC_INLINE std::vector< float > getAllExposures(Image *imgIn)
getAllExposures computes all required exposure values for reconstructing the input image using histog...
Definition: get_all_exposures.hpp:107
#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...
MULTI_EXPOSURE_TYPE
Definition: m_psnr.hpp:34
Definition: m_psnr.hpp:34
Definition: m_psnr.hpp:34