Browse Source

Dynamic Contrast gray level and color scale added

Arash Aletayeb 12 months ago
parent
commit
4c79538246
  1. 2
      developHw.pro.user
  2. 65
      mainwindow.cpp
  3. 1
      mainwindow.h
  4. 14
      mainwindow.ui

2
developHw.pro.user

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2024-04-16T11:50:14. --> <!-- Written by QtCreator 4.10.0, 2024-04-17T14:43:41. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

65
mainwindow.cpp

@ -213,12 +213,10 @@ MainWindow::MainWindow(QWidget* parent)
lcdStyle(ui->lcd_biteCounter); lcdStyle(ui->lcd_biteCounter);
lcdStyle(ui->lcd_adcCounter); lcdStyle(ui->lcd_adcCounter);
dynamicContrastMinLogInput = MIN_LOG_INPUT_DEFAULT; ui->plot_2->axisRect()->setupFullAxesBox(true);
dynamicContrastMaxLogInput = MAX_LOG_INPUT_DEFAULT; ui->plot_2->xAxis->setLabel("Line");
dynamicContrastGain = GAIN_DEFAULT; ui->plot_2->yAxis->setLabel("Point");
contrastNumber = CONTRAST_NUM_DEFAULT; ui->plot_2->clearGraphs();
readDynamicContrastParameters(dynamicContrastParams);
try try
{ {
@ -236,6 +234,8 @@ MainWindow::MainWindow(QWidget* parent)
_trx.setTrxFanRpm(fan1, static_cast<quint8>(ui->sb_Fan1Pwm->value())); _trx.setTrxFanRpm(fan1, static_cast<quint8>(ui->sb_Fan1Pwm->value()));
_trx.setTrxFanRpm(fan2, static_cast<quint8>(ui->sb_Fan2Pwm->value())); _trx.setTrxFanRpm(fan2, static_cast<quint8>(ui->sb_Fan2Pwm->value()));
on_btn_dynConSetParams_clicked();
} }
catch(const char* exception) catch(const char* exception)
{ {
@ -1485,7 +1485,7 @@ const QString MainWindow::enum2String(ePg state) const
} }
/*************************************************************************************************/ /*************************************************************************************************/
void MainWindow::dynamicContrastCsvRead(const QString &path) void MainWindow::dynamicContrastCsvRead(const QString& path)
{ {
QFile csvReadFile(path); QFile csvReadFile(path);
@ -1504,7 +1504,7 @@ void MainWindow::dynamicContrastCsvRead(const QString &path)
data.clear(); data.clear();
line = csvReadFile.readLine(); line = csvReadFile.readLine();
auto sl = line.split(','); auto sl = line.split(',');
foreach(auto &str, sl) foreach(auto& str, sl)
{ {
data.push_back(str.toFloat()); data.push_back(str.toFloat());
} }
@ -1552,6 +1552,11 @@ void MainWindow::on_btn_dynConSetParams_clicked()
if(ui->tb_contrastNum->text().length() > 0) if(ui->tb_contrastNum->text().length() > 0)
{ {
contrastNumber = static_cast<quint8>(ui->tb_contrastNum->text().toUShort()); contrastNumber = static_cast<quint8>(ui->tb_contrastNum->text().toUShort());
if(contrastNumber < 1 || contrastNumber > 12)
{
qDebug() << "Dynamic Contrast is out of range.";
contrastNumber = CONTRAST_NUM_DEFAULT;
}
} }
else else
{ {
@ -1560,7 +1565,7 @@ void MainWindow::on_btn_dynConSetParams_clicked()
readDynamicContrastParameters(dynamicContrastParams); readDynamicContrastParameters(dynamicContrastParams);
} }
catch(SonoException &e) catch(SonoException& e)
{ {
qDebug() << e.what(); qDebug() << e.what();
} }
@ -1573,7 +1578,7 @@ void MainWindow::on_chk_dynamicContrast_clicked(bool checked)
} }
/*************************************************************************************************/ /*************************************************************************************************/
void MainWindow::readDynamicContrastParameters(DynamicContrastParameters &params) void MainWindow::readDynamicContrastParameters(DynamicContrastParameters& params)
{ {
params.gain = log2(pow(10.0f, (dynamicContrastGain / 20.0f))) * pow(2.0f, 11.0f); params.gain = log2(pow(10.0f, (dynamicContrastGain / 20.0f))) * pow(2.0f, 11.0f);
params.max_output_level = MAX_OUTPUT_LEVEL; params.max_output_level = MAX_OUTPUT_LEVEL;
@ -1582,9 +1587,17 @@ void MainWindow::readDynamicContrastParameters(DynamicContrastParameters &params
params.app_max_log_input_level = dynamicContrastMaxLogInput * pow(2.0f, 11.0f); params.app_max_log_input_level = dynamicContrastMaxLogInput * pow(2.0f, 11.0f);
params.app_min_log_input_level = dynamicContrastMinLogInput * pow(2.0f, 11.0f); params.app_min_log_input_level = dynamicContrastMinLogInput * pow(2.0f, 11.0f);
qDebug() << "gain: " << params.gain;
qDebug() << "max_output_level: " << params.max_output_level;
qDebug() << "min_output_level: " << params.min_output_level;
qDebug() << "max_log_input_level: " << params.max_log_input_level;
qDebug() << "app_max_log_input_level:" << params.app_max_log_input_level;
qDebug() << "app_min_log_input_level:" << params.app_min_log_input_level;
dynamicContrastCsvRead(_dynContrCurvesPath);
params.const_piecewise_y = dynamicTotalData.at(contrastNumber - 1); params.const_piecewise_y = dynamicTotalData.at(contrastNumber - 1);
QList<float> piecewise_x; QList<float> piecewise_x;
for (auto i = 0; i < 256; i++) for(auto i = 0; i < dynamicTotalData.at(0).length(); i++)
{ {
piecewise_x.push_back(i); piecewise_x.push_back(i);
} }
@ -2146,9 +2159,6 @@ void MainWindow::show3d()
quint16 line(0), point(0); quint16 line(0), point(0);
ui->plot_2->clearGraphs(); ui->plot_2->clearGraphs();
ui->plot_2->axisRect()->setupFullAxesBox(true);
ui->plot_2->xAxis->setLabel("Line");
ui->plot_2->yAxis->setLabel("Point");
if(plotFrame.size() != 0) if(plotFrame.size() != 0)
{ {
@ -2219,8 +2229,8 @@ void MainWindow::show3d()
qDebug() << "mPoint" << mPoint; qDebug() << "mPoint" << mPoint;
_colorMap->data()->clear(); _colorMap->data()->clear();
_colorMap->data()->setSize(line, point); _colorMap->data()->setSize(line, point + 1);
_colorMap->data()->setRange(QCPRange(1, line), QCPRange(1, point)); _colorMap->data()->setRange(QCPRange(1, line), QCPRange(1, point + 1));
quint32 max = 0; quint32 max = 0;
auto indx = 0; auto indx = 0;
@ -2232,7 +2242,7 @@ void MainWindow::show3d()
for(auto ln = 0; ln < lnPacket; ln += 1) for(auto ln = 0; ln < lnPacket; ln += 1)
{ {
for(auto pnt = 0; pnt < point; pnt += 1) for(auto pnt = 0; pnt < (point + 1); pnt += 1)
{ {
indx = (ln * point + pnt) * 4 + 160; indx = (ln * point + pnt) * 4 + 160;
auto val = ((static_cast<quint32>(plotPacket[indx])) & 0x000000FF) | auto val = ((static_cast<quint32>(plotPacket[indx])) & 0x000000FF) |
@ -2250,7 +2260,14 @@ void MainWindow::show3d()
val = static_cast<quint32>(DynamicContrast(val, dynamicContrastParams)); val = static_cast<quint32>(DynamicContrast(val, dynamicContrastParams));
} }
_colorMap->data()->setCell(lnSum + ln, pnt, double(val)); if(pnt == point)
{
_colorMap->data()->setCell(lnSum + ln, pnt, double(255));
}
else
{
_colorMap->data()->setCell(lnSum + ln, pnt, double(val));
}
} }
} }
lnSum = lnSum + lnPacket; lnSum = lnSum + lnPacket;
@ -2263,13 +2280,19 @@ void MainWindow::show3d()
colorScale->setType(QCPAxis::atRight); colorScale->setType(QCPAxis::atRight);
_colorMap->setColorScale(colorScale); _colorMap->setColorScale(colorScale);
colorScale->axis()->setLabel("Number"); colorScale->axis()->setLabel("Number");
_colorMap->setGradient((QCPColorGradient::gpJet));
QCPMarginGroup* marginGroup = new QCPMarginGroup(ui->plot_2); QCPMarginGroup* marginGroup = new QCPMarginGroup(ui->plot_2);
ui->plot_2->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup); ui->plot_2->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup); colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
} }
_colorMap->setGradient((QCPColorGradient::gpJet)); if(_isDynamicContrast)
_colorMap->rescaleDataRange(); {
_colorMap->setGradient((QCPColorGradient::gpGrayscale));
}
else
{
_colorMap->setGradient((QCPColorGradient::gpJet));
}
_colorMap->rescaleDataRange(false);
ui->plot_2->rescaleAxes(true); ui->plot_2->rescaleAxes(true);
ui->plot_2->replot(); ui->plot_2->replot();

1
mainwindow.h

@ -262,6 +262,7 @@ private:
QString _headerLogPath = "/home/hasis/Desktop/hardware/Log/frameHeader/headerLog.csv"; QString _headerLogPath = "/home/hasis/Desktop/hardware/Log/frameHeader/headerLog.csv";
QString _headerEndurancePath = "/home/hasis/Desktop/hardware/Log/header_endurance/headerLog.csv"; QString _headerEndurancePath = "/home/hasis/Desktop/hardware/Log/header_endurance/headerLog.csv";
QString _probeRomPath = "/home/hasis/Desktop/hardware/ProbeRom"; QString _probeRomPath = "/home/hasis/Desktop/hardware/ProbeRom";
QString _dynContrCurvesPath = "/home/hasis/Desktop/hardware/Develop_HardwareTest/developHw/kernelParams/DynContrCurves.csv";
QVector<QByteArray> _dmaBuffer; QVector<QByteArray> _dmaBuffer;
QByteArray _lastBuffer; QByteArray _lastBuffer;

14
mainwindow.ui

@ -1787,19 +1787,23 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="tb_dynamicGain"/> <widget class="QLineEdit" name="tb_dynamicGain">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt; font-weight:600; font-style:italic;&quot;&gt;(log2(10^(gain/20))*2^11)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_103"> <widget class="QLabel" name="label_105">
<property name="font"> <property name="font">
<font> <font>
<pointsize>7</pointsize> <pointsize>10</pointsize>
<weight>50</weight> <weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>dB (log2(2^(gain/20))*2^11)</string> <string>dB</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -1860,7 +1864,7 @@
<widget class="QLabel" name="label_104"> <widget class="QLabel" name="label_104">
<property name="font"> <property name="font">
<font> <font>
<pointsize>9</pointsize> <pointsize>10</pointsize>
<weight>50</weight> <weight>50</weight>
<bold>false</bold> <bold>false</bold>
</font> </font>

Loading…
Cancel
Save