Merge pull request #4797 from Beep6581/rawcacorrection_iterate

Raw ca correction. Iterative processing and Avoid color shift.
This commit is contained in:
Ingo Weyrich 2018-09-15 00:15:57 +02:00 committed by GitHub
commit f9404901ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1218 additions and 998 deletions

View File

@ -748,6 +748,8 @@ HISTORY_MSG_PREPROCESS_LINEDENOISE_DIRECTION;Line noise filter direction
HISTORY_MSG_PREPROCESS_PDAFLINESFILTER;PDAF lines filter
HISTORY_MSG_PRSHARPEN_CONTRAST;PRS - Contrast threshold
HISTORY_MSG_RAW_BORDER;Raw border
HISTORY_MSG_RAWCACORR_AUTOIT;Raw CA Correction - Iterations
HISTORY_MSG_RAWCACORR_COLOURSHIFT;Raw CA Correction - Avoid color shift
HISTORY_MSG_RESIZE_ALLOWUPSCALING;Resize - Allow upscaling
HISTORY_MSG_SHARPENING_CONTRAST;Sharpening - Contrast threshold
HISTORY_MSG_SOFTLIGHT_ENABLED;Soft light
@ -1780,6 +1782,8 @@ TP_PREPROCESS_PDAFLINESFILTER_TOOLTIP;Tries to suppress stripe noise caused by o
TP_PRSHARPENING_LABEL;Post-Resize Sharpening
TP_PRSHARPENING_TOOLTIP;Sharpens the image after resizing. Only works when the "Lanczos" resizing method is used. It is impossible to preview the effects of this tool. See RawPedia for usage instructions.
TP_RAWCACORR_AUTO;Auto-correction
TP_RAWCACORR_AUTOIT;Iterations
TP_RAWCACORR_AVOIDCOLORSHIFT;Avoid color shift
TP_RAWCACORR_CABLUE;Blue
TP_RAWCACORR_CARED;Red
TP_RAWCACORR_CASTR;Strength

File diff suppressed because it is too large Load Diff

View File

@ -2561,6 +2561,8 @@ RAWParams::RAWParams() :
ff_AutoClipControl(false),
ff_clipControl(0),
ca_autocorrect(false),
ca_avoidcolourshift(true),
caautoiterations(2),
cared(0.0),
cablue(0.0),
expos(1.0),
@ -2585,6 +2587,8 @@ bool RAWParams::operator ==(const RAWParams& other) const
&& ff_AutoClipControl == other.ff_AutoClipControl
&& ff_clipControl == other.ff_clipControl
&& ca_autocorrect == other.ca_autocorrect
&& ca_avoidcolourshift == other.ca_avoidcolourshift
&& caautoiterations == other.caautoiterations
&& cared == other.cared
&& cablue == other.cablue
&& expos == other.expos
@ -3381,6 +3385,8 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || pedited->raw.ff_AutoClipControl, "RAW", "FlatFieldAutoClipControl", raw.ff_AutoClipControl, keyFile);
saveToKeyfile(!pedited || pedited->raw.ff_clipControl, "RAW", "FlatFieldClipControl", raw.ff_clipControl, keyFile);
saveToKeyfile(!pedited || pedited->raw.ca_autocorrect, "RAW", "CA", raw.ca_autocorrect, keyFile);
saveToKeyfile(!pedited || pedited->raw.ca_avoidcolourshift, "RAW", "CAAvoidColourshift", raw.ca_avoidcolourshift, keyFile);
saveToKeyfile(!pedited || pedited->raw.caautoiterations, "RAW", "CAAutoIterations", raw.caautoiterations, keyFile);
saveToKeyfile(!pedited || pedited->raw.cared, "RAW", "CARed", raw.cared, keyFile);
saveToKeyfile(!pedited || pedited->raw.cablue, "RAW", "CABlue", raw.cablue, keyFile);
saveToKeyfile(!pedited || pedited->raw.hotPixelFilter, "RAW", "HotPixelFilter", raw.hotPixelFilter, keyFile);
@ -4753,6 +4759,17 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
}
assignFromKeyfile(keyFile, "RAW", "CA", pedited, raw.ca_autocorrect, pedited->raw.ca_autocorrect);
if (ppVersion >= 342) {
assignFromKeyfile(keyFile, "RAW", "CAAutoIterations", pedited, raw.caautoiterations, pedited->raw.caautoiterations);
} else {
raw.caautoiterations = 1;
}
if (ppVersion >= 343) {
assignFromKeyfile(keyFile, "RAW", "CAAvoidColourshift", pedited, raw.ca_avoidcolourshift, pedited->raw.ca_avoidcolourshift);
} else {
raw.ca_avoidcolourshift = false;
}
assignFromKeyfile(keyFile, "RAW", "CARed", pedited, raw.cared, pedited->raw.cared);
assignFromKeyfile(keyFile, "RAW", "CABlue", pedited, raw.cablue, pedited->raw.cablue);
// For compatibility to elder pp3 versions

View File

@ -1368,6 +1368,8 @@ struct RAWParams {
int ff_clipControl;
bool ca_autocorrect;
bool ca_avoidcolourshift;
int caautoiterations;
double cared;
double cablue;

View File

@ -2009,13 +2009,13 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
}
if(numFrames == 4) {
double fitParams[64];
float *buffer = CA_correct_RT(raw.ca_autocorrect, raw.cared, raw.cablue, 8.0, *rawDataFrames[0], fitParams, false, true, nullptr, false);
float *buffer = CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, raw.cared, raw.cablue, true, *rawDataFrames[0], fitParams, false, true, nullptr, false);
for(int i = 1; i < 3; ++i) {
CA_correct_RT(raw.ca_autocorrect, raw.cared, raw.cablue, 8.0, *rawDataFrames[i], fitParams, true, false, buffer, false);
CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, raw.cared, raw.cablue, true, *rawDataFrames[i], fitParams, true, false, buffer, false);
}
CA_correct_RT(raw.ca_autocorrect, raw.cared, raw.cablue, 8.0, *rawDataFrames[3], fitParams, true, false, buffer, true);
CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, raw.cared, raw.cablue, true, *rawDataFrames[3], fitParams, true, false, buffer, true);
} else {
CA_correct_RT(raw.ca_autocorrect, raw.cared, raw.cablue, 8.0, rawData, nullptr, false, false, nullptr, true);
CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, raw.cared, raw.cablue, true, rawData, nullptr, false, false, nullptr, true);
}
}

View File

@ -239,7 +239,19 @@ protected:
inline void interpolate_row_rb (float* ar, float* ab, float* pg, float* cg, float* ng, int i);
inline void interpolate_row_rb_mul_pp (const array2D<float> &rawData, float* ar, float* ab, float* pg, float* cg, float* ng, int i, float r_mul, float g_mul, float b_mul, int x1, int width, int skip);
float* CA_correct_RT (const bool autoCA, const double cared, const double cablue, const double caautostrength, array2D<float> &rawData, double *fitParamsTransfer, bool fitParamsIn, bool fitParamsOut, float * buffer, bool freeBuffer);
float* CA_correct_RT(
bool autoCA,
size_t autoIterations,
double cared,
double cablue,
bool avoidColourshift,
const array2D<float> &rawData,
double* fitParamsTransfer,
bool fitParamsIn,
bool fitParamsOut,
float* buffer,
bool freeBuffer
);
void ddct8x8s(int isgn, float a[8][8]);
void processRawWhitepoint (float expos, float preser, array2D<float> &rawData); // exposure before interpolation

View File

@ -431,6 +431,8 @@ void ParamsEdited::set(bool v)
raw.xtranssensor.exBlackGreen = v;
raw.xtranssensor.exBlackBlue = v;
raw.ca_autocorrect = v;
raw.ca_avoidcolourshift = v;
raw.caautoiterations = v;
raw.cablue = v;
raw.cared = v;
raw.hotPixelFilter = v;
@ -986,6 +988,8 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
raw.xtranssensor.exBlackGreen = raw.xtranssensor.exBlackGreen && p.raw.xtranssensor.blackgreen == other.raw.xtranssensor.blackgreen;
raw.xtranssensor.exBlackBlue = raw.xtranssensor.exBlackBlue && p.raw.xtranssensor.blackblue == other.raw.xtranssensor.blackblue;
raw.ca_autocorrect = raw.ca_autocorrect && p.raw.ca_autocorrect == other.raw.ca_autocorrect;
raw.ca_avoidcolourshift = raw.ca_avoidcolourshift && p.raw.ca_avoidcolourshift == other.raw.ca_avoidcolourshift;
raw.caautoiterations = raw.caautoiterations && p.raw.caautoiterations == other.raw.caautoiterations;
raw.cared = raw.cared && p.raw.cared == other.raw.cared;
raw.cablue = raw.cablue && p.raw.cablue == other.raw.cablue;
raw.hotPixelFilter = raw.hotPixelFilter && p.raw.hotPixelFilter == other.raw.hotPixelFilter;
@ -2626,6 +2630,14 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
toEdit.raw.ca_autocorrect = mods.raw.ca_autocorrect;
}
if (raw.ca_avoidcolourshift) {
toEdit.raw.ca_avoidcolourshift = mods.raw.ca_avoidcolourshift;
}
if (raw.caautoiterations) {
toEdit.raw.caautoiterations = dontforceSet && options.baBehav[ADDSET_RAWCACORR] ? toEdit.raw.caautoiterations + mods.raw.caautoiterations : mods.raw.caautoiterations;
}
if (raw.cared) {
toEdit.raw.cared = dontforceSet && options.baBehav[ADDSET_RAWCACORR] ? toEdit.raw.cared + mods.raw.cared : mods.raw.cared;
}
@ -3127,7 +3139,7 @@ bool RAWParamsEdited::XTransSensor::isUnchanged() const
bool RAWParamsEdited::isUnchanged() const
{
return bayersensor.isUnchanged() && xtranssensor.isUnchanged() && ca_autocorrect && cared && cablue && hotPixelFilter && deadPixelFilter && hotdeadpix_thresh && darkFrame
return bayersensor.isUnchanged() && xtranssensor.isUnchanged() && ca_autocorrect && ca_avoidcolourshift && caautoiterations && cared && cablue && hotPixelFilter && deadPixelFilter && hotdeadpix_thresh && darkFrame
&& df_autoselect && ff_file && ff_AutoSelect && ff_BlurRadius && ff_BlurType && exPos && exPreser && ff_AutoClipControl && ff_clipControl;
}

View File

@ -787,6 +787,8 @@ public:
XTransSensor xtranssensor;
bool ca_autocorrect;
bool ca_avoidcolourshift;
bool caautoiterations;
bool cared;
bool cablue;
bool hotPixelFilter;

View File

@ -901,6 +901,7 @@ void PartialPasteDlg::applyPaste (rtengine::procparams::ProcParams* dstPP, Param
if (!raw_ca_autocorrect->get_active ()) {
filterPE.raw.ca_autocorrect = falsePE.raw.ca_autocorrect;
filterPE.raw.caautoiterations = falsePE.raw.caautoiterations;
}
if (!raw_caredblue->get_active ()) {

View File

@ -1,11 +1,15 @@
#pragma once
// This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes
#define PPVERSION 340
#define PPVERSION 343
#define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified
/*
Log of version changes
343 2018-09-06
raw auto ca correction avoid colour shift
342 2018-09-05
raw auto ca correction iterations
341 2018-07-22
[ICM] enhanced custom output profile
340 2018-07-08

View File

@ -17,6 +17,7 @@
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rawcacorrection.h"
#include "eventmapper.h"
#include "guiutils.h"
#include "rtimage.h"
@ -25,6 +26,11 @@ using namespace rtengine::procparams;
RAWCACorr::RAWCACorr () : FoldableToolPanel(this, "rawcacorrection", M("TP_CHROMATABERR_LABEL"))
{
auto m = ProcEventMapper::getInstance();
EvPreProcessCAAutoiterations = m->newEvent(DARKFRAME, "HISTORY_MSG_RAWCACORR_AUTOIT");
// EvPreProcessCAColourshift = m->newEvent(DARKFRAME, "HISTORY_MSG_RAWCACORR_COLOURSHIFT");
// EvPreProcessCAColourshiftHistory = m->newEvent(M_VOID, "HISTORY_MSG_RAWCACORR_COLOURSHIFT");
Gtk::Image* icaredL = Gtk::manage (new RTImage ("circle-red-cyan-small.png"));
Gtk::Image* icaredR = Gtk::manage (new RTImage ("circle-cyan-red-small.png"));
Gtk::Image* icablueL = Gtk::manage (new RTImage ("circle-blue-yellow-small.png"));
@ -33,6 +39,13 @@ RAWCACorr::RAWCACorr () : FoldableToolPanel(this, "rawcacorrection", M("TP_CHROM
caAutocorrect = Gtk::manage (new CheckBox(M("TP_RAWCACORR_AUTO"), multiImage));
caAutocorrect->setCheckBoxListener (this);
caAutoiterations = Gtk::manage(new Adjuster (M("TP_RAWCACORR_AUTOIT"), 1, 5, 1, 2));
caAutoiterations->setAdjusterListener (this);
if (caAutoiterations->delay < options.adjusterMaxDelay) {
caAutoiterations->delay = options.adjusterMaxDelay;
}
caRed = Gtk::manage(new Adjuster (M("TP_RAWCACORR_CARED"), -8.0, 8.0, 0.1, 0, icaredL, icaredR));
caRed->setAdjusterListener (this);
@ -51,9 +64,15 @@ RAWCACorr::RAWCACorr () : FoldableToolPanel(this, "rawcacorrection", M("TP_CHROM
caBlue->show();
pack_start( *caAutocorrect, Gtk::PACK_SHRINK, 4);
pack_start( *caAutoiterations, Gtk::PACK_SHRINK, 4);
pack_start( *caRed, Gtk::PACK_SHRINK, 4);
pack_start( *caBlue, Gtk::PACK_SHRINK, 4);
// caAvoidcolourshift = Gtk::manage (new CheckBox(M("TP_RAWCACORR_AVOIDCOLORSHIFT"), multiImage));
// caAvoidcolourshift->setCheckBoxListener (this);
// pack_start( *caAvoidcolourshift, Gtk::PACK_SHRINK, 4);
}
void RAWCACorr::read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited)
@ -62,15 +81,20 @@ void RAWCACorr::read(const rtengine::procparams::ProcParams* pp, const ParamsEdi
if(pedited ) {
caAutocorrect->setEdited(pedited->raw.ca_autocorrect);
// caAvoidcolourshift->setEdited(pedited->raw.ca_avoidcolourshift);
caAutoiterations->setEditedState( pedited->raw.caautoiterations ? Edited : UnEdited );
caRed->setEditedState( pedited->raw.cared ? Edited : UnEdited );
caBlue->setEditedState( pedited->raw.cablue ? Edited : UnEdited );
}
// disable Red and Blue sliders when caAutocorrect is enabled
caAutoiterations->set_sensitive(pp->raw.ca_autocorrect);
caRed->set_sensitive(!pp->raw.ca_autocorrect);
caBlue->set_sensitive(!pp->raw.ca_autocorrect);
caAutocorrect->setValue(pp->raw.ca_autocorrect);
// caAvoidcolourshift->setValue(pp->raw.ca_avoidcolourshift);
caAutoiterations->setValue (pp->raw.caautoiterations);
caRed->setValue (pp->raw.cared);
caBlue->setValue (pp->raw.cablue);
@ -80,11 +104,15 @@ void RAWCACorr::read(const rtengine::procparams::ProcParams* pp, const ParamsEdi
void RAWCACorr::write( rtengine::procparams::ProcParams* pp, ParamsEdited* pedited)
{
pp->raw.ca_autocorrect = caAutocorrect->getLastActive();
// pp->raw.ca_avoidcolourshift = caAvoidcolourshift->getLastActive();
pp->raw.caautoiterations = caAutoiterations->getValue();
pp->raw.cared = caRed->getValue();
pp->raw.cablue = caBlue->getValue();
if (pedited) {
pedited->raw.ca_autocorrect = !caAutocorrect->get_inconsistent();
// pedited->raw.ca_avoidcolourshift = !caAvoidcolourshift->get_inconsistent();
pedited->raw.caautoiterations = caAutoiterations->getEditedState ();
pedited->raw.cared = caRed->getEditedState ();
pedited->raw.cablue = caBlue->getEditedState ();
}
@ -97,7 +125,9 @@ void RAWCACorr::adjusterChanged (Adjuster* a, double newval)
Glib::ustring value = a->getTextValue();
if (a == caRed) {
if (a == caAutoiterations) {
listener->panelChanged (EvPreProcessCAAutoiterations, value );
} else if (a == caRed) {
listener->panelChanged (EvPreProcessCARed, value );
} else if (a == caBlue) {
listener->panelChanged (EvPreProcessCABlue, value );
@ -110,6 +140,7 @@ void RAWCACorr::checkBoxToggled (CheckBox* c, CheckValue newval)
if (c == caAutocorrect) {
if (!batchMode) {
// disable Red and Blue sliders when caAutocorrect is enabled
caAutoiterations->set_sensitive(caAutocorrect->getLastActive ());
caRed->set_sensitive(!caAutocorrect->getLastActive ());
caBlue->set_sensitive(!caAutocorrect->getLastActive ());
}
@ -117,24 +148,33 @@ void RAWCACorr::checkBoxToggled (CheckBox* c, CheckValue newval)
listener->panelChanged (EvPreProcessAutoCA, caAutocorrect->getLastActive() ? M("GENERAL_ENABLED") : M("GENERAL_DISABLED"));
}
}
// else if (c == caAvoidcolourshift) {
// if (listener) {
// listener->panelChanged ((caAutocorrect->getLastActive() || caRed->getValue() != 0 || caBlue->getValue() != 0) ? EvPreProcessCAColourshift : EvPreProcessCAColourshiftHistory, caAvoidcolourshift->getLastActive() ? M("GENERAL_ENABLED") : M("GENERAL_DISABLED"));
// }
// }
}
void RAWCACorr::setBatchMode(bool batchMode)
{
ToolPanel::setBatchMode (batchMode);
caAutoiterations->showEditedCB ();
caRed->showEditedCB ();
caBlue->showEditedCB ();
}
void RAWCACorr::setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited)
{
caAutoiterations->setDefault( defParams->raw.caautoiterations);
caRed->setDefault( defParams->raw.cared);
caBlue->setDefault( defParams->raw.cablue);
if (pedited) {
caAutoiterations->setDefaultEditedState( pedited->raw.caautoiterations ? Edited : UnEdited);
caRed->setDefaultEditedState( pedited->raw.cared ? Edited : UnEdited);
caBlue->setDefaultEditedState( pedited->raw.cablue ? Edited : UnEdited);
} else {
caAutoiterations->setDefaultEditedState( Irrelevant );
caRed->setDefaultEditedState( Irrelevant );
caBlue->setDefaultEditedState( Irrelevant );
}
@ -150,6 +190,7 @@ void RAWCACorr::setAdjusterBehavior (bool caadd)
void RAWCACorr::trimValues (rtengine::procparams::ProcParams* pp)
{
caAutoiterations->trimValue(pp->raw.caautoiterations);
caRed->trimValue(pp->raw.cared);
caBlue->trimValue(pp->raw.cablue);
}

View File

@ -29,8 +29,14 @@ class RAWCACorr : public ToolParamBlock, public AdjusterListener, public CheckBo
protected:
CheckBox* caAutocorrect;
Adjuster* caAutoiterations;
Adjuster* caRed;
Adjuster* caBlue;
// CheckBox* caAvoidcolourshift;
rtengine::ProcEvent EvPreProcessCAAutoiterations;
// rtengine::ProcEvent EvPreProcessCAColourshift;
// rtengine::ProcEvent EvPreProcessCAColourshiftHistory;
public: