7#include "focusblurriness.h"
12FocusBlurriness::FocusBlurriness()
14 m_maxX = m_maxY = -1.0;
17FocusBlurriness::~FocusBlurriness()
21ImageMosaicMask * FocusBlurriness::getMosaicMask(
const QSharedPointer<ImageMask> &mask,
const int tile)
23 ImageMosaicMask *mosaicMask =
nullptr;
26 if (tile < 0 || tile >= NUM_TILES)
27 qCDebug(KSTARS_EKOS_FOCUS) << QString(
"%1 called with invalid mosaic tile %2").arg(__FUNCTION__)
31 mosaicMask =
dynamic_cast<ImageMosaicMask *
>(mask.
get());
33 qCDebug(KSTARS_EKOS_FOCUS) << QString(
"%1 called with invalid 2 mosaic tile %2").arg(__FUNCTION__)
38 qCDebug(KSTARS_EKOS_FOCUS) << QString(
"%1 called for mosaic tile but no mask").arg(__FUNCTION__);
43int FocusBlurriness::getCVType(
const int type)
49 cvType = CV_MAKETYPE(CV_8U, 1);
53 cvType = CV_MAKETYPE(CV_16S, 1);
57 cvType = CV_MAKETYPE(CV_16U, 1);
61 cvType = CV_MAKETYPE(CV_32S, 1);
65 qCDebug(KSTARS_EKOS_FOCUS) <<
"OpenCV does not support " <<
type <<
" Cannot calc blurriness";
69 cvType = CV_MAKETYPE(CV_32F, 1);
73 qCDebug(KSTARS_EKOS_FOCUS) <<
"OpenCV does not support " <<
type <<
" Cannot calc blurriness";
77 cvType = CV_MAKETYPE(CV_64F, 1);
81 qCDebug(KSTARS_EKOS_FOCUS) <<
"Unknown image buffer datatype " <<
type <<
" Cannot calc blurriness";
87cv::Rect FocusBlurriness::calcROIfromTile(
const int tile, ImageMosaicMask *mosaicMask)
89 unsigned int topLeftX = 0, topLeftY = 0, width = 0, height = 0;
91 if (tile >= 0 && tile < NUM_TILES)
94 topLeftX = mosaicMask->tiles()[tile].topLeft().x();
95 topLeftY = mosaicMask->tiles()[tile].topLeft().y();
96 width = mosaicMask->tiles()[tile].width();
99 cv::Rect cvROI(topLeftX, topLeftY, width, height);
103void FocusBlurriness::applyRingMaskToImage(cv::Mat &img,
const int width,
const int height, ImageRingMask *ringMask)
108 cv::Mat cvMask = cv::Mat::zeros(img.size(), CV_8UC1);
109 const float diagonalRadius = std::sqrt((width * width + height * height) / 4.0);
110 const float innerRadius = ringMask->innerRadius() * diagonalRadius;
111 const float outerRadius = ringMask->outerRadius() * diagonalRadius;
112 const cv::Point
center(width / 2, height / 2);
113 cv::circle(cvMask, center, outerRadius, 255, cv::FILLED, cv::FILLED);
114 cv::circle(cvMask, center, innerRadius, 0, cv::FILLED, cv::FILLED);
119 img.copyTo(res, cvMask);
123 cv::imshow(
"Mask", cvMask);
124 cv::imshow(
"Image with mask", img);
Type type(const QSqlDatabase &db)
Ekos is an advanced Astrophotography tool for Linux.
QTextStream & center(QTextStream &stream)