SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
image_calibrator.h
1#pragma once
2
3#include "../image_product.h" // TODOREWORK remove?
4#include "calibration_units.h"
5#include "nlohmann/json.hpp"
6
7namespace satdump
8{
9 namespace products
10 {
11 class ImageCalibrator
12 {
13 protected:
14 ImageProduct *d_pro;
15 nlohmann::json d_cfg;
16
17 private:
18 int depth_diff = 0;
19 uint32_t val = 0;
20
21 public:
22 ImageCalibrator(ImageProduct *p, nlohmann::json c) : d_pro(p), d_cfg(c) {}
23
24 inline double compute(int idx, int x, int y)
25 {
26 auto &i = d_pro->images[idx];
27 if (0 <= x && x < i.image.width() && 0 <= y && y < i.image.height())
28 {
29 val = d_pro->get_raw_channel_val(idx, x, y);
30 return compute(i.abs_index, x, y, val);
31 }
32 else
33 return CALIBRATION_INVALID_VALUE;
34 }
35
36 protected:
37 virtual double compute(int abs_idx, int x, int y, uint32_t val) = 0;
38 };
39
41 {
42 std::string id;
43 std::vector<std::shared_ptr<ImageCalibrator>> &calibrators;
44 ImageProduct *products;
45 nlohmann::json calib;
46 };
47
48 std::shared_ptr<ImageCalibrator> get_calibrator_from_product(ImageProduct *p);
49 image::Image generate_calibrated_product_channel(ImageProduct *product, std::string channel_name, double range_min, double range_max, std::string output_unit = "", float *progess = nullptr);
50 } // namespace products
51} // namespace satdump
Definition image.h:17
SatDump image product class.
Definition image_product.h:42
ImageProduct implementation.
Definition image_calibrator.h:41