SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
meta.h
Go to the documentation of this file.
1#pragma once
2
7
8#include "image.h"
9#include "nlohmann/json.hpp"
10
11namespace satdump
12{
13 namespace image
14 {
20 bool has_metadata(Image &img);
21
27 void set_metadata(Image &img, nlohmann::json metadata);
28
34 nlohmann::json get_metadata(const Image &img);
35
40 void free_metadata(const Image &img);
41
47 bool has_metadata_proj_cfg(Image &img);
48
54 void set_metadata_proj_cfg(Image &img, nlohmann::json proj_cfg);
55
61 nlohmann::json get_metadata_proj_cfg(const Image &img);
62
74 {
75 std::string unit;
76 double scale = 0;
77 double offset = 0;
78
79 double min = 0, max = 0;
80
81 friend void to_json(nlohmann::json &j, const ImgCalibHandler &v)
82 {
83 j["unit"] = v.unit;
84
85 if (v.offset == 0 && v.scale == 0)
86 {
87 j["offset"] = v.min;
88 j["scale"] = v.max - v.min;
89 }
90 else
91 {
92 j["offset"] = v.offset;
93 j["scale"] = v.scale;
94 }
95 }
96
97 friend void from_json(const nlohmann::json &j, ImgCalibHandler &v)
98 {
99 v.unit = j["unit"];
100 if (j.contains("offset"))
101 v.offset = j["offset"];
102 if (j.contains("scale"))
103 v.scale = j["scale"];
104
105 v.min = v.offset;
106 v.max = v.offset + v.scale;
107 }
108
114 inline double getVal(double img_val) { return img_val * scale + offset; }
115
121 inline double setVal(double cal_val) { return (cal_val - offset) / scale; }
122 };
123
129 bool has_metadata_calib_cfg(Image &img);
130
136 void set_metadata_calib_cfg(Image &img, nlohmann::json calib_cfg);
137
143 nlohmann::json get_metadata_calib_cfg(const Image &img);
144 } // namespace image
145} // namespace satdump
Definition image.h:17
Core Image class.
Image Calibration Handler. This handles converting between raw pixel values and calibrated/physical u...
Definition meta.h:74
double setVal(double cal_val)
Convert from calibrated value to raw image value.
Definition meta.h:121
double getVal(double img_val)
Convert from raw image value to calibration.
Definition meta.h:114