Integrated "Fattal02" tone-mapping operator from Luminance HDR

This commit is contained in:
Alberto Griggio
2017-11-02 22:34:49 +01:00
parent dd6e411c13
commit 77b4ad497b
17 changed files with 1267 additions and 1 deletions

View File

@@ -147,6 +147,7 @@ set(NONCLISOURCEFILES
xtransprocess.cc
xtransrawexposure.cc
zoompanel.cc
fattaltonemap.cc
)
include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}")

120
rtgui/fattaltonemap.cc Normal file
View File

@@ -0,0 +1,120 @@
/** -*- C++ -*-
*
* This file is part of RawTherapee.
*
* Copyright (c) 2017 Alberto Griggio <alberto.griggio@gmail.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fattaltonemap.h"
#include <iomanip>
#include <cmath>
using namespace rtengine;
using namespace rtengine::procparams;
FattalToneMapping::FattalToneMapping(): FoldableToolPanel(this, "fattal", M("TP_TM_FATTAL_LABEL"), true, true)
{
// setEnabledTooltipMarkup(M("TP_EPD_TOOLTIP"));
alpha = Gtk::manage(new Adjuster (M("TP_TM_FATTAL_ALPHA"), 0.0, 2.0, 0.01, 1.0));
beta = Gtk::manage(new Adjuster (M("TP_TM_FATTAL_BETA"), 0.0, 2.0, 0.01, 1.0));
alpha->setAdjusterListener(this);
beta->setAdjusterListener(this);
alpha->show();
beta->show();
pack_start(*alpha);
pack_start(*beta);
}
void FattalToneMapping::read(const ProcParams *pp, const ParamsEdited *pedited)
{
disableListener();
if(pedited) {
alpha->setEditedState(pedited->fattal.alpha ? Edited : UnEdited);
beta->setEditedState(pedited->fattal.beta ? Edited : UnEdited);
set_inconsistent(multiImage && !pedited->fattal.enabled);
}
setEnabled(pp->fattal.enabled);
alpha->setValue(pp->fattal.alpha);
beta->setValue(pp->fattal.beta);
enableListener();
}
void FattalToneMapping::write(ProcParams *pp, ParamsEdited *pedited)
{
pp->fattal.alpha = alpha->getValue();
pp->fattal.beta = beta->getValue();
pp->fattal.enabled = getEnabled();
if(pedited) {
pedited->fattal.alpha = alpha->getEditedState();
pedited->fattal.beta = beta->getEditedState();
pedited->fattal.enabled = !get_inconsistent();
}
}
void FattalToneMapping::setDefaults(const ProcParams *defParams, const ParamsEdited *pedited)
{
alpha->setDefault(defParams->fattal.alpha);
beta->setDefault(defParams->fattal.beta);
if(pedited) {
alpha->setDefaultEditedState(pedited->fattal.alpha ? Edited : UnEdited);
beta->setDefaultEditedState(pedited->fattal.beta ? Edited : UnEdited);
} else {
alpha->setDefaultEditedState(Irrelevant);
beta->setDefaultEditedState(Irrelevant);
}
}
void FattalToneMapping::adjusterChanged(Adjuster* a, double newval)
{
if(listener && getEnabled()) {
if(a == alpha) {
listener->panelChanged(EvTMFattalAlpha, Glib::ustring::format(std::setw(2), std::fixed, std::setprecision(2), a->getValue()));
} else if(a == beta) {
listener->panelChanged(EvTMFattalBeta, Glib::ustring::format(std::setw(2), std::fixed, std::setprecision(2), a->getValue()));
}
}
}
void FattalToneMapping::enabledChanged ()
{
if (listener) {
if (get_inconsistent()) {
listener->panelChanged (EvTMFattalEnabled, M("GENERAL_UNCHANGED"));
} else if (getEnabled()) {
listener->panelChanged (EvTMFattalEnabled, M("GENERAL_ENABLED"));
} else {
listener->panelChanged (EvTMFattalEnabled, M("GENERAL_DISABLED"));
}
}
}
void FattalToneMapping::setBatchMode(bool batchMode)
{
ToolPanel::setBatchMode(batchMode);
alpha->showEditedCB();
beta->showEditedCB();
}

44
rtgui/fattaltonemap.h Normal file
View File

@@ -0,0 +1,44 @@
/** -*- C++ -*-
*
* This file is part of RawTherapee.
*
* Copyright (c) 2017 Alberto Griggio <alberto.griggio@gmail.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gtkmm.h>
#include "adjuster.h"
#include "toolpanel.h"
class FattalToneMapping: public ToolParamBlock, public AdjusterListener, public FoldableToolPanel
{
protected:
Adjuster *alpha;
Adjuster *beta;
public:
FattalToneMapping();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void adjusterChanged (Adjuster* a, double newval);
void enabledChanged ();
};

View File

@@ -264,6 +264,9 @@ void ParamsEdited::set (bool v)
epd.edgeStopping = v;
epd.scale = v;
epd.reweightingIterates = v;
fattal.enabled = v;
fattal.alpha = v;
fattal.beta = v;
sh.enabled = v;
sh.hq = v;
sh.highlights = v;
@@ -804,6 +807,10 @@ void ParamsEdited::initFrom (const std::vector<rtengine::procparams::ProcParams>
epd.scale = epd.scale && p.epd.scale == other.epd.scale;
epd.reweightingIterates = epd.reweightingIterates && p.epd.reweightingIterates == other.epd.reweightingIterates;
fattal.enabled = fattal.enabled && p.fattal.enabled == other.fattal.enabled;
fattal.alpha = fattal.alpha && p.fattal.alpha == other.fattal.alpha;
fattal.beta = fattal.beta && p.fattal.beta == other.fattal.beta;
sh.enabled = sh.enabled && p.sh.enabled == other.sh.enabled;
sh.hq = sh.hq && p.sh.hq == other.sh.hq;
sh.highlights = sh.highlights && p.sh.highlights == other.sh.highlights;
@@ -1972,6 +1979,16 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
toEdit.epd.reweightingIterates = mods.epd.reweightingIterates;
}
if (fattal.enabled) {
toEdit.fattal.enabled = mods.fattal.enabled;
}
if (fattal.alpha) {
toEdit.fattal.alpha = mods.fattal.alpha;
}
if (fattal.beta) {
toEdit.fattal.beta = mods.fattal.beta;
}
if (sh.enabled) {
toEdit.sh.enabled = mods.sh.enabled;
}

View File

@@ -365,6 +365,14 @@ public:
};
class FattalToneMappingParamsEdited {
public:
bool enabled;
bool alpha;
bool beta;
};
class SHParamsEdited
{
@@ -800,6 +808,7 @@ public:
DefringeParamsEdited defringe;
DirPyrDenoiseParamsEdited dirpyrDenoise;
EPDParamsEdited epd;
FattalToneMappingParamsEdited fattal;
ImpulseDenoiseParamsEdited impulseDenoise;
SHParamsEdited sh;
CropParamsEdited crop;

View File

@@ -90,6 +90,7 @@ ToolPanelCoordinator::ToolPanelCoordinator (bool batch) : ipc (nullptr), hasChan
rawexposure = Gtk::manage (new RAWExposure ());
bayerrawexposure = Gtk::manage (new BayerRAWExposure ());
xtransrawexposure = Gtk::manage (new XTransRAWExposure ());
fattal = Gtk::manage(new FattalToneMapping());
// So Demosaic, Line noise filter, Green Equilibration, Ca-Correction (garder le nom de section identique!) and Black-Level will be moved in a "Bayer sensor" tool,
// and a separate Demosaic and Black Level tool will be created in an "X-Trans sensor" tool
@@ -114,6 +115,7 @@ ToolPanelCoordinator::ToolPanelCoordinator (bool batch) : ipc (nullptr), hasChan
addPanel (colorPanel, rgbcurves);
addPanel (colorPanel, colortoning);
addPanel (exposurePanel, epd);
addPanel (exposurePanel, fattal);
addPanel (exposurePanel, retinex);
addPanel (exposurePanel, pcvignette);
addPanel (exposurePanel, gradient);

View File

@@ -78,6 +78,7 @@
#include "colortoning.h"
#include "filmsimulation.h"
#include "prsharpening.h"
#include "fattaltonemap.h"
#include "guiutils.h"
class ImageEditorCoordinator;
@@ -145,6 +146,7 @@ protected:
RAWExposure* rawexposure;
BayerRAWExposure* bayerrawexposure;
XTransRAWExposure* xtransrawexposure;
FattalToneMapping *fattal;
std::vector<PParamsChangeListener*> paramcListeners;