ddt  0.1
imageColor.hpp
Go to the documentation of this file.
1 // @copyright
2 // (c) Copyright ESO 2020
3 // All Rights Reserved
4 // ESO (eso.org) is an Intergovernmental Organization, and therefore special
5 // legal conditions apply.
6 //
7 // @file imageColor.hpp
8 // @brief Image Color class, offers access to color map related functions.
9 //
10 // This file is part of the DDT Image Handling Library and
11 // provides functions for color map purposes.
12 //
13 // @author Christoph Bortlisz, CGI
14 // @since 2020/09/10
15 //
16 
17 #ifndef IMAGECOLOR_HPP
18 #define IMAGECOLOR_HPP
19 
20 #include <sys/stat.h>
21 
22 #include <algorithm>
23 #include <cctype>
24 #include <unordered_map>
25 
26 #include "boost/filesystem.hpp"
27 
28 #include <cpl.h>
29 #undef I
30 #undef arg
31 
32 #include "ddt/dataAcquisition.hpp"
33 #include "ddt/dataFile.hpp"
34 #include "ddt/ddtLogger.hpp"
35 #include "ddt/imageError.hpp"
36 #include "ddt/imageIO.hpp"
37 #include "ddt/imageProc.hpp"
38 #include "ddt/imageStats.hpp"
39 
40 namespace ddt {
41 
42 constexpr size_t MAX_SCALING_LUT_ENTRIES = 65536;
43 constexpr uint MAX_SCALING_LUT_VALUE = 65535;
44 constexpr size_t MAX_COLOR_MAP_ENTRIES = 256;
45 constexpr size_t MAX_COLOR_MAP_VALUE = 255;
46 constexpr size_t COLOR_MAP_ENTRY_SIZE = 3;
47 
54 typedef std::array<std::array<float, COLOR_MAP_ENTRY_SIZE>,
57 
66 typedef std::array<unsigned int, MAX_COLOR_MAP_ENTRIES> colorMapARGB_t;
67 
76 typedef struct scalingLut_t {
80  std::array<uint, MAX_SCALING_LUT_ENTRIES> lut;
85  double offset;
90  double factor;
92 
99 class ImageColor {
100  public:
105  ImageColor();
106 
110  virtual ~ImageColor();
111 
116  void set_logger(ddt::DdtLogger* const in_logger);
117 
122  void LoadColorMaps(const std::string color_map_folder);
123 
128  std::list<std::string> get_ColorMapsList() const;
129 
138  ddt::colorMap_t* get_ColorMap(const std::string color_map_name);
139 
148  ddt::colorMapARGB_t* get_ColorMapARGB(const std::string color_map_name);
149 
157 
165 
174  ddt::scalingLut_t* get_LinearScalingLut(const double cut_level_min,
175  const double cut_level_max);
176 
185  ddt::scalingLut_t* get_LogarithmicScalingLut(const double cut_level_min,
186  const double cut_level_max);
187 
196  ddt::scalingLut_t* get_SqrtScalingLut(const double cut_level_min,
197  const double cut_level_max);
198 
199  protected:
204 
205  private:
209  void initialize();
210 
214  void loadColorMap(std::string color_map_name);
215 
219  void loadGrayScaleColorMap();
220 
224  void calculateScalingParameter(const double cut_level_min,
225  const double cut_level_max,
226  double* const pixval_range,
227  double* const offset, double* const factor,
228  int* const cut_level_min_tmp,
229  int* const cut_level_max_tmp) const;
233  std::unordered_map<std::string, ddt::colorMap_t> colorMaps;
234 
238  std::unordered_map<std::string, ddt::colorMapARGB_t> colorMapsARGB;
239 
243  scalingLut_t linearScalingLut;
244 
248  scalingLut_t logScalingLut;
249 
253  scalingLut_t sqrtScalingLut;
254 };
255 
256 } // namespace ddt
257 
258 #endif /* IMAGECOLOR_HPP */
ddt::ImageColor::get_ColorMapARGB
ddt::colorMapARGB_t * get_ColorMapARGB(const std::string color_map_name)
Definition: imageColor.cpp:210
imageProc.hpp
ddt::scalingLut_t
Definition: imageColor.hpp:76
ddt::DdtLogger
Definition: ddtLogger.hpp:48
ddt
Definition: ddtClient.hpp:36
ddt::ImageColor
Definition: imageColor.hpp:99
ddt::ImageColor::ImageColor
ImageColor()
Definition: imageColor.cpp:28
ddt::colorMapARGB_t
std::array< unsigned int, MAX_COLOR_MAP_ENTRIES > colorMapARGB_t
Definition: imageColor.hpp:66
ddt::ImageColor::logger
ddt::DdtLogger * logger
Definition: imageColor.hpp:203
ddt::scalingLut_t::lut
std::array< uint, MAX_SCALING_LUT_ENTRIES > lut
Definition: imageColor.hpp:80
imageIO.hpp
ddt::scalingLut_t
struct ddt::scalingLut_t scalingLut_t
ddt::ImageColor::get_SqrtScalingLut
ddt::scalingLut_t * get_SqrtScalingLut(const double cut_level_min, const double cut_level_max)
Definition: imageColor.cpp:312
ddt::ImageColor::get_GrayScaleColorMap
ddt::colorMap_t * get_GrayScaleColorMap()
Definition: imageColor.cpp:224
ddt::scalingLut_t::factor
double factor
Definition: imageColor.hpp:90
ddt::ImageColor::get_LinearScalingLut
ddt::scalingLut_t * get_LinearScalingLut(const double cut_level_min, const double cut_level_max)
Definition: imageColor.cpp:238
ddt::ImageColor::~ImageColor
virtual ~ImageColor()
ddt::ImageColor::get_LogarithmicScalingLut
ddt::scalingLut_t * get_LogarithmicScalingLut(const double cut_level_min, const double cut_level_max)
Definition: imageColor.cpp:277
imageError.hpp
ddt::ImageColor::get_ColorMapsList
std::list< std::string > get_ColorMapsList() const
Definition: imageColor.cpp:185
dataAcquisition.hpp
ddt::ImageColor::get_ColorMap
ddt::colorMap_t * get_ColorMap(const std::string color_map_name)
Definition: imageColor.cpp:197
ddt::scalingLut_t::offset
double offset
Definition: imageColor.hpp:85
imageStats.hpp
ddtLogger.hpp
ddt::MAX_COLOR_MAP_VALUE
constexpr size_t MAX_COLOR_MAP_VALUE
Definition: imageColor.hpp:45
ddt::ImageColor::set_logger
void set_logger(ddt::DdtLogger *const in_logger)
Definition: imageColor.cpp:33
ddt::colorMap_t
std::array< std::array< float, COLOR_MAP_ENTRY_SIZE >, MAX_COLOR_MAP_ENTRIES > colorMap_t
Definition: imageColor.hpp:56
dataFile.hpp
ddt::MAX_COLOR_MAP_ENTRIES
constexpr size_t MAX_COLOR_MAP_ENTRIES
Definition: imageColor.hpp:44
ddt::MAX_SCALING_LUT_VALUE
constexpr uint MAX_SCALING_LUT_VALUE
Definition: imageColor.hpp:43
ddt::ImageColor::LoadColorMaps
void LoadColorMaps(const std::string color_map_folder)
Definition: imageColor.cpp:117
ddt::ImageColor::get_GrayScaleColorMapARGB
ddt::colorMapARGB_t * get_GrayScaleColorMapARGB()
Definition: imageColor.cpp:231
ddt::COLOR_MAP_ENTRY_SIZE
constexpr size_t COLOR_MAP_ENTRY_SIZE
Definition: imageColor.hpp:46
ddt::MAX_SCALING_LUT_ENTRIES
constexpr size_t MAX_SCALING_LUT_ENTRIES
Definition: imageColor.hpp:42