Draw circles around peaks
This commit is contained in:
+27
-1
@@ -3,6 +3,7 @@
|
||||
#include <libraw/libraw.h>
|
||||
#include "imageinfo.h"
|
||||
#include <QFileInfo>
|
||||
#include <QPainter>
|
||||
#include <libexif/exif-data.h>
|
||||
#include <fitsio2.h>
|
||||
#include "rawimage.h"
|
||||
@@ -25,6 +26,18 @@ void loadExifEntry(ImageInfoData &info, ExifContent *content, ExifTag tag)
|
||||
}
|
||||
}
|
||||
|
||||
void drawPeaks(QImage &img, const std::vector<Peak> &peaks, bool half)
|
||||
{
|
||||
QPixmap pix = QPixmap::fromImage(img);
|
||||
QPainter painter(&pix);
|
||||
painter.setPen(Qt::red);
|
||||
for(auto peak : peaks)
|
||||
{
|
||||
painter.drawEllipse(QPoint(peak.x(), peak.y()), 5, 5);
|
||||
}
|
||||
img = pix.toImage();
|
||||
}
|
||||
|
||||
bool loadRAW(QString path, ImageInfoData &info, RawImageAbs **image, QImage *qimage)
|
||||
{
|
||||
if(!image && !qimage)
|
||||
@@ -231,7 +244,7 @@ void LoadRunable::run()
|
||||
}
|
||||
}
|
||||
|
||||
if(rawImage)
|
||||
if(m_analyzeLevel >= Statistics)
|
||||
{
|
||||
uint64_t mean, median, min, max;
|
||||
double stdDev;
|
||||
@@ -241,7 +254,20 @@ void LoadRunable::run()
|
||||
info.append(StringPair(QObject::tr("Median"), QString::number(median)));
|
||||
info.append(StringPair(QObject::tr("Minimum"), QString::number(min)));
|
||||
info.append(StringPair(QObject::tr("Maximum"), QString::number(max)));
|
||||
|
||||
if(m_analyzeLevel >= Peaks)
|
||||
{
|
||||
std::vector<Peak> peaks;
|
||||
rawImage->quarter();
|
||||
rawImage->medianFilter();
|
||||
int numPeaks = rawImage->findPeaks(median+stdDev, 20, peaks);
|
||||
drawPeaks(img, peaks, true);
|
||||
info.append(StringPair(QObject::tr("Peaks"), QString::number(numPeaks)));
|
||||
info.append(StringPair(QObject::tr("Peaks draw"), QString::number(peaks.size())));
|
||||
}
|
||||
}
|
||||
|
||||
if(rawImage)delete rawImage;
|
||||
|
||||
QMetaObject::invokeMethod(m_receiver, "imageLoaded", Qt::QueuedConnection, Q_ARG(QImage, img), Q_ARG(ImageInfoData, info));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user