CA_correct_RT(): readability changes suggested by @Floessie; increased range of iterations adjuster to 5, #4774

This commit is contained in:
heckflosse
2018-09-05 17:54:11 +02:00
parent 9ecc7e6876
commit ac1db99220
3 changed files with 41 additions and 8 deletions

View File

@@ -111,7 +111,19 @@ bool LinEqSolve(int nDim, double* pfMatr, double* pfVect, double* pfSolution)
using namespace std;
using namespace rtengine;
float* RawImageSource::CA_correct_RT(const bool autoCA, const size_t autoIterations, const double cared, const double cablue, const double caautostrength, array2D<float> &rawData, double *fitParamsTransfer, bool fitParamsIn, bool fitParamsOut, float *buffer, bool freeBuffer)
float* RawImageSource::CA_correct_RT(
bool autoCA,
size_t autoIterations,
double cared,
double cablue,
double caautostrength,
const array2D<float> &rawData,
double* fitParamsTransfer,
bool fitParamsIn,
bool fitParamsOut,
float* buffer,
bool freeBuffer
)
{
// multithreaded and vectorized by Ingo Weyrich
constexpr int ts = 128;
@@ -120,14 +132,16 @@ float* RawImageSource::CA_correct_RT(const bool autoCA, const size_t autoIterati
constexpr int v1 = ts, v2 = 2 * ts, v3 = 3 * ts, v4 = 4 * ts; //, p1=-ts+1, p2=-2*ts+2, p3=-3*ts+3, m1=ts+1, m2=2*ts+2, m3=3*ts+3;
// Test for RGB cfa
for(int i = 0; i < 2; i++)
for(int j = 0; j < 2; j++)
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 2; j++) {
if(FC(i, j) == 3) {
printf("CA correction supports only RGB Colour filter arrays\n");
return buffer;
}
}
}
volatile double progress = 0.0;
double progress = 0.0;
if(plistener) {
plistener->setProgress (progress);
@@ -159,9 +173,16 @@ float* RawImageSource::CA_correct_RT(const bool autoCA, const size_t autoIterati
bool processpasstwo = true;
double fitparams[2][2][16];
const size_t iterations = autoCA ? std::max(autoIterations, static_cast<size_t>(1)) : 1;
const size_t iterations =
autoCA
? std::max<size_t>(autoIterations, 1)
: 1;
for (size_t it = 0; it < iterations && processpasstwo; ++it) {
float blockave[2][2] = {{0, 0}, {0, 0}}, blocksqave[2][2] = {{0, 0}, {0, 0}}, blockdenom[2][2] = {{0, 0}, {0, 0}}, blockvar[2][2];
float blockave[2][2] = {};
float blocksqave[2][2] = {};
float blockdenom[2][2] = {};
float blockvar[2][2];
const bool fitParamsSet = fitParamsTransfer && fitParamsIn;
if(autoCA && fitParamsSet && iterations < 2) {
// use stored parameters

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 size_t autoIterations, 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,
double caautostrength,
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

@@ -37,7 +37,7 @@ 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, 3, 1, 1));
caAutoiterations = Gtk::manage(new Adjuster (M("TP_RAWCACORR_AUTOIT"), 1, 5, 1, 1));
caAutoiterations->setAdjusterListener (this);
if (caAutoiterations->delay < options.adjusterMaxDelay) {