raw ca correction: first try to avoid colour shift, #4777
This commit is contained in:
parent
f6195877e5
commit
bcc7a3fb85
@ -749,6 +749,7 @@ 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
|
||||
@ -1782,6 +1783,7 @@ 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
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "rtengine.h"
|
||||
#include "rawimagesource.h"
|
||||
#include "rt_math.h"
|
||||
#include "gauss.h"
|
||||
#include "median.h"
|
||||
//#define BENCHMARK
|
||||
#include "StopWatch.h"
|
||||
@ -118,6 +119,7 @@ float* RawImageSource::CA_correct_RT(
|
||||
double cared,
|
||||
double cablue,
|
||||
double caautostrength,
|
||||
bool avoidColourshift,
|
||||
const array2D<float> &rawData,
|
||||
double* fitParamsTransfer,
|
||||
bool fitParamsIn,
|
||||
@ -142,6 +144,14 @@ float* RawImageSource::CA_correct_RT(
|
||||
}
|
||||
}
|
||||
}
|
||||
array2D<float> oldraw(W,H);
|
||||
if (avoidColourshift) {
|
||||
for(int i = 0; i < H; ++i) {
|
||||
for(int j = 0; j < W; ++j) {
|
||||
oldraw[i][j] = rawData[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double progress = 0.0;
|
||||
|
||||
@ -1230,6 +1240,35 @@ float* RawImageSource::CA_correct_RT(
|
||||
buffer = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (avoidColourshift) {
|
||||
array2D<float> redFactor((W+1)/2, (H+1)/2);
|
||||
array2D<float> blueFactor((W+1)/2, (H+1)/2);
|
||||
|
||||
for(int i = 0; i < H; ++i) {
|
||||
for(int j = 0; j < W; ++j) {
|
||||
float factor = (rawData[i][j] * oldraw[i][j] == 0.0 ? 1.0 : oldraw[i][j] / rawData[i][j]);
|
||||
if(FC(i,j) == 0) {
|
||||
redFactor[i/2][j/2] = factor;
|
||||
} else if(FC(i,j) == 2) {
|
||||
blueFactor[i/2][j/2] = factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
gaussianBlur(redFactor, redFactor, (W+1)/2, (H+1)/2, 30.0);
|
||||
gaussianBlur(blueFactor, blueFactor, (W+1)/2, (H+1)/2, 30.0);
|
||||
|
||||
for(int i = 0; i < H; ++i) {
|
||||
for(int j = 0; j < W; ++j) {
|
||||
if(FC(i,j) == 0) {
|
||||
rawData[i][j] *= redFactor[i/2][j/2];
|
||||
} else if(FC(i,j) == 2) {
|
||||
rawData[i][j] *= blueFactor[i/2][j/2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(plistener) {
|
||||
plistener->setProgress(1.0);
|
||||
}
|
||||
|
@ -2561,6 +2561,7 @@ RAWParams::RAWParams() :
|
||||
ff_AutoClipControl(false),
|
||||
ff_clipControl(0),
|
||||
ca_autocorrect(false),
|
||||
ca_avoidcolourshift(true),
|
||||
caautoiterations(2),
|
||||
cared(0.0),
|
||||
cablue(0.0),
|
||||
@ -2586,6 +2587,7 @@ 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
|
||||
@ -3383,6 +3385,7 @@ 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);
|
||||
@ -4761,6 +4764,12 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
|
||||
} 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
|
||||
|
@ -1368,6 +1368,7 @@ struct RAWParams {
|
||||
int ff_clipControl;
|
||||
|
||||
bool ca_autocorrect;
|
||||
bool ca_avoidcolourshift;
|
||||
int caautoiterations;
|
||||
double cared;
|
||||
double cablue;
|
||||
|
@ -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.caautoiterations, 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, 8.0, raw.ca_avoidcolourshift, *rawDataFrames[0], fitParams, false, true, nullptr, false);
|
||||
for(int i = 1; i < 3; ++i) {
|
||||
CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, 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, 8.0, raw.ca_avoidcolourshift, *rawDataFrames[i], fitParams, true, false, buffer, false);
|
||||
}
|
||||
CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, 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, 8.0, raw.ca_avoidcolourshift, *rawDataFrames[3], fitParams, true, false, buffer, true);
|
||||
} else {
|
||||
CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, raw.cared, raw.cablue, 8.0, rawData, nullptr, false, false, nullptr, true);
|
||||
CA_correct_RT(raw.ca_autocorrect, raw.caautoiterations, raw.cared, raw.cablue, 8.0, raw.ca_avoidcolourshift, rawData, nullptr, false, false, nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,6 +245,7 @@ protected:
|
||||
double cared,
|
||||
double cablue,
|
||||
double caautostrength,
|
||||
bool avoidColourshift,
|
||||
const array2D<float> &rawData,
|
||||
double* fitParamsTransfer,
|
||||
bool fitParamsIn,
|
||||
|
@ -431,6 +431,7 @@ 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;
|
||||
@ -987,6 +988,7 @@ 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;
|
||||
@ -2628,6 +2630,10 @@ 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;
|
||||
}
|
||||
@ -3133,7 +3139,7 @@ bool RAWParamsEdited::XTransSensor::isUnchanged() const
|
||||
|
||||
bool RAWParamsEdited::isUnchanged() const
|
||||
{
|
||||
return bayersensor.isUnchanged() && xtranssensor.isUnchanged() && ca_autocorrect && caautoiterations && 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;
|
||||
}
|
||||
|
||||
|
@ -787,6 +787,7 @@ public:
|
||||
XTransSensor xtranssensor;
|
||||
|
||||
bool ca_autocorrect;
|
||||
bool ca_avoidcolourshift;
|
||||
bool caautoiterations;
|
||||
bool cared;
|
||||
bool cablue;
|
||||
|
@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
// This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes
|
||||
#define PPVERSION 342
|
||||
#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
|
||||
|
@ -28,6 +28,7 @@ RAWCACorr::RAWCACorr () : FoldableToolPanel(this, "rawcacorrection", M("TP_CHROM
|
||||
{
|
||||
auto m = ProcEventMapper::getInstance();
|
||||
EvPreProcessCAAutoiterations = m->newEvent(DARKFRAME, "HISTORY_MSG_RAWCACORR_AUTOIT");
|
||||
EvPreProcessCAColourshift = m->newEvent(DARKFRAME, "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"));
|
||||
@ -66,6 +67,11 @@ RAWCACorr::RAWCACorr () : FoldableToolPanel(this, "rawcacorrection", M("TP_CHROM
|
||||
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)
|
||||
@ -74,7 +80,8 @@ void RAWCACorr::read(const rtengine::procparams::ProcParams* pp, const ParamsEdi
|
||||
|
||||
if(pedited ) {
|
||||
caAutocorrect->setEdited(pedited->raw.ca_autocorrect);
|
||||
caAutoiterations->setEditedState( pedited->raw.cared ? Edited : UnEdited );
|
||||
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 );
|
||||
}
|
||||
@ -85,6 +92,7 @@ void RAWCACorr::read(const rtengine::procparams::ProcParams* pp, const ParamsEdi
|
||||
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);
|
||||
@ -95,12 +103,14 @@ 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 ();
|
||||
@ -136,6 +146,10 @@ void RAWCACorr::checkBoxToggled (CheckBox* c, CheckValue newval)
|
||||
if (listener) {
|
||||
listener->panelChanged (EvPreProcessAutoCA, caAutocorrect->getLastActive() ? M("GENERAL_ENABLED") : M("GENERAL_DISABLED"));
|
||||
}
|
||||
} else if (c == caAvoidcolourshift) {
|
||||
if (listener) {
|
||||
listener->panelChanged (EvPreProcessCAColourshift, caAvoidcolourshift->getLastActive() ? M("GENERAL_ENABLED") : M("GENERAL_DISABLED"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,10 @@ protected:
|
||||
Adjuster* caAutoiterations;
|
||||
Adjuster* caRed;
|
||||
Adjuster* caBlue;
|
||||
CheckBox* caAvoidcolourshift;
|
||||
|
||||
rtengine::ProcEvent EvPreProcessCAAutoiterations;
|
||||
rtengine::ProcEvent EvPreProcessCAColourshift;
|
||||
|
||||
public:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user