PICCANTE  0.4
The hottest HDR imaging library!
image_vec.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_IMAGE_RAW_VEC_HPP
19 #define PIC_IMAGE_RAW_VEC_HPP
20 
21 #include <vector>
22 #include "image.hpp"
23 
24 namespace pic {
25 
29 typedef std::vector<Image *> ImageVec;
30 
37 {
38  ImageVec ret;
39  ret.push_back(img);
40  return ret;
41 }
42 
50 {
51  ImageVec ret;
52  ret.push_back(img1);
53  ret.push_back(img2);
54  return ret;
55 }
56 
64 PIC_INLINE ImageVec Triple(Image *img1, Image *img2, Image *img3)
65 {
66  ImageVec ret;
67  ret.push_back(img1);
68  ret.push_back(img2);
69  ret.push_back(img3);
70  return ret;
71 }
72 
81 PIC_INLINE ImageVec Quad(Image *img1, Image *img2, Image *img3,
82  Image *img4)
83 {
84  ImageVec ret;
85  ret.push_back(img1);
86  ret.push_back(img2);
87  ret.push_back(img3);
88  ret.push_back(img4);
89  return ret;
90 }
91 
97 {
98  std::sort(stack.begin(), stack.end(), [](const Image *l, const Image *r)->bool{
99  if (!l || !r) {
100  return false;
101  }
102  return l->exposure < r->exposure;
103  });
104 }
105 
106 
111 PIC_INLINE void ImaveVecGetExposureTimesAsArray(ImageVec &stack, std::vector<float> &output, bool bLog)
112 {
113  output.clear();
114 
115  for(unsigned int i = 0; i < stack.size(); i++) {
116  float tmp = bLog ? logf(stack[i]->exposure) : stack[i]->exposure;
117  output.push_back(tmp);
118  }
119 }
120 
127 {
128  if(stack.size() < 2) {
129  return false;
130  }
131 
132  for (unsigned int i = 1; i < stack.size(); i++) {
133  if (!stack[0]->isSimilarType(stack[i])) {
134  return false;
135  }
136  }
137 
138  return true;
139 }
140 
147 PIC_INLINE bool ImageVecCheck(ImageVec &imgIn, int minInputImages)
148 {
149  int n;
150  if(minInputImages < 0) {
151  n = int(imgIn.size());
152  } else {
153  if(imgIn.size() < minInputImages) {
154  return false;
155  }
156 
157  n = minInputImages;
158  }
159 
160  for(int i = 0; i < n; i ++) {
161  if(imgIn[i] == NULL) {
162  return false;
163  } else {
164  if(!imgIn[i]->isValid()) {
165  return false;
166  }
167  }
168  }
169 
170  return true;
171 }
172 
173 } // end namespace pic
174 
175 #endif /* PIC_IMAGE_RAW_VEC_HPP */
176 
PIC_INLINE bool ImageVecCheck(ImageVec &imgIn, int minInputImages)
ImageVecCheck.
Definition: image_vec.hpp:147
PIC_INLINE bool ImageVecCheckSimilarType(ImageVec &stack)
ImageVecCheckSimilarType.
Definition: image_vec.hpp:126
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
PIC_INLINE ImageVec Quad(Image *img1, Image *img2, Image *img3, Image *img4)
Triple creates an std::vector which contains img1, img2, img3, and img4; this is for filters input...
Definition: image_vec.hpp:81
float exposure
Definition: image.hpp:79
PIC_INLINE ImageVec Double(Image *img1, Image *img2)
Double creates an std::vector which contains img1 and img2; this is for filters input.
Definition: image_vec.hpp:49
#define PIC_INLINE
Definition: base.hpp:33
PIC_INLINE void ImaveVecSortByExposureTime(ImageVec &stack)
ImaveVecSortByExposureTime.
Definition: image_vec.hpp:96
The Image class stores an image as buffer of float.
Definition: image.hpp:60
PIC_INLINE ImageVec Triple(Image *img1, Image *img2, Image *img3)
Triple creates an std::vector which contains img1, img2, and img3; this is for filters input...
Definition: image_vec.hpp:64
PIC_INLINE void ImaveVecGetExposureTimesAsArray(ImageVec &stack, std::vector< float > &output, bool bLog)
ImaveVecGetExposureTimesAsArray.
Definition: image_vec.hpp:111
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Definition: bilateral_separation.hpp:25