PICCANTE  0.4
The hottest HDR imaging library!
maximum_error.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_METRICS_MAXIMUM_ERROR_HPP
19 #define PIC_METRICS_MAXIMUM_ERROR_HPP
20 
21 #include <math.h>
22 
23 #include "../base.hpp"
24 #include "../image.hpp"
25 #include "../metrics/base.hpp"
26 
27 namespace pic {
28 
36 PIC_INLINE float MaximumError(Image *ori, Image *cmp, bool bLargeDifferences = false)
37 {
38  if(ori == NULL || cmp == NULL) {
39  return -2.0f;
40  }
41 
42  if(!ori->isValid() || !cmp->isValid()) {
43  return -4.0f;
44  }
45 
46  if(!ori->isSimilarType(cmp)) {
47  return -1.0f;
48  }
49 
50  int size = ori->size();
51 
52 
53  float largeDifferences = C_LARGE_DIFFERENCESf;
54  if(!bLargeDifferences) {
55  largeDifferences = FLT_MAX;
56  }
57 
58  float maxVal = -FLT_MAX;
59  for(int i = 0; i < size; i++) {
60  float delta = fabsf(ori->data[i] - cmp->data[i]);
61 
62  if((delta < C_LARGE_DIFFERENCES) && (maxVal < delta)) {
63  maxVal = delta;
64  }
65  }
66 
67  return maxVal;
68 }
69 
70 } // end namespace pic
71 
72 #endif /* PIC_METRICS_MAXIMUM_ERROR_HPP */
73 
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
bool isSimilarType(const Image *img)
isSimilarType checks if the current image is similar to img; i.e. if they have the same width...
#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...
const float C_LARGE_DIFFERENCESf
Definition: base.hpp:28
PIC_INLINE float MaximumError(Image *ori, Image *cmp, bool bLargeDifferences=false)
MaximumError computes the maximum error between two images.
Definition: maximum_error.hpp:36
const double C_LARGE_DIFFERENCES
Definition: base.hpp:27