PICCANTE  0.4
The hottest HDR imaging library!
convert_raw_to_images.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_UTIL_CONVERT_RAW_TO_IMAGES_HPP
19 #define PIC_UTIL_CONVERT_RAW_TO_IMAGES_HPP
20 
21 #include "../base.hpp"
22 #include "../util/raw.hpp"
23 #include "../util/string.hpp"
24 #include "../image.hpp"
25 
26 namespace pic {
27 
35 PIC_INLINE void ConvertRAWtoImages(std::string nameDirectory, std::string format,
36  int width, int height)
37 {
38  StringVec vec;
39  FileLister::List(nameDirectory, "raw", &vec);
40 
41  Image img;
42 
43  for(unsigned int i = 0; i < vec.size(); i++) {
44  img.ReadRAW(vec[i], "NULL", RAW_U16_RGGB, width, height);
45 
46  std::string out = removeExtension(vec[i]);
47  out += ".";
48  out += format;
49  printf("%s\n", out.c_str());
50  img.Write(out);
51  }
52 }
53 
61 PIC_INLINE void ConvertDetect(std::string nameDirectory, std::string format, int width,
62  int height)
63 {
64 
65  RAW<unsigned short> *imgMean = CalculateRAWMeanFromFile<unsigned short>
66  (nameDirectory, "raw", width, height);
67 
68  StringVec vec;
69  FileLister::List(nameDirectory, "raw", &vec);
70 
72  Image img;
73 
74  for(unsigned int i = 0; i < vec.size(); i++) {
75  tmp.Read(vec[i], width * height);
76 
77  for(int j = 0; j < tmp.nData; j++) {
78  int diff = (tmp.data[j] - imgMean->data[j]);
79  diff = diff > 0 ? diff : -diff;
80 
81  if(diff > 6200) {
82  tmp.data[j] = 10000;
83  } else {
84  tmp.data[j] = 0;
85  }
86  }
87 
88  tmp.Write("tmpRAW.raw");
89  img.ReadRAW("tmpRAW.raw", "NULL", RAW_U16_RGGB, width, height);
90 
91  std::string out = vec[i];
92  out += ".";
93  out += format;
94  printf("%s\n", out.c_str());
95  img.Write(out);
96  }
97 }
98 
99 } // end namespace pic
100 
101 #endif /* PIC_UTIL_CONVERT_RAW_TO_IMAGES_HPP */
102 
std::vector< std::string > StringVec
StringVec is an std::vector of std::string.
Definition: string.hpp:49
PIC_INLINE void ConvertDetect(std::string nameDirectory, std::string format, int width, int height)
ConvertDetect.
Definition: convert_raw_to_images.hpp:61
Definition: raw.hpp:32
Definition: raw.hpp:35
PIC_INLINE void ConvertRAWtoImages(std::string nameDirectory, std::string format, int width, int height)
ConvertRAWtoImages converts .RAW into format.
Definition: convert_raw_to_images.hpp:35
#define PIC_INLINE
Definition: base.hpp:33
bool Read(std::string nameFile, int nData)
Read.
Definition: raw.hpp:84
The Image class stores an image as buffer of float.
Definition: image.hpp:60
Definition: bilateral_separation.hpp:25
std::string removeExtension(std::string name)
RemoveExtension removes the extension of a string.
Definition: string.hpp:132
T * data
Definition: saturation.hpp:37
bool Write(std::string nameFile, LDR_type typeWrite, int writerCounter)
Write saves an Image into a file on the disk.
bool Write(std::string nameFile)
Write.
Definition: raw.hpp:116
int nData
Definition: saturation.hpp:38