Kstars

darkprocessor.h
1/*
2 SPDX-FileCopyrightText: 2016 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "indi/indicamera.h"
10#include "indi/indidustcap.h"
11#include "darkview.h"
12#include "defectmap.h"
13#include "ekos/ekos.h"
14
15#include <QFutureWatcher>
16
17class TestDefects;
18class TestSubtraction;
19
20namespace Ekos
21{
22
23/**
24 * @brief The DarkProcessor class
25 *
26 * Denoises a light image by either subtracting a dark frame or applying a defect map.
27 *
28 * The primary denoise function searches first for defect maps that matches the criteria of the passed parameters.
29 * These include sensor binning, size, temperature, and date. If a defect map is found, then it is loaded from disk and all the bad
30 * pixels are treated with a 3x3 median filter. If no defect map is found, it searches for suitable dark frames and if any is found then
31 * a simple subtraction is applied.
32 *
33 * @author Jasem Mutlaq
34 * @version 1.0
35 */
36class DarkProcessor : public QObject
37{
39 public:
40 explicit DarkProcessor(QObject *parent = nullptr);
41
42 // Perform defect correction or dark subtraction
43 void denoise(int trainID, ISD::CameraChip *targetChip, const QSharedPointer<FITSData> &targetData, double duration,
44 uint16_t offsetX, uint16_t offsetY);
45
46
47 private:
48
49 // Denoise Internal
50 bool denoiseInternal(bool useDefect);
51 void processDenoiseResult();
52
53 ////////////////////////////////////////////////////////////////////////////////////////////////
54 /// Subtraction Functions
55 ////////////////////////////////////////////////////////////////////////////////////////////////
56
57 /**
58 * @brief subtractHelper Calls tempelated subtract function
59 * @param darkData passes dark frame data to templerated subtract function.
60 * @param lightData passes list frame data to templerated subtract function.
61 * @param offsetX passes offsetX to templerated subtract function.
62 * @param offsetY passes offsetY to templerated subtract function.
63 */
64 void subtractDarkData(const QSharedPointer<FITSData> &darkData, const QSharedPointer<FITSData> &lightData,
65 uint16_t offsetX, uint16_t offsetY);
66
67 /**
68 * @brief subtract Subtracts dark pixels from light pixels given the supplied parameters
69 * @param darkData Dark frame data.
70 * @param lightData Light frame data. The light frame data is modified in this process.
71 * @param offsetX Only apply subtraction beyond offsetX in X-axis.
72 * @param offsetY Only apply subtraction beyond offsetY in Y-axis.
73 */
74 template <typename T>
75 void subtractInternal(const QSharedPointer<FITSData> &darkData, const QSharedPointer<FITSData> &lightData,
76 uint16_t offsetX, uint16_t offsetY);
77
78 ////////////////////////////////////////////////////////////////////////////////////////////////
79 /// Defect Map Functions
80 ////////////////////////////////////////////////////////////////////////////////////////////////
81
82 /**
83 * @brief normalizeDefects Remove defects from LIGHT image by replacing bad pixels with a 3x3 median filter around
84 * them.
85 * @param defectMap Defect Map containing a list of hot and cold pixels.
86 * @param lightData Target light data to remove noise from.
87 * @param offsetX Only apply filtering beyond offsetX in X-axis.
88 * @param offsetY Only apply filtering beyond offsetX in Y-axis.
89 */
90 void normalizeDefects(const QSharedPointer<DefectMap> &defectMap, const QSharedPointer<FITSData> &lightData,
91 uint16_t offsetX, uint16_t offsetY);
92
93 template <typename T>
94 void normalizeDefectsInternal(const QSharedPointer<DefectMap> &defectMap, const QSharedPointer<FITSData> &lightData,
95 uint16_t offsetX, uint16_t offsetY);
96
97 template <typename T>
98 T median3x3Filter(uint16_t x, uint16_t y, uint32_t width, T *buffer);
99
100 signals:
101 void darkFrameCompleted(bool);
102 void newLog(const QString &message);
103
104 private:
105 QFutureWatcher<bool> m_Watcher;
106 struct
107 {
108 int trainID;
109 ISD::CameraChip *targetChip;
110 QSharedPointer<FITSData> targetData;
111 double duration;
112 uint16_t offsetX;
113 uint16_t offsetY;
114 } info;
115
116
117 // Testing
118 friend class ::TestDefects;
119 friend class ::TestSubtraction;
120
121};
122
123}
124
The DarkProcessor class.
CameraChip class controls a particular chip in camera.
Ekos is an advanced Astrophotography tool for Linux.
Definition align.cpp:78
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:02 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.