Browse Source

Dynamic Contrast gray level and color scale added

Arash Aletayeb 7 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"?>
<!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>
<data>
<variable>EnvironmentId</variable>

65
mainwindow.cpp

@ -213,12 +213,10 @@ MainWindow::MainWindow(QWidget* parent)
lcdStyle(ui->lcd_biteCounter);
lcdStyle(ui->lcd_adcCounter);
dynamicContrastMinLogInput = MIN_LOG_INPUT_DEFAULT;
dynamicContrastMaxLogInput = MAX_LOG_INPUT_DEFAULT;
dynamicContrastGain = GAIN_DEFAULT;
contrastNumber = CONTRAST_NUM_DEFAULT;
readDynamicContrastParameters(dynamicContrastParams);
ui->plot_2->axisRect()->setupFullAxesBox(true);
ui->plot_2->xAxis->setLabel("Line");
ui->plot_2->yAxis->setLabel("Point");
ui->plot_2->clearGraphs();
try
{
@ -236,6 +234,8 @@ MainWindow::MainWindow(QWidget* parent)
_trx.setTrxFanRpm(fan1, static_cast<quint8>(ui->sb_Fan1Pwm->value()));
_trx.setTrxFanRpm(fan2, static_cast<quint8>(ui->sb_Fan2Pwm->value()));
on_btn_dynConSetParams_clicked();
}
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);
@ -1504,7 +1504,7 @@ void MainWindow::dynamicContrastCsvRead(const QString &path)
data.clear();
line = csvReadFile.readLine();
auto sl = line.split(',');
foreach(auto &str, sl)
foreach(auto& str, sl)
{
data.push_back(str.toFloat());
}
@ -1552,6 +1552,11 @@ void MainWindow::on_btn_dynConSetParams_clicked()
if(ui->tb_contrastNum->text().length() > 0)
{
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
{
@ -1560,7 +1565,7 @@ void MainWindow::on_btn_dynConSetParams_clicked()
readDynamicContrastParameters(dynamicContrastParams);
}
catch(SonoException &e)
catch(SonoException& e)
{
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.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_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);
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);
}
@ -2146,9 +2159,6 @@ void MainWindow::show3d()
quint16 line(0), point(0);
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)
{
@ -2219,8 +2229,8 @@ void MainWindow::show3d()
qDebug() << "mPoint" << mPoint;
_colorMap->data()->clear();
_colorMap->data()->setSize(line, point);
_colorMap->data()->setRange(QCPRange(1, line), QCPRange(1, point));
_colorMap->data()->setSize(line, point + 1);
_colorMap->data()->setRange(QCPRange(1, line), QCPRange(1, point + 1));
quint32 max = 0;
auto indx = 0;
@ -2232,7 +2242,7 @@ void MainWindow::show3d()
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;
auto val = ((static_cast<quint32>(plotPacket[indx])) & 0x000000FF) |
@ -2250,7 +2260,14 @@ void MainWindow::show3d()
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;
@ -2263,13 +2280,19 @@ void MainWindow::show3d()
colorScale->setType(QCPAxis::atRight);
_colorMap->setColorScale(colorScale);
colorScale->axis()->setLabel("Number");
_colorMap->setGradient((QCPColorGradient::gpJet));
QCPMarginGroup* marginGroup = new QCPMarginGroup(ui->plot_2);
ui->plot_2->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup);
}
_colorMap->setGradient((QCPColorGradient::gpJet));
_colorMap->rescaleDataRange();
if(_isDynamicContrast)
{
_colorMap->setGradient((QCPColorGradient::gpGrayscale));
}
else
{
_colorMap->setGradient((QCPColorGradient::gpJet));
}
_colorMap->rescaleDataRange(false);
ui->plot_2->rescaleAxes(true);
ui->plot_2->replot();

1
mainwindow.h

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

14
mainwindow.ui

@ -1787,19 +1787,23 @@
</widget>
</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>
<widget class="QLabel" name="label_103">
<widget class="QLabel" name="label_105">
<property name="font">
<font>
<pointsize>7</pointsize>
<pointsize>10</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>dB (log2(2^(gain/20))*2^11)</string>
<string>dB</string>
</property>
</widget>
</item>
@ -1860,7 +1864,7 @@
<widget class="QLabel" name="label_104">
<property name="font">
<font>
<pointsize>9</pointsize>
<pointsize>10</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>

Loading…
Cancel
Save