From 8492e95b8980a4d6697de19c0ee2f9f49d46fe61 Mon Sep 17 00:00:00 2001 From: gehelem Date: Wed, 11 Dec 2024 12:39:41 +0100 Subject: [PATCH 1/2] Add basic selection property and make it work seems ok --- src/modules/inspector/inspector.cpp | 17 +++++++++++++++++ src/modules/inspector/inspector.json | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/modules/inspector/inspector.cpp b/src/modules/inspector/inspector.cpp index eac09bf..588dee4 100644 --- a/src/modules/inspector/inspector.cpp +++ b/src/modules/inspector/inspector.cpp @@ -106,6 +106,23 @@ void Inspector::OnMyExternalEvent(const QString &eventType, const QString &even getProperty("actions")->setState(OST::Ok); } } + + } + if (keyprop == "fileselect") + { + if (keyelt == "name") + { + if (eventType == "Fposticon") + { + getProperty("actions")->setState(OST::Ok); + delete _image; + _image = new fileio(); + _image->loadFits(getString("fileselect", "name")); + _image->generateQImage(); + stats = _image->getStats(); + emit newImage(); + } + } } } } diff --git a/src/modules/inspector/inspector.json b/src/modules/inspector/inspector.json index 186d7b6..13d960e 100644 --- a/src/modules/inspector/inspector.json +++ b/src/modules/inspector/inspector.json @@ -1,5 +1,25 @@ { "properties":{ + "fileselect": { + "devcat": "Parameters", + "order": "222Parms222", + "group": "", + "permission": 2, + "hasprofile":true, + "rule":0, + "label": "Select a file to reload", + "elements": { + "name": { + "autoupdate":true, + "directedit":true, + "posticon": "forward", + "type": "string", + "label": "", + "order": "1", + "value":"" + } + } + }, "parameters": { "devcat": "Parameters", "group": "", From 55e2d691089d9847a0bd9741c2da31db9c41a819 Mon Sep 17 00:00:00 2001 From: gehelem Date: Thu, 12 Dec 2024 19:08:07 +0100 Subject: [PATCH 2/2] Many improvements --- src/modules/inspector/inspector.cpp | 287 ++++++++++++++++++++------- src/modules/inspector/inspector.json | 58 +++++- 2 files changed, 273 insertions(+), 72 deletions(-) diff --git a/src/modules/inspector/inspector.cpp b/src/modules/inspector/inspector.cpp index 588dee4..f36b0c1 100644 --- a/src/modules/inspector/inspector.cpp +++ b/src/modules/inspector/inspector.cpp @@ -220,79 +220,174 @@ void Inspector::OnSucessSEP() QImage rawImage = _image->getRawQImage(); QImage im = rawImage.convertToFormat(QImage::Format_RGB32); im.setColorTable(rawImage.colorTable()); - QImage immap = rawImage.convertToFormat(QImage::Format_RGB32); - immap.setColorTable(rawImage.colorTable()); + QImage imHFR = rawImage.convertToFormat(QImage::Format_ARGB32); + //imHFR.setColorTable(rawImage.colorTable()); + QImage imShape = rawImage.convertToFormat(QImage::Format_RGB32); + imShape.setColorTable(rawImage.colorTable()); + int imgWidth = _image->getStats().width; + int imgHeight = _image->getStats().height; double ech = getSampling(); - //QRect r; - //r.setRect(0,0,im.width(),im.height()); + /****************************************************************** HFR */ + /****************************************************************** HFR */ + /****************************************************************** HFR */ + /****************************************************************** HFR */ - /* Drw HFR ellipses around found stars */ - foreach( FITSImage::Star s, _solver.stars ) + /* smoothing avg 8 surround cell */ + QList smoothedHFR = _solver.HFRavgZone; + for (int line = 1; line < _solver.HFRZones - 1 ; line++) { - QPainter p2; - p2.begin(&immap); - p2.setPen(QPen(Qt::green)); - - //qDebug() << "draw " << s.x << "/" << s.y; - int x = s.x; - int y = s.y; - int a = s.a; - int b = s.b; - float dx = 2 * s.a * cos(s.theta * 3.14159 / 360) / s.b; - float dy = 2 * s.a * sin(s.theta * 3.14159 / 360) / s.b; - - //qDebug() << "draw " << x << "/" << y; - //p2.rotate(s.theta); - //p2.drawEllipse(QPoint(x / 2, y / 2), a * 5, b * 5); - p2.drawLine(x / 2 - dx, y / 2 - dy, x / 2 + dx, y / 2 + dy); - p2.end(); + for (int column = 1; column < _solver.HFRZones - 1; column++) + { + int i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] / 9; + } } - - int imgWidth = _image->getStats().width; - int imgHeight = _image->getStats().height; - int ellipseSize = 0.20 * imgHeight / _solver.HFRZones; - + /* first row */ + for (int column = 1; column < _solver.HFRZones - 1; column++) + { + int line = 0; + int i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] / 6; + } + /* last row */ + for (int column = 1; column < _solver.HFRZones - 1; column++) + { + int line = _solver.HFRZones - 1; + int i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] / 6; + } + /* first column */ + for (int line = 1; line < _solver.HFRZones - 1 ; line++) + { + int column = 0; + int i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] / 6; + } + /* last column */ + for (int line = 1; line < _solver.HFRZones - 1 ; line++) + { + int column = _solver.HFRZones - 1; + int i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 0]; + smoothedHFR[i] = smoothedHFR[i] / 6; + } + /*corners*/ + { + /* upper left */ + int line = 0; + int column = 0; + int i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column + 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] / 4; + /* upper right */ + line = 0; + column = _solver.HFRZones - 1; + i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 0) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column + 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] / 4; + /* lower left */ + line = _solver.HFRZones - 1; + column = 0; + i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column + 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 0) + column + 1]; + smoothedHFR[i] = smoothedHFR[i] / 4; + /* lower right */ + line = _solver.HFRZones - 1; + column = _solver.HFRZones - 1; + i = _solver.HFRZones * line + column; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column + 0]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line - 1) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] + _solver.HFRavgZone[_solver.HFRZones * (line + 0) + column - 1]; + smoothedHFR[i] = smoothedHFR[i] / 4; + } + /* calculate min & max HFR */ + float minHFR = 99; + float maxHFR = 0; + for (int i = 0; i < _solver.HFRZones * _solver.HFRZones ; i++) + { + if (smoothedHFR[i] < minHFR) minHFR = smoothedHFR[i]; + if ((smoothedHFR[i] > maxHFR) && (smoothedHFR[i] < 99)) maxHFR = smoothedHFR[i]; + } + /*zoning*/ + QPainter p2; + p2.begin(&imHFR); + p2.setOpacity(0.5); for (int line = 0; line < _solver.HFRZones ; line++) { for (int column = 0; column < _solver.HFRZones; column++) { int zone = _solver.HFRZones * line + column; - //qDebug() << "zones theta" << zone << _solver.thetaAvgZone[zone] << _solver.thetaDevAvgZone[zone] << - // _solver.aAxeAvgZone[zone] << - // _solver.bAxeAvgZone[zone] << _solver.eAxeAvgZone[zone]; + int x = (imgWidth / _solver.HFRZones) * (column) ; + int y = (imgHeight / _solver.HFRZones) * (line) ; + int dx = imgWidth / _solver.HFRZones; + int dy = imgHeight / _solver.HFRZones; + qreal alpha = 1 * (smoothedHFR[zone] - minHFR) / (maxHFR - minHFR); + unsigned int r = 255 * (smoothedHFR[zone] - minHFR) / (maxHFR - minHFR); + unsigned int g = 255 * (maxHFR - smoothedHFR[zone]) / (maxHFR - minHFR); + p2.fillRect(QRect(x / 2, y / 2, dx / 2, dy / 2), qRgb(r, 0, 0)); - int x = (imgWidth / _solver.HFRZones) * (column + 0.5) ; - int y = (imgHeight / _solver.HFRZones) * (line + 0.5) ; - float e = _solver.aAxeAvgZone[zone] / _solver.bAxeAvgZone[zone] - 1; - float dx = (imgWidth / _solver.HFRZones) * e * e * cos(_solver.thetaAvgZone[zone] * 3.14159 / 360); - float dy = (imgWidth / _solver.HFRZones) * e * e * sin(_solver.thetaAvgZone[zone] * 3.14159 / 360); - QPainter p2; - p2.begin(&immap); - p2.setPen(QPen(Qt::red, 20)); - - //qDebug() << "draw " << x << "/" << y; - //p2.rotate(_solver.thetaAvgZone[zone]); - //p2.drawEllipse(QPoint(x / 2, y / 2), a * 15, b * 15); - //p2.drawEllipse(QPoint(x / 2, y / 2), ellipseSize, ellipseSize); - p2.drawLine(x / 2 - dx, y / 2 - dy, x / 2 + dx, y / 2 + dy); - p2.end(); } } - QPainter p; - p.begin(&immap); - p.setPen(QPen(Qt::red)); + p2.end(); + + /*surround stars*/ + p2.begin(&imHFR); + p2.setPen(QPen(Qt::blue, 10)); + foreach( FITSImage::Star s, _solver.stars ) + { + QPainter p2; + int x = s.x; + int y = s.y; + int hfr = s.HFR; + p2.drawEllipse(QPoint(x / 2, y / 2), hfr, hfr); + } + p2.end(); + - //p.drawLine(0, imgHeight / 6, imgWidth / 2, imgHeight / 6); - //p.drawLine(0, 2 * imgHeight / 6, imgWidth / 2, 2 * imgHeight / 6); - //p.drawLine(imgWidth / 6, 0, imgWidth / 6, imgHeight / 2); - //p.drawLine(2 * imgWidth / 6, 0, 2 * imgWidth / 6, imgHeight / 2); - /* determine 4 corner HFR */ + + /* HFR rectangle*/ + QPainter p; + p.begin(&imHFR); + p.setPen(QPen(Qt::red)); int upperLeftI = 0; int lowerLeftI = 0; int upperRightI = 0; @@ -328,17 +423,17 @@ void Inspector::OnSucessSEP() p.setPen(QPen(Qt::white)); int mul = 200; QVector hexPoints; - hexPoints << QPointF(1 * im.width() / 4 - mul*(upperLeftHFR - _solver.HFRavg*ech), - 1 * im.height() / 4 - mul*(upperLeftHFR - _solver.HFRavg*ech)); - hexPoints << QPointF(3 * im.width() / 4 + mul*(upperRightHFR - _solver.HFRavg*ech), - 1 * im.height() / 4 - mul*(upperRightHFR - _solver.HFRavg*ech)); - hexPoints << QPointF(3 * im.width() / 4 - mul*(lowerRightHFR - _solver.HFRavg*ech), - 3 * im.height() / 4 + mul*(lowerRightHFR - _solver.HFRavg*ech)); - hexPoints << QPointF(1 * im.width() / 4 + mul*(lowerLeftHFR - _solver.HFRavg*ech), - 3 * im.height() / 4 + mul*(lowerLeftHFR - _solver.HFRavg*ech)); + hexPoints << QPointF(1 * im.width() / 4 - mul * (upperLeftHFR - _solver.HFRavg * ech), + 1 * im.height() / 4 - mul * (upperLeftHFR - _solver.HFRavg * ech)); + hexPoints << QPointF(3 * im.width() / 4 + mul * (upperRightHFR - _solver.HFRavg * ech), + 1 * im.height() / 4 - mul * (upperRightHFR - _solver.HFRavg * ech)); + hexPoints << QPointF(3 * im.width() / 4 - mul * (lowerRightHFR - _solver.HFRavg * ech), + 3 * im.height() / 4 + mul * (lowerRightHFR - _solver.HFRavg * ech)); + hexPoints << QPointF(1 * im.width() / 4 + mul * (lowerLeftHFR - _solver.HFRavg * ech), + 3 * im.height() / 4 + mul * (lowerLeftHFR - _solver.HFRavg * ech)); p.drawPolygon(hexPoints); p.setFont(QFont("Courrier", im.width() / 50, QFont::Normal)); - p.drawText( QRect(0, 0, im.width(), im.height()), Qt::AlignCenter, QString::number(_solver.HFRavg*ech, 'f', 3) + "''"); + p.drawText( QRect(0, 0, im.width(), im.height()), Qt::AlignCenter, QString::number(_solver.HFRavg * ech, 'f', 3) + "''"); p.drawText(1 * im.width() / 4, 1 * im.height() / 4, QString::number(upperLeftHFR, 'f', 3) + "''"); p.drawText(3 * im.width() / 4, 1 * im.height() / 4, QString::number(upperRightHFR, 'f', 3) + "''"); p.drawText(1 * im.width() / 4, 3 * im.height() / 4, QString::number(lowerLeftHFR, 'f', 3) + "''"); @@ -346,8 +441,12 @@ void Inspector::OnSucessSEP() p.end(); + imHFR.save(getWebroot() + "/" + getModuleName() + "HFR.jpeg", "JPG", 100); - immap.save(getWebroot() + "/" + getModuleName() + "map.jpeg", "JPG", 100); + /****************************************************************** corners */ + /****************************************************************** corners */ + /****************************************************************** corners */ + /****************************************************************** corners */ int s = getInt("parms", "cornersize"); int h = rawImage.height(); @@ -376,19 +475,73 @@ void Inspector::OnSucessSEP() painter.drawRect(QRect(0, 0, 3 * s - 1, 3 * s - 1)); painter.end(); - corners.save(getWebroot() + "/" + getModuleName() + "corners.jpeg", "JPG", 100); - im.save(getWebroot() + "/" + getModuleName() + ".jpeg", "JPG", 100); + + /****************************************************************** aberations */ + /****************************************************************** aberations */ + /****************************************************************** aberations */ + /****************************************************************** aberations */ + + int ellipseSize = 0.20 * imgHeight / _solver.HFRZones; + + /* min and max aberations */ + float eMin = 99; + float eMax = 0; + for (int line = 0; line < _solver.HFRZones ; line++) + { + for (int column = 0; column < _solver.HFRZones; column++) + { + int zone = _solver.HFRZones * line + column; + float e = _solver.aAxeAvgZone[zone] / _solver.bAxeAvgZone[zone] - 1; + if (e < eMin) eMin = e; + if (e > eMax) eMax = e; + } + } + + /* draw aberations */ + p2.begin(&imShape); + p2.setOpacity(0.5); + p2.setPen(QPen(Qt::red, 10)); + for (int line = 0; line < _solver.HFRZones ; line++) + { + for (int column = 0; column < _solver.HFRZones; column++) + { + int zone = _solver.HFRZones * line + column; + + int x = (imgWidth / _solver.HFRZones) * (column + 0.5) ; + int y = (imgHeight / _solver.HFRZones) * (line + 0.5) ; + float e = _solver.aAxeAvgZone[zone] / _solver.bAxeAvgZone[zone] - 1; + float dx = (0.5 * imgWidth / _solver.HFRZones) * ((e - eMin) / (eMax - eMin)) * cos(_solver.thetaAvgZone[zone] * 3.14159 / + 360); + float dy = (0.5 * imgWidth / _solver.HFRZones) * ((e - eMin) / (eMax - eMin)) * sin(_solver.thetaAvgZone[zone] * 3.14159 / + 360); + + p2.drawLine(x / 2 - dx, y / 2 - dy, x / 2 + dx, y / 2 + dy); + } + } + p2.end(); + imShape.save(getWebroot() + "/" + getModuleName() + "shape.jpeg", "JPG", 100); + + OST::ImgData dta = _image->ImgStats(); dta.mUrlJpeg = getModuleName() + ".jpeg"; dta.HFRavg = ech * _solver.HFRavg; dta.starsCount = _solver.stars.size(); dta.mAlternates.clear(); dta.mAlternates.push_front(getModuleName() + "corners.jpeg"); - dta.mAlternates.push_front(getModuleName() + "map.jpeg"); + dta.mAlternates.push_front(getModuleName() + "HFR.jpeg"); + dta.mAlternates.push_front(getModuleName() + "shape.jpeg"); getEltImg("image", "image")->setValue(dta, true); + dta = _image->ImgStats(); + dta.mUrlJpeg = getModuleName() + "corners.jpeg"; + getEltImg("corners", "image")->setValue(dta, true); + dta.mUrlJpeg = getModuleName() + "HFR.jpeg"; + getEltImg("hfr", "image")->setValue(dta, true); + dta.mUrlJpeg = getModuleName() + "shape.jpeg"; + getEltImg("shape", "image")->setValue(dta, true); + emit FindStarsDone(); diff --git a/src/modules/inspector/inspector.json b/src/modules/inspector/inspector.json index 13d960e..bba61a2 100644 --- a/src/modules/inspector/inspector.json +++ b/src/modules/inspector/inspector.json @@ -1,8 +1,8 @@ { "properties":{ "fileselect": { - "devcat": "Parameters", - "order": "222Parms222", + "devcat": "Control", + "order": "000Control115", "group": "", "permission": 2, "hasprofile":true, @@ -21,11 +21,11 @@ } }, "parameters": { - "devcat": "Parameters", + "devcat": "Control", "group": "", "permission": 2, "hasprofile":true, - "order":"222Parms000", + "order":"000Control114", "label": "Zoning parameters", "elements": { "zoning": { @@ -49,12 +49,60 @@ [8,"08x08"], [9,"09x09"], [12,"12x12"], - [16,"16x16"] + [16,"16x16"], + [32,"32x32"], + [64,"64x64"] ] } } + }, + "hfr": { + "devcat": "Control", + "group": "", + "order":"AAAResults999", + "permission": 0, + "label": "HFR map", + "elements": { + "image": { + "type": "img", + "label": "HFR map", + "order":"1", + "showstats":false + } + } + }, + "shape": { + "devcat": "Control", + "group": "", + "order":"AAAResults999", + "permission": 0, + "label": "Shape map", + "elements": { + "image": { + "type": "img", + "label": "Shape map", + "order":"1", + "showstats":false + } + } + }, + "corners": { + "devcat": "Control", + "group": "", + "order":"AAAResults999", + "permission": 0, + "label": "Corners map", + "elements": { + "image": { + "type": "img", + "label": "Corners map", + "order":"1", + "showstats":false + } + } } + } }