Skip to content

Commit

Permalink
Exchange checkbox to slider (luma weight)
Browse files Browse the repository at this point in the history
  • Loading branch information
masc4ii committed Nov 26, 2020
1 parent ae954d1 commit 365c488
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 57 deletions.
43 changes: 29 additions & 14 deletions platform/qt/MainWindow.cpp
Expand Up @@ -3696,7 +3696,7 @@ void MainWindow::readXmlElementsFromFile(QXmlStreamReader *Rxml, ReceiptSettings
}
else if( Rxml->isStartElement() && Rxml->name() == "grainLumaWeight" )
{
receipt->setGrainLumaWeight( (bool)Rxml->readElementText().toInt() );
receipt->setGrainLumaWeight( Rxml->readElementText().toInt() );
Rxml->readNext();
}
else if( Rxml->isStartElement() && Rxml->name() == "rawFixesEnabled" )
Expand Down Expand Up @@ -4000,7 +4000,7 @@ void MainWindow::writeXmlElementsToFile(QXmlStreamWriter *xmlWriter, ReceiptSett
xmlWriter->writeTextElement( "rbfDenoiserChroma", QString( "%1" ).arg( receipt->rbfDenoiserChroma() ) );
xmlWriter->writeTextElement( "rbfDenoiserRange", QString( "%1" ).arg( receipt->rbfDenoiserRange() ) );
xmlWriter->writeTextElement( "grainStrength", QString( "%1" ).arg( receipt->grainStrength() ) );
xmlWriter->writeTextElement( "grainLumaWeight", QString( "%1" ).arg( receipt->grainLumaWeightEnabled() ) );
xmlWriter->writeTextElement( "grainLumaWeight", QString( "%1" ).arg( receipt->grainLumaWeight() ) );
xmlWriter->writeTextElement( "rawFixesEnabled", QString( "%1" ).arg( receipt->rawFixesEnabled() ) );
xmlWriter->writeTextElement( "verticalStripes", QString( "%1" ).arg( receipt->verticalStripes() ) );
xmlWriter->writeTextElement( "focusPixels", QString( "%1" ).arg( receipt->focusPixels() ) );
Expand Down Expand Up @@ -4257,7 +4257,7 @@ void MainWindow::setSliders(ReceiptSettings *receipt, bool paste)
ui->horizontalSliderRbfDenoiseRange->setValue( receipt->rbfDenoiserRange() );

ui->horizontalSliderGrainStrength->setValue( receipt->grainStrength() );
ui->checkBoxGrainLumaWeight->setChecked( receipt->grainLumaWeightEnabled() );
ui->horizontalSliderGrainLumaWeight->setValue( receipt->grainLumaWeight() );

ui->checkBoxRawFixEnable->setChecked( receipt->rawFixesEnabled() );
on_checkBoxRawFixEnable_clicked( receipt->rawFixesEnabled() );
Expand Down Expand Up @@ -4475,7 +4475,7 @@ void MainWindow::setReceipt( ReceiptSettings *receipt )
receipt->setRbfDenoiserChroma( ui->horizontalSliderRbfDenoiseChroma->value() );
receipt->setRbfDenoiserRange( ui->horizontalSliderRbfDenoiseRange->value() );
receipt->setGrainStrength( ui->horizontalSliderGrainStrength->value() );
receipt->setGrainLumaWeight( ui->checkBoxGrainLumaWeight->isChecked() );
receipt->setGrainLumaWeight( ui->horizontalSliderGrainLumaWeight->value() );

receipt->setRawFixesEnabled( ui->checkBoxRawFixEnable->isChecked() );
receipt->setVerticalStripes( toolButtonVerticalStripesCurrentIndex() );
Expand Down Expand Up @@ -4600,7 +4600,7 @@ void MainWindow::replaceReceipt(ReceiptSettings *receiptTarget, ReceiptSettings
if( paste && cdui->checkBoxDenoise->isChecked() ) receiptTarget->setRbfDenoiserChroma( receiptSource->rbfDenoiserChroma() );
if( paste && cdui->checkBoxDenoise->isChecked() ) receiptTarget->setRbfDenoiserRange( receiptSource->rbfDenoiserRange() );
if( paste && cdui->checkBoxGrain->isChecked() ) receiptTarget->setGrainStrength( receiptSource->grainStrength() );
if( paste && cdui->checkBoxGrain->isChecked() ) receiptTarget->setGrainLumaWeight( receiptSource->grainLumaWeightEnabled() );
if( paste && cdui->checkBoxGrain->isChecked() ) receiptTarget->setGrainLumaWeight( receiptSource->grainLumaWeight() );

if( paste && cdui->checkBoxRawCorrectEnable->isChecked() ) receiptTarget->setRawFixesEnabled( receiptSource->rawFixesEnabled() );
if( paste && cdui->checkBoxDarkFrameSubtraction->isChecked() ) receiptTarget->setDarkFrameFileName( receiptSource->darkFrameFileName() );
Expand Down Expand Up @@ -4792,7 +4792,7 @@ void MainWindow::addClipToExportQueue(int row, QString fileName)
receipt->setRbfDenoiserChroma( GET_RECEIPT( row )->rbfDenoiserChroma() );
receipt->setRbfDenoiserRange( GET_RECEIPT( row )->rbfDenoiserRange() );
receipt->setGrainStrength( GET_RECEIPT( row )->grainStrength() );
receipt->setGrainLumaWeight( GET_RECEIPT( row )->grainLumaWeightEnabled() );
receipt->setGrainLumaWeight( GET_RECEIPT( row )->grainLumaWeight() );

receipt->setRawFixesEnabled( GET_RECEIPT( row )->rawFixesEnabled() );
receipt->setVerticalStripes( GET_RECEIPT( row )->verticalStripes() );
Expand Down Expand Up @@ -5722,6 +5722,13 @@ void MainWindow::on_horizontalSliderGrainStrength_valueChanged(int position)
m_frameChanged = true;
}

void MainWindow::on_horizontalSliderGrainLumaWeight_valueChanged(int position)
{
processingSetGrainLumaWeight( m_pProcessingObject, position );
ui->label_GrainLumaWeight->setText( QString("%1").arg( position ) );
m_frameChanged = true;
}

void MainWindow::on_horizontalSliderLutStrength_valueChanged(int position)
{
processingSetLutStrength( m_pProcessingObject, position );
Expand Down Expand Up @@ -6086,6 +6093,13 @@ void MainWindow::on_horizontalSliderGrainStrength_doubleClicked()
delete sliders;
}

void MainWindow::on_horizontalSliderGrainLumaWeight_doubleClicked()
{
ReceiptSettings *sliders = new ReceiptSettings(); //default
ui->horizontalSliderGrainLumaWeight->setValue( sliders->grainLumaWeight() );
delete sliders;
}

void MainWindow::on_horizontalSliderLutStrength_doubleClicked()
{
ReceiptSettings *sliders = new ReceiptSettings(); //default
Expand Down Expand Up @@ -6522,14 +6536,6 @@ void MainWindow::on_checkBoxChromaSeparation_toggled(bool checked)
m_frameChanged = true;
}

//Enable / Disable grain luma weight
void MainWindow::on_checkBoxGrainLumaWeight_toggled(bool checked)
{
if( checked ) processingSetGrainLumaWeightEnable( m_pProcessingObject );
else processingSetGrainLumaWeightDisable( m_pProcessingObject );
m_frameChanged = true;
}

//Chose profile
void MainWindow::on_comboBoxProfile_currentIndexChanged(int index)
{
Expand Down Expand Up @@ -7548,6 +7554,15 @@ void MainWindow::on_label_GrainStrength_doubleClicked()
ui->horizontalSliderGrainStrength->setValue( editSlider.getValue() );
}

//DoubleClick on GrainLumaWeight Label
void MainWindow::on_label_GrainLumaWeight_doubleClicked()
{
EditSliderValueDialog editSlider;
editSlider.autoSetup( ui->horizontalSliderGrainLumaWeight, ui->label_GrainLumaWeight, 1.0, 0, 1.0 );
editSlider.exec();
ui->horizontalSliderGrainLumaWeight->setValue( editSlider.getValue() );
}

//Repaint audio if its size changed
void MainWindow::on_labelAudioTrack_sizeChanged()
{
Expand Down
4 changes: 3 additions & 1 deletion platform/qt/MainWindow.h
Expand Up @@ -101,6 +101,7 @@ private slots:
void on_horizontalSliderRbfDenoiseChroma_valueChanged(int position);
void on_horizontalSliderRbfDenoiseRange_valueChanged(int position);
void on_horizontalSliderGrainStrength_valueChanged(int position);
void on_horizontalSliderGrainLumaWeight_valueChanged(int position);
void on_horizontalSliderLutStrength_valueChanged(int position);
void on_horizontalSliderFilterStrength_valueChanged(int position);
void on_horizontalSliderVignetteStrength_valueChanged(int position);
Expand Down Expand Up @@ -144,6 +145,7 @@ private slots:
void on_horizontalSliderRbfDenoiseChroma_doubleClicked();
void on_horizontalSliderRbfDenoiseRange_doubleClicked();
void on_horizontalSliderGrainStrength_doubleClicked();
void on_horizontalSliderGrainLumaWeight_doubleClicked();
void on_horizontalSliderLutStrength_doubleClicked();
void on_horizontalSliderFilterStrength_doubleClicked();
void on_horizontalSliderVignetteStrength_doubleClicked();
Expand Down Expand Up @@ -171,7 +173,6 @@ private slots:
void on_checkBoxCreativeAdjustments_toggled(bool checked);
void on_checkBoxExrMode_toggled(bool checked);
void on_checkBoxChromaSeparation_toggled(bool checked);
void on_checkBoxGrainLumaWeight_toggled(bool checked);
void on_comboBoxProfile_currentIndexChanged(int index);
void on_comboBoxProfile_activated(int index);
void on_comboBoxTonemapFct_currentIndexChanged(int index);
Expand Down Expand Up @@ -252,6 +253,7 @@ private slots:
void on_label_RbfDenoiseChroma_doubleClicked( void );
void on_label_RbfDenoiseRange_doubleClicked( void );
void on_label_GrainStrength_doubleClicked( void );
void on_label_GrainLumaWeight_doubleClicked( void );
void on_labelAudioTrack_sizeChanged( void );
void on_label_LutStrengthVal_doubleClicked( void );
void on_label_FilterStrengthVal_doubleClicked( void );
Expand Down
131 changes: 97 additions & 34 deletions platform/qt/MainWindow.ui
Expand Up @@ -68,7 +68,17 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="1" column="0">
<widget class="JumpSlider" name="horizontalSliderPosition">
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="ResizeLabel" name="labelAudioTrack">
<property name="enabled">
<bool>false</bool>
Expand Down Expand Up @@ -105,16 +115,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="JumpSlider" name="horizontalSliderPosition">
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
Expand Down Expand Up @@ -468,9 +468,9 @@ QGroupBox::indicator:checked:disabled {
<property name="geometry">
<rect>
<x>0</x>
<y>-2298</y>
<width>265</width>
<height>5491</height>
<y>-2547</y>
<width>266</width>
<height>5571</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayoutScrollArea">
Expand Down Expand Up @@ -5534,6 +5534,18 @@ QGroupBox::indicator:checked:disabled {
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_37">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Grain Strength</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="DoubleClickLabel" name="label_GrainStrength">
<property name="font">
Expand All @@ -5549,18 +5561,31 @@ QGroupBox::indicator:checked:disabled {
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_37">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
<item row="1" column="0" colspan="3">
<widget class="NoScrollSlider" name="horizontalSliderGrainStrength">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Recursive bilateral filtering</string>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Grain Strength</string>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="sliderPosition">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
Expand All @@ -5580,8 +5605,42 @@ QGroupBox::indicator:checked:disabled {
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_69">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_40">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Grain Luma Weight</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="DoubleClickLabel" name="label_GrainLumaWeight">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="NoScrollSlider" name="horizontalSliderGrainStrength">
<widget class="NoScrollSlider" name="horizontalSliderGrainLumaWeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -5608,17 +5667,21 @@ QGroupBox::indicator:checked:disabled {
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxGrainLumaWeight">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
<item row="0" column="1">
<spacer name="horizontalSpacer_63">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="text">
<string>Luma Weight</string>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
Expand Down
2 changes: 1 addition & 1 deletion platform/qt/ReceiptSettings.cpp
Expand Up @@ -49,7 +49,7 @@ ReceiptSettings::ReceiptSettings()
m_rbfDenoiserChroma = 0;
m_rbfDenoiserRange = 40;
m_grainStrength = 0;
m_grainLumaWeightEnable = false;
m_grainLumaWeight = 0;
m_highlightReconstruction = false;
m_useCamMatrix = 1;
m_chromaSeparation = false;
Expand Down
6 changes: 3 additions & 3 deletions platform/qt/ReceiptSettings.h
Expand Up @@ -55,7 +55,7 @@ class ReceiptSettings
void setRbfDenoiserChroma( int value ) {m_rbfDenoiserChroma = value;}
void setRbfDenoiserRange( int value ) {m_rbfDenoiserRange = value;}
void setGrainStrength( int value ) {m_grainStrength = value;}
void setGrainLumaWeight( bool on ) {m_grainLumaWeightEnable = on;}
void setGrainLumaWeight( int on ) {m_grainLumaWeight = on;}
void setHighlightReconstruction( bool on ){m_highlightReconstruction = on;}
void setCamMatrixUsed( uint8_t val ) {m_useCamMatrix = val;}
void setChromaSeparation( bool on ) {m_chromaSeparation = on;}
Expand Down Expand Up @@ -159,7 +159,7 @@ class ReceiptSettings
int rbfDenoiserChroma( void ){return m_rbfDenoiserChroma;}
int rbfDenoiserRange( void ){return m_rbfDenoiserRange;}
int grainStrength( void ){return m_grainStrength;}
bool grainLumaWeightEnabled( void ){return m_grainLumaWeightEnable;}
int grainLumaWeight( void ){return m_grainLumaWeight;}
bool isHighlightReconstruction( void ){return m_highlightReconstruction;}
uint8_t camMatrixUsed( void ){return m_useCamMatrix;}
bool isChromaSeparation( void ){return m_chromaSeparation;}
Expand Down Expand Up @@ -272,7 +272,7 @@ class ReceiptSettings
int m_rbfDenoiserChroma;
int m_rbfDenoiserRange;
int m_grainStrength;
bool m_grainLumaWeightEnable;
int m_grainLumaWeight;
bool m_highlightReconstruction;
uint8_t m_useCamMatrix;
bool m_chromaSeparation;
Expand Down
5 changes: 3 additions & 2 deletions src/processing/raw_processing.c
Expand Up @@ -175,7 +175,7 @@ processingObject_t * initProcessingObject()
processingSetVignetteStrength(processing, 0);

processingSetGrainStrength(processing, 0);
processingSetGrainLumaWeightDisable(processing);
processingSetGrainLumaWeight(processing, 0);

/* Colour default parameters */
processingSetGamut(processing, GAMUT_Rec709);
Expand Down Expand Up @@ -545,10 +545,11 @@ void applyProcessingObject( processingObject_t * processing,
uint32_t randomval = randomseed1 ^ ((i*randomseed2) * (randomseed3-i) * (i+randomseed4));
int grain = ( randomval % strength ) - ( strength >> 2 ); //change value for strength

if( processing->grainLumaWeight )
if( processing->grainLumaWeight > 0 )
{
uint32_t sumL = outputImage[i+0] + outputImage[i+1] + outputImage[i+2];
double weight = sumL / 1.5 / 65535.0;
weight = ( weight * processing->grainLumaWeight / 100.0 ) + ( ( 100 - processing->grainLumaWeight ) / 100.0 );
grain *= weight;
}

Expand Down
3 changes: 1 addition & 2 deletions src/processing/raw_processing.h
Expand Up @@ -170,8 +170,7 @@ void processingSet3WayCorrection( processingObject_t * processing,

/* Grain */
#define processingSetGrainStrength(processing, strength) (processing)->grainStrength = (strength)
#define processingSetGrainLumaWeightEnable(processing) (processing)->grainLumaWeight = 1
#define processingSetGrainLumaWeightDisable(processing) (processing)->grainLumaWeight = 0
#define processingSetGrainLumaWeight(processing, strength) (processing)->grainLumaWeight = (strength)

/* Vignette */
void processingSetVignetteStrength(processingObject_t * processing, int8_t value);
Expand Down

0 comments on commit 365c488

Please sign in to comment.