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 #include <cpl.h>
28 #undef I
29 #undef arg
30 
31 #include "ddt/dataAcquisition.hpp"
32 #include "ddt/dataFile.hpp"
33 #include "ddt/ddtLogger.hpp"
34 #include "ddt/imageError.hpp"
35 #include "ddt/imageIO.hpp"
36 #include "ddt/imageProc.hpp"
37 #include "ddt/imageStats.hpp"
38 
39 namespace ddt {
40 
41 constexpr size_t MAX_SCALING_LUT_ENTRIES = 65536;
42 constexpr uint MAX_SCALING_LUT_VALUE = 65535;
43 constexpr size_t MAX_COLOR_MAP_ENTRIES = 256;
44 constexpr size_t COLOR_MAP_ENTRY_SIZE = 3;
45 
52 typedef std::array<std::array<float, COLOR_MAP_ENTRY_SIZE>, MAX_COLOR_MAP_ENTRIES> colorMap_t;
53 
62 typedef std::array<unsigned int, MAX_COLOR_MAP_ENTRIES> colorMapARGB_t;
63 
72 typedef struct scalingLut_t {
76  std::array<uint, MAX_SCALING_LUT_ENTRIES> lut;
81  double offset;
86  double factor;
88 
95 class ImageColor {
96  public:
101  ImageColor();
102 
106  virtual ~ImageColor();
107 
113 
118  void LoadColorMaps(std::string color_map_folder);
119 
124  std::list<std::string> get_ColorMapsList();
125 
134  ddt::colorMap_t* get_ColorMap(std::string color_map_name);
135 
144  ddt::colorMapARGB_t* get_ColorMapARGB(std::string color_map_name);
145 
153 
161 
170  ddt::scalingLut_t* get_LinearScalingLut(const double cut_level_min,
171  const double cut_level_max);
172 
181  ddt::scalingLut_t* get_LogarithmicScalingLut(const double cut_level_min,
182  const double cut_level_max);
183 
192  ddt::scalingLut_t* get_SqrtScalingLut(const double cut_level_min,
193  const double cut_level_max);
194 
195  protected:
200 
201  private:
205  void initialize();
206 
210  void loadColorMap(std::string color_map_name);
211 
215  void loadGrayScaleColorMap();
216 
220  std::unordered_map<std::string, ddt::colorMap_t> colorMaps;
221 
225  std::unordered_map<std::string, ddt::colorMapARGB_t> colorMapsARGB;
226 
230  scalingLut_t linearScalingLut;
231 
235  scalingLut_t logScalingLut;
236 
240  scalingLut_t sqrtScalingLut;
241 };
242 
243 } // namespace ddt
244 
245 #endif /* IMAGECOLOR_HPP */
imageProc.hpp
ddt::scalingLut_t
Definition: imageColor.hpp:72
ddt::DdtLogger
Definition: ddtLogger.hpp:71
ddt
Definition: ddtClient.hpp:36
ddt::ImageColor
Definition: imageColor.hpp:95
ddt::ImageColor::ImageColor
ImageColor()
Definition: imageColor.cpp:28
ddt::colorMapARGB_t
std::array< unsigned int, MAX_COLOR_MAP_ENTRIES > colorMapARGB_t
Definition: imageColor.hpp:62
ddt::ImageColor::logger
ddt::DdtLogger * logger
Definition: imageColor.hpp:199
ddt::ImageColor::get_ColorMapARGB
ddt::colorMapARGB_t * get_ColorMapARGB(std::string color_map_name)
Definition: imageColor.cpp:187
ddt::scalingLut_t::lut
std::array< uint, MAX_SCALING_LUT_ENTRIES > lut
Definition: imageColor.hpp:76
ddt::ImageColor::LoadColorMaps
void LoadColorMaps(std::string color_map_folder)
Definition: imageColor.cpp:96
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:293
ddt::ImageColor::get_GrayScaleColorMap
ddt::colorMap_t * get_GrayScaleColorMap()
Definition: imageColor.cpp:199
ddt::scalingLut_t::factor
double factor
Definition: imageColor.hpp:86
ddt::ImageColor::get_LinearScalingLut
ddt::scalingLut_t * get_LinearScalingLut(const double cut_level_min, const double cut_level_max)
Definition: imageColor.cpp:211
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:252
imageError.hpp
ddt::ImageColor::get_ColorMap
ddt::colorMap_t * get_ColorMap(std::string color_map_name)
Definition: imageColor.cpp:175
dataAcquisition.hpp
ddt::scalingLut_t::offset
double offset
Definition: imageColor.hpp:81
imageStats.hpp
ddt::ImageColor::set_logger
void set_logger(ddt::DdtLogger *logger)
Definition: imageColor.cpp:33
ddt::ImageColor::get_ColorMapsList
std::list< std::string > get_ColorMapsList()
Definition: imageColor.cpp:164
ddtLogger.hpp
ddt::colorMap_t
std::array< std::array< float, COLOR_MAP_ENTRY_SIZE >, MAX_COLOR_MAP_ENTRIES > colorMap_t
Definition: imageColor.hpp:52
dataFile.hpp
ddt::MAX_COLOR_MAP_ENTRIES
constexpr size_t MAX_COLOR_MAP_ENTRIES
Definition: imageColor.hpp:43
ddt::MAX_SCALING_LUT_VALUE
constexpr uint MAX_SCALING_LUT_VALUE
Definition: imageColor.hpp:42
ddt::ImageColor::get_GrayScaleColorMapARGB
ddt::colorMapARGB_t * get_GrayScaleColorMapARGB()
Definition: imageColor.cpp:205
ddt::COLOR_MAP_ENTRY_SIZE
constexpr size_t COLOR_MAP_ENTRY_SIZE
Definition: imageColor.hpp:44
ddt::MAX_SCALING_LUT_ENTRIES
constexpr size_t MAX_SCALING_LUT_ENTRIES
Definition: imageColor.hpp:41