Files
rawTherapee/rtgui/filmnegative.h
rom9 e635030650 FilmNegative: non-raw file support and better accuracy (#5798)
* Added support for non-raw files to the film negative tool. The tool is now under the "Color" tab. Moved the entire filmneg code downstream, right after input profile conversion.
Usage changes a bit: White Balance must be set to the _backlight_ color temperature. Added two more sliders to color-balance the picture after negative inversion. Legacy inversion method kept for compatibility with processing profiles saved by RT v5.7 or 5.8 (only if Film Negative was enabled). Should be removed in a future version.
There is still an issue with DCP profiles that need the look table to be active to work properly. Using a simple matrix input profile (or just camera standard) is recommended for now.

* The user can now choose to perform inversion before or after input colorspace conversion.
Seamless backwards compatibility with previous processing profiles; upgrading from a previous version now gives an (almost) identical output as before.
Generalised the concept of film base values: the processing profile now contains a pair of RGB triplets, "reference input" and "reference output", which makes it much more straightforward to compute the output multipliers.

* Added support for `RGB` data type to putToKeyFile, removed the now unused `RGB::toVector()` method. Some cleanup.

* Spot balance picker now stays active indefinitely. Can be disabled by right-clicking, too.

* Removed film negative from `filterRawRefresh` condition, since the new version does not require raw rendering anymore.

* The Output Level slider is now exponential, so it should feel more familiar to use (similar to the exposure compensation slider).

* Removed old `RedBase`, `GreenBase`, `BlueBase` keys from the PP3 file after params upgrade. Keys are only kept if the file only undergoes batch edit (hence no params upgrade was done).

* Made the balance sliders exponential and centered at zero. Now they should be a bit smoother and possibly more user-friendly.

* Changed adjusters' step to more useful values, they were too fine-grained and hard to adjust using the +/- spinbutton.
Increased max ratio value from 3 to 5, as i found an old negative needing a very high blue channel exponent.

* Added an initial processing profile for film negative inversion, to be provided as a bundled profile.

* Removed Output Level and balance sliders when in batch mode: since the effect of these sliders is dependent on the reference input values, those values needed to be copied as well. And, touching any of the sliders needed to flag all three as dirty. All this felt more confusing than useful.
It should be sufficient (and clearer) to copy/paste the params, and then fine-tune the balance on individual pictures when needed.

* Set bayer demosaic method to RCD in the bundled "Film Negative" processing profile. RCD seems to play a bit better with Capture Sharpening in the presence of film grain, compared to Amaze.
This will favor new users starting with all-defaults settings, hence having Capture Sharpening enabled by default.

* Removed incorrect "contrast" term from the "Reference exponent" label. This parameter adjusts the image _gamma_, not its contrast.
2020-11-21 13:29:47 +01:00

122 lines
3.6 KiB
C++

/*
* This file is part of RawTherapee.
*
* Copyright (c) 2019 Alberto Romei <aldrop8@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 <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <array>
#include <gtkmm.h>
#include "adjuster.h"
#include "editcallbacks.h"
#include "guiutils.h"
#include "toolpanel.h"
#include "../rtengine/colortemp.h"
namespace
{
using RGB = rtengine::procparams::FilmNegativeParams::RGB;
using ColorSpace = rtengine::procparams::FilmNegativeParams::ColorSpace;
using BackCompat = rtengine::procparams::FilmNegativeParams::BackCompat;
}
class FilmNegProvider
{
public:
virtual ~FilmNegProvider() = default;
virtual bool getFilmNegativeSpot(rtengine::Coord spot, int spotSize, RGB &refInput, RGB &refOutput) = 0;
};
class FilmNegative final :
public ToolParamBlock,
public AdjusterListener,
public FoldableToolPanel,
public EditSubscriber,
public rtengine::FilmNegListener
{
public:
FilmNegative();
~FilmNegative() override;
void read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr) override;
void write(rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr) override;
void setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override;
void setBatchMode(bool batchMode) override;
void adjusterChanged(Adjuster* a, double newval) override;
void enabledChanged() override;
void colorSpaceChanged();
void filmRefValuesChanged(const RGB &refInput, const RGB &refOutput) override;
void setFilmNegProvider(FilmNegProvider* provider);
void setEditProvider(EditDataProvider* provider) override;
// EditSubscriber interface
CursorShape getCursor(int objectID) const override;
bool mouseOver(int modifierKey) override;
bool button1Pressed(int modifierKey) override;
bool button1Released() override;
bool button3Pressed(int modifierKey) override;
void switchOffEditMode() override;
private:
void editToggled();
void refSpotToggled();
void readOutputSliders(RGB &refOutput);
void writeOutputSliders(const RGB &refOutput);
// ColorTemp value corresponding to neutral RGB multipliers (1,1,1). Should be around 6500K.
const rtengine::ColorTemp NEUTRAL_TEMP;
const rtengine::ProcEvent evFilmNegativeExponents;
const rtengine::ProcEvent evFilmNegativeEnabled;
const rtengine::ProcEvent evFilmNegativeRefSpot;
const rtengine::ProcEvent evFilmNegativeBalance;
const rtengine::ProcEvent evFilmNegativeColorSpace;
std::vector<rtengine::Coord> refSpotCoords;
RGB refInputValues;
bool paramsUpgraded;
FilmNegProvider* fnp;
MyComboBoxText* const colorSpace;
Adjuster* const greenExp;
Adjuster* const redRatio;
Adjuster* const blueRatio;
Gtk::ToggleButton* const spotButton;
Gtk::Label* const refInputLabel;
Gtk::ToggleButton* const refSpotButton;
Adjuster* const outputLevel;
Adjuster* const greenBalance;
Adjuster* const blueBalance;
IdleRegister idle_register;
};