Warning, file /education/kstars/kstars/ekos/focus/focusstars.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2021 Hy Murveit <hy-1@murveit.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QList>
0010 #include "../fitsviewer/fitsstardetector.h"
0011 
0012 namespace Ekos
0013 {
0014 
0015 // This class helps compare HFRs computed from two images. The issue is that the two images
0016 // may have different stars detected, and thus when comparing HFRs one may have smaller
0017 // stars than the other, and be at an advantage wrt HFR computation.
0018 // If we only use stars that the two star lists have in common, then comparisons are more fair.
0019 
0020 // FocusStars is a object with a set of stars: star x,y positions and the computed HFRs for each star.
0021 // getHFR() computes an overall HFR value using all stars in the FocusStars object.
0022 // FocusStars.commonHFR(focusStars2, hfr1, hfr2) computes HFRs only using stars in common
0023 // with focusStars2.
0024 // FocusStars.relativeHFR(focusStars2, givenHFRValue) returns an hfr which is a scaled
0025 // version of givenHFRValue, scaled by the ratio of the commonHFR
0026 // between the two focusStars lists.
0027 
0028 class FocusStars
0029 {
0030     public:
0031         // The list of stars is not modified after the constructor.
0032         // Stars whose positions are further apart than maxDistance (after
0033         // overall image translation) cannot be considered the same stars.
0034         FocusStars(const QList<Edge *> edges, double maDistance = 10.0);
0035         FocusStars(const QList<Edge> edges, double maxDistance = 10.0);
0036         FocusStars() {}
0037 
0038         // Returns the median HFR for all the stars in this object.
0039         // Uses all the stars in the object.
0040         double getHFR() const;
0041 
0042         // Computes the HFRs of this list of stars and focusStars2's list.
0043         // It just uses the common stars in both lists.
0044         bool commonHFR(const FocusStars &focusStars2, double *hfr, double *hfr2) const;
0045 
0046         // Given an HFR value for focusStars2, come up with an HFR value for this
0047         // object. The number it computes will be relatively correct (e.g. if this
0048         // FocusStars is more in focus than FocusStars2, then it will return a
0049         // lower HFR value than hfrForList2, and if it is worse, the hfr will be higher.
0050         // It will return something proportionally correct, however the number
0051         // returned likely won't be the standard HFR value computed for all stars.
0052         double relativeHFR(const FocusStars &focusStars2, double hfrForStars2) const;
0053 
0054         // Returns a reference to all the stars.
0055         const QList<Edge> &getStars() const
0056         {
0057             return stars;
0058         };
0059 
0060         // debug
0061         void printStars(const QString &label) const;
0062 
0063     private:
0064 
0065         QList<Edge> stars;
0066 
0067         // Cached HFR computed on all the stars.
0068         mutable double computedHFR = -1;
0069 
0070         // Default max distance to consider two star positions the same star.
0071         double maxDistance = 5;
0072         bool initialized = false;
0073 };
0074 }