12#include "config-kstars.h"
15#ifdef HAVE_STELLARSOLVER
16#include <structuredefinitions.h>
18#include "structuredefinitions.h"
21#include "kstarsdatetime.h"
23#include "skybackground.h"
24#include "fitscommon.h"
25#include "fitsstardetector.h"
26#include "auxiliary/imagemask.h"
39#include <QTemporaryFile>
42#include <kxmlguiwindow.h>
48#include "fitsskyobject.h"
82 explicit FITSData(FITSMode
fitsMode = FITS_NORMAL);
130 bool parseSolution(FITSImage::Solution &solution)
const;
136 void clearImageBuffers();
137 void setImageBuffer(uint8_t *buffer);
138 uint8_t
const *getImageBuffer()
const;
139 uint8_t *getWritableImageBuffer();
147 void calculateStats(
bool refresh =
false,
bool roi =
false);
148 void saveStatistics(FITSImage::Statistic &
other);
149 void restoreStatistics(FITSImage::Statistic &
other);
150 FITSImage::Statistic
const &getStatistics()
const
155 uint16_t width(
bool roi =
false)
const
157 return roi ? m_ROIStatistics.width : m_Statistics.width;
159 uint16_t height(
bool roi =
false)
const
161 return roi ? m_ROIStatistics.height : m_Statistics.height;
163 int64_t size(
bool roi =
false)
const
165 return roi ? m_ROIStatistics.size : m_Statistics.size;
169 return m_Statistics.channels;
171 uint32_t samplesPerChannel(
bool roi =
false)
const
173 return roi ? m_ROIStatistics.samples_per_channel : m_Statistics.samples_per_channel;
175 uint32_t dataType()
const
177 return m_Statistics.dataType;
179 double getMin(uint8_t channel = 0,
bool roi =
false)
const
181 return roi ? m_ROIStatistics.min[channel] : m_Statistics.min[channel];
183 double getMax(uint8_t channel = 0,
bool roi =
false)
const
185 return roi ? m_ROIStatistics.max[channel] : m_Statistics.max[channel];
188 void setMinMax(
double newMin,
double newMax, uint8_t channel = 0);
189 void getMinMax(
double *min,
double *max, uint8_t channel = 0)
const
191 *min = m_Statistics.min[channel];
192 *max = m_Statistics.max[channel];
194 void setStdDev(
double value, uint8_t channel = 0)
196 m_Statistics.stddev[channel] = value;
198 double getStdDev(uint8_t channel = 0,
bool roi =
false )
const
200 return roi ? m_ROIStatistics.stddev[channel] : m_Statistics.stddev[channel];
202 double getAverageStdDev(
bool roi =
false)
const;
203 void setMean(
double value, uint8_t channel = 0)
205 m_Statistics.mean[channel] = value;
207 double getMean(uint8_t channel = 0,
bool roi =
false)
const
209 return roi ? m_ROIStatistics.mean[channel] : m_Statistics.mean[channel];
213 double getAverageMean(
bool roi =
false)
const;
214 void setMedian(
double val, uint8_t channel = 0)
216 m_Statistics.median[channel] = val;
220 double getAverageMedian(
bool roi =
false)
const;
221 double getMedian(uint8_t channel = 0,
bool roi =
false)
const
223 return roi ? m_ROIStatistics.median[channel] : m_Statistics.median[channel];
226 int getBytesPerPixel()
const
228 return m_Statistics.bytesPerPixel;
230 void setSNR(
double val)
232 m_Statistics.SNR = val;
234 double getSNR()
const
236 return m_Statistics.SNR;
240 switch(m_Statistics.dataType)
258 double getADU()
const;
269 return m_HeaderRecords;
278 void setStarAlgorithm(StarAlgorithm algorithm)
280 starAlgorithm = algorithm;
282 int getDetectedStars()
const
284 return starCenters.
count();
286 bool areStarsSearched()
const
288 return starsSearched;
307 void setSkyBackground(
const SkyBackground &bg)
309 m_SkyBackground = bg;
311 const SkyBackground &getSkyBackground()
const
313 return m_SkyBackground;
315 const QVariantMap &getSourceExtractorSettings()
const
317 return m_SourceExtractorSettings;
319 void setSourceExtractorSettings(
const QVariantMap &settings)
321 m_SourceExtractorSettings = settings;
324 template <
typename T>
325 void getFloatBuffer(
float *buffer,
int x,
int y,
int w,
int h)
const;
332 const Edge &getSelectedHFRStar()
const
334 return m_SelectedHFRStar;
338 double getEccentricity();
340 double getHFR(HFRType type = HFR_AVERAGE);
341 double getHFR(
int x,
int y,
double scale = 1.0);
360 const QPoint getRoiCenter()
const
365 void setRoiCenter(
QPoint c)
376 bool contains(
const QPointF &point)
const;
385 WCSState getWCSState()
const
415 void injectWCS(
double orientation,
double ra,
double dec,
double pixscale,
bool eastToTheRight);
434 bool debayer(
bool reload =
false);
436 bool debayer_16bit();
437 void getBayerParams(BayerParams *
param);
438 void setBayerParams(BayerParams *
param);
446 void resetHistogram()
448 m_HistogramConstructed =
false;
450 double getHistogramBinWidth(
int channel = 0)
452 return m_HistogramBinWidth[channel];
458 return m_CumulativeFrequency[channel];
463 const QVector<double> &getHistogramIntensity(uint8_t channel = 0)
const
465 return m_HistogramIntensity[channel];
467 const QVector<double> &getHistogramFrequency(uint8_t channel = 0)
const
469 return m_HistogramFrequency[channel];
471 int getHistogramBinCount()
const
473 return m_HistogramBinCount;
477 int32_t histogramBin(
int x,
int y,
int channel)
const;
483 double getJMIndex()
const
488 bool isHistogramConstructed()
const
490 return m_HistogramConstructed;
492 void constructHistogram();
504 int getRotCounter()
const;
505 void setRotCounter(
int value);
508 const QString &filename()
const
512 const QString &compressedFilename()
const
514 return m_compressedFilename;
516 bool isCompressed()
const
518 return m_isCompressed;
521 const QString &extension()
const
527 int getFlipHCounter()
const;
528 void setFlipHCounter(
int value);
531 int getFlipVCounter()
const;
532 void setFlipVCounter(
int value);
570 static bool readableFilename(
const QString &filename);
578 void histogramReady();
597 bool loadCanonicalImage(
const QByteArray &buffer);
599 bool loadFITSImage(
const QByteArray &buffer,
const bool isCompressed =
false);
607 void rotWCSFITS(
int angle,
int mirror);
608 void calculateMinMax(
bool refresh =
false,
bool roi =
false);
609 void calculateMedian(
bool refresh =
false,
bool roi =
false);
614 void recordLastError(
int errorCode);
622 template <
typename T>
625 template <
typename T>
626 bool rotFITS(
int rotate,
int mirror);
629 template <
typename T>
632 template <
typename T>
633 void calculateMinMax(
bool roi =
false);
634 template <
typename T>
635 void calculateMedian(
bool roi =
false);
637 template <
typename T>
638 QPair<T, T> getParitionMinMax(uint32_t start, uint32_t stride,
bool roi);
642 template <
typename T>
644 template <
typename T>
645 void gaussianBlur(
int kernelSize,
double sigma);
648 template <
typename T>
649 void calculateStdDev(
bool roi =
false );
651 template <
typename T>
659 template <
typename T>
void constructHistogramInternal();
660 template <
typename T> int32_t histogramBinInternal(T value,
int channel)
const;
661 template <
typename T> int32_t histogramBinInternal(
int x,
int y,
int channel)
const;
666 uint8_t *m_ImageBuffer {
nullptr };
668 uint32_t m_ImageBufferSize { 0 };
670 uint8_t *m_ImageRoiBuffer {
nullptr };
672 uint32_t m_ImageRoiBufferSize { 0 };
674 bool m_isTemporary {
false };
676 bool m_isCompressed {
false };
678 bool starsSearched {
false };
680 StarAlgorithm starAlgorithm { ALGORITHM_GRADIENT };
682 bool HasWCS {
false };
684 bool HasDebayer {
false };
686 uint8_t *m_PackBuffer {
nullptr};
689 QString m_Filename, m_compressedFilename, m_Extension;
696 int rotCounter { 0 };
698 int flipHCounter { 0 };
700 int flipVCounter { 0 };
703 struct wcsprm *m_WCSHandle
709 WCSState m_WCSState { Idle };
714 Edge m_SelectedHFRStar;
717 BayerParams debayerParams;
724 FITSImage::Statistic m_Statistics;
725 FITSImage::Statistic m_ROIStatistics;
731 bool m_ObjectsSearched {
false};
744 uint16_t m_HistogramBinCount { 0 };
745 double m_JMIndex { 1 };
746 bool m_HistogramConstructed {
false };
754 SkyBackground m_SkyBackground;
756 QVariantMap m_SourceExtractorSettings;
761 double cacheHFR { -1 };
762 HFRType cacheHFRType { HFR_AVERAGE };
763 double cacheEccentricity { -1 };
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
The sky coordinates of a point in the sky.
void append(QList< T > &&value)
qsizetype count() const const
Object to hold FITS Header records.
QString comment
FITS Header Value.
QVariant value
FITS Header Key.