diff --git a/kstars/fitsviewer/fitsdata.cpp b/kstars/fitsviewer/fitsdata.cpp --- a/kstars/fitsviewer/fitsdata.cpp +++ b/kstars/fitsviewer/fitsdata.cpp @@ -4224,6 +4224,8 @@ int FITSData::findSEPStars(const QRect &boundary) { int x = 0, y = 0, w = stats.width, h = stats.height, maxRadius = 50; + std::vector> ovals; + const int maxNumCenters = 100; if (!boundary.isNull()) { @@ -4236,31 +4238,31 @@ auto * data = new float[w * h]; - switch (stats.bitpix) + switch (m_DataType) { - case BYTE_IMG: + case TBYTE: getFloatBuffer(data, x, y, w, h); break; - case SHORT_IMG: + case TSHORT: getFloatBuffer(data, x, y, w, h); break; - case USHORT_IMG: + case TUSHORT: getFloatBuffer(data, x, y, w, h); break; - case LONG_IMG: + case TLONG: getFloatBuffer(data, x, y, w, h); break; - case ULONG_IMG: + case TULONG: getFloatBuffer(data, x, y, w, h); break; - case FLOAT_IMG: + case TFLOAT: delete [] data; data = reinterpret_cast(m_ImageBuffer); break; - case LONGLONG_IMG: + case TLONGLONG: getFloatBuffer(data, x, y, w, h); break; - case DOUBLE_IMG: + case TDOUBLE: getFloatBuffer(data, x, y, w, h); break; default: @@ -4306,8 +4308,22 @@ // Must limit to brightest 100 (by flux) centers // Should probably use ellipse to draw instead of simple circle? // Useful for galaxies and also elenogated stars. + + // Find the oval sizes for each detection in the detected star catalog, and sort by that. Oval size + // correlates very well with HFR, so we don't need to call sep_flux_radius on all detections later + // to find the maxNumCenters largest stars. This can save a lot of time. for (int i = 0; i < catalog->nobj; i++) { + const double ovalSizeSq = catalog->a[i]*catalog->a[i] + catalog->b[i]*catalog->b[i]; + ovals.push_back(std::pair(i, ovalSizeSq)); + } + std::sort(ovals.begin(), ovals.end(), [](const std::pair& o1, const std::pair& o2) -> bool { return o1.second > o2.second;}); + + // Go through the largest (by oval size) detections and compute the HFR for the first maxNumCenters. + for (int index = 0; index < catalog->nobj; index++) + { + if (index >= maxNumCenters) break; + int i = ovals[index].first; double flux = catalog->flux[i]; // Get HFR sep_flux_radius(&im, catalog->x[i], catalog->y[i], maxRadius, 5, 0, &flux, requested_frac, 2, flux_fractions, &flux_flag); @@ -4324,11 +4340,11 @@ } // Let's sort edges, starting with widest - std::sort(edges.begin(), edges.end(), [](const Edge * edge1, const Edge * edge2) -> bool { return edge1->width > edge2->width;}); + std::sort(edges.begin(), edges.end(), [](const Edge * edge1, const Edge * edge2) -> bool { return edge1->HFR > edge2->HFR;}); // Take only the first 100 stars { - int starCount = qMin(100, edges.count()); + int starCount = qMin(maxNumCenters, edges.count()); for (int i = 0; i < starCount; i++) starCenters.append(edges[i]); } @@ -4358,7 +4374,6 @@ qCritical(KSTARS_FITS) << errorMessage; return -1; } - return starCenters.count(); } diff --git a/kstars/fitsviewer/fitstab.cpp b/kstars/fitsviewer/fitstab.cpp --- a/kstars/fitsviewer/fitstab.cpp +++ b/kstars/fitsviewer/fitstab.cpp @@ -442,11 +442,11 @@ histogram->constructHistogram(); } - evaluateStats(); - if (viewer->isStarsMarked()) view->toggleStars(true); + evaluateStats(); + loadFITSHeader(); // Don't add it to the list if it is already there diff --git a/kstars/fitsviewer/fitsview.cpp b/kstars/fitsviewer/fitsview.cpp --- a/kstars/fitsviewer/fitsview.cpp +++ b/kstars/fitsviewer/fitsview.cpp @@ -1447,10 +1447,10 @@ QApplication::setOverrideCursor(Qt::WaitCursor); emit newStatus(i18n("Finding stars..."), FITS_MESSAGE); qApp->processEvents(); - int count = findStars(); + int count = findStars(ALGORITHM_SEP); if (count >= 0 && isVisible()) - emit newStatus(i18np("1 star detected.", "%1 stars detected.", count), FITS_MESSAGE); + emit newStatus(i18np("1 star detected. HFR=%2", "%1 stars detected. HFR=%2", count, imageData->getHFR()), FITS_MESSAGE); QApplication::restoreOverrideCursor(); } } diff --git a/kstars/fitsviewer/fitsviewer.cpp b/kstars/fitsviewer/fitsviewer.cpp --- a/kstars/fitsviewer/fitsviewer.cpp +++ b/kstars/fitsviewer/fitsviewer.cpp @@ -560,7 +560,8 @@ view->updateFrame(); if (markStars) - updateStatusBar(i18np("%1 star detected.", "%1 stars detected.", view->getImageData()->getDetectedStars()), + updateStatusBar(i18np("%1 star detected. HFR=%2", "%1 stars detected. HFR=%2", + view->getImageData()->getDetectedStars(), view->getImageData()->getHFR()), FITS_MESSAGE); else updateStatusBar("", FITS_MESSAGE);