Kstars

defectmap.h
1/*
2 SPDX-FileCopyrightText: 2021 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <set>
10#include <QJsonObject>
11#include <QJsonArray>
12
13#include "fitsviewer/fitsdata.h"
14
15class BadPixel
16{
17 public:
18 BadPixel() {};
19 explicit BadPixel(uint16_t _x, uint16_t _y, double _value) : x(_x), y(_y), value(_value) {}
20 bool operator<(const BadPixel &rhs) const
21 {
22 return value < rhs.value;
23 }
24 QJsonObject json() const;
25 uint16_t x{0}, y{0};
26 double value {0};
27};
28
29typedef std::multiset<BadPixel> BadPixelSet;
30
31class DefectMap : public QObject
32{
34
35 // Hot Pixels Aggressiveness
36 Q_PROPERTY(int HotPixelAggressiveness MEMBER m_HotPixelsAggressiveness)
37 // Cold Pixels Aggressiveness
38 Q_PROPERTY(int ColdPixelAggressiveness MEMBER m_ColdPixelsAggressiveness)
39 // Hot Pixels Enabled
40 Q_PROPERTY(bool HotEnabled READ hotEnabled WRITE setHotEnabled)
41 // Cold Pixels Enabled
42 Q_PROPERTY(bool ColdEnabled READ coldEnabled WRITE setColdEnabled)
43
44 public:
45 DefectMap();
46
47 void setHotEnabled(bool enabled);
48 void setColdEnabled(bool enabled);
49 void setDarkData(const QSharedPointer<FITSData> &data);
50 bool load(const QString &filename);
51 bool save(const QString &filename, const QString &camera);
52 void initBadPixels();
53
54 const BadPixelSet &hotPixels() const
55 {
56 return m_HotPixels;
57 }
58 const BadPixelSet &coldPixels() const
59 {
60 return m_ColdPixels;
61 }
62
63 bool hotEnabled() const
64 {
65 return m_HotEnabled;
66 }
67 bool coldEnabled() const
68 {
69 return m_ColdEnabled;
70 }
71 const QString &filename() const
72 {
73 return m_Filename;
74 }
75
76 const BadPixelSet::const_iterator hotThreshold() const
77 {
78 return (m_HotEnabled ? m_HotPixelsThreshold : m_HotPixels.end());
79 }
80 const BadPixelSet::const_iterator coldThreshold() const
81 {
82 return (m_ColdEnabled ? m_ColdPixelsThreshold : m_ColdPixels.begin());
83 }
84 uint32_t hotCount() const
85 {
86 return m_HotPixelsCount;
87 }
88 uint32_t coldCount() const
89 {
90 return m_ColdPixelsCount;
91 }
92
93 void filterPixels();
94 signals:
95 // void hotPixelsUpdated(const BadPixelSet::const_iterator &start, const BadPixelSet::const_iterator &end);
96 // void coldPixelsUpdated(const BadPixelSet::const_iterator &start, const BadPixelSet::const_iterator &end);
97 void pixelsUpdated(uint32_t hotPixelsCount, uint32_t coldPixelsCount);
98
99 private:
100 double getHotThreshold(uint8_t aggressiveness);
101 double getColdThreshold(uint8_t aggressiveness);
102 double calculateSigma(uint8_t aggressiveness);
103 template <typename T>
104 void initBadPixelsInternal(double hotPixelThreshold, double coldPixelThreshold);
105
106 BadPixelSet m_ColdPixels, m_HotPixels;
107 BadPixelSet::const_iterator m_ColdPixelsThreshold, m_HotPixelsThreshold;
108 uint8_t m_HotPixelsAggressiveness {75}, m_ColdPixelsAggressiveness {75};
109 uint32_t m_HotPixelsCount {0}, m_ColdPixelsCount {0};
110 double m_HotSigma {0}, m_ColdSigma {0};
111 double m_Median {0}, m_StandardDeviation {0};
112 bool m_HotEnabled {true}, m_ColdEnabled {true};
113 QString m_Filename, m_Camera;
114
115 QSharedPointer<FITSData> m_DarkData;
116
117};
118
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.