Solving issue 1001: "Auto WB is saved as Custom in profile files" and 929: "Crash on image open with WB method = Auto" with a different workaround
This commit is contained in:
@@ -78,6 +78,7 @@ class ImageSource : public InitialImage {
|
||||
virtual bool IsrgbSourceModified() =0; // tracks whether cached rgb output of demosaic has been modified
|
||||
|
||||
virtual void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, HRecParams hlp, ColorManagementParams cmp, RAWParams raw) {}
|
||||
virtual bool isWBProviderReady () =0;
|
||||
virtual ColorTemp getWB () =0;
|
||||
virtual ColorTemp getAutoWB () =0;
|
||||
virtual ColorTemp getSpotWB (std::vector<Coord2D> red, std::vector<Coord2D> green, std::vector<Coord2D>& blue, int tran) =0;
|
||||
|
@@ -354,6 +354,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
|
||||
imageListener->setImage (previmg, scale, params.crop);
|
||||
}
|
||||
if (imageListener)
|
||||
// TODO: The WB tool should be advertised too in order to get the AutoWB's temp and green values
|
||||
imageListener->imageReady (params.crop);
|
||||
|
||||
readyphase++;
|
||||
@@ -487,9 +488,9 @@ void ImProcCoordinator::progress (Glib::ustring str, int pr) {
|
||||
}*/
|
||||
}
|
||||
|
||||
void ImProcCoordinator::getAutoWB (double& temp, double& green) {
|
||||
bool ImProcCoordinator::getAutoWB (double& temp, double& green) {
|
||||
|
||||
if (imgsrc) {
|
||||
if (imgsrc && imgsrc->isWBProviderReady()) {
|
||||
if (!awbComputed) {
|
||||
minit.lock ();
|
||||
autoWB = imgsrc->getAutoWB ();
|
||||
@@ -498,6 +499,12 @@ void ImProcCoordinator::getAutoWB (double& temp, double& green) {
|
||||
}
|
||||
temp = autoWB.getTemp ();
|
||||
green = autoWB.getGreen ();
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
temp = -1.0;
|
||||
green = -1.0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ class ImProcCoordinator : public StagedImageProcessor {
|
||||
LabImage *oprevl;
|
||||
LabImage *nprevl;
|
||||
Image8 *previmg;
|
||||
Image8 *workimg;
|
||||
Image8 *workimg;
|
||||
|
||||
ImageSource* imgsrc;
|
||||
|
||||
@@ -65,28 +65,28 @@ class ImProcCoordinator : public StagedImageProcessor {
|
||||
|
||||
void freeAll ();
|
||||
|
||||
LUTf hltonecurve;
|
||||
LUTf shtonecurve;
|
||||
LUTf tonecurve;
|
||||
LUTf hltonecurve;
|
||||
LUTf shtonecurve;
|
||||
LUTf tonecurve;
|
||||
|
||||
LUTf lumacurve;
|
||||
LUTf chroma_acurve;
|
||||
LUTf chroma_bcurve;
|
||||
LUTf satcurve;
|
||||
LUTf lumacurve;
|
||||
LUTf chroma_acurve;
|
||||
LUTf chroma_bcurve;
|
||||
LUTf satcurve;
|
||||
|
||||
LUTf rCurve;
|
||||
LUTf gCurve;
|
||||
LUTf bCurve;
|
||||
LUTf rCurve;
|
||||
LUTf gCurve;
|
||||
LUTf bCurve;
|
||||
|
||||
LUTu rcurvehist, rcurvehistCropped, rbeforehist;
|
||||
LUTu gcurvehist, gcurvehistCropped, gbeforehist;
|
||||
LUTu bcurvehist, bcurvehistCropped, bbeforehist;
|
||||
LUTu rcurvehist, rcurvehistCropped, rbeforehist;
|
||||
LUTu gcurvehist, gcurvehistCropped, gbeforehist;
|
||||
LUTu bcurvehist, bcurvehistCropped, bbeforehist;
|
||||
|
||||
LUTu vhist16;
|
||||
LUTu lhist16,lhist16Cropped;
|
||||
LUTu vhist16;
|
||||
LUTu lhist16,lhist16Cropped;
|
||||
LUTu histCropped;
|
||||
|
||||
LUTu histRed, histGreen, histBlue, histLuma, histToneCurve, histLCurve, bcabhist;
|
||||
LUTu histRed, histGreen, histBlue, histLuma, histToneCurve, histLCurve, bcabhist;
|
||||
LUTu histRedRaw, histGreenRaw, histBlueRaw;
|
||||
|
||||
int fw, fh, tr, fullw, fullh;
|
||||
@@ -153,7 +153,7 @@ class ImProcCoordinator : public StagedImageProcessor {
|
||||
|
||||
DetailedCrop* createCrop ();
|
||||
|
||||
void getAutoWB (double& temp, double& green);
|
||||
bool getAutoWB (double& temp, double& green);
|
||||
void getCamWB (double& temp, double& green);
|
||||
void getSpotWB (int x, int y, int rectSize, double& temp, double& green);
|
||||
void getAutoCrop (double ratio, int &x, int &y, int &w, int &h);
|
||||
|
@@ -443,12 +443,7 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2) const {
|
||||
keyFile.set_double ("Color Boost", "SaturationLimit", colorBoost.saturationlimit);
|
||||
|
||||
// save wb
|
||||
if (wb.method=="Auto")
|
||||
// note that "Auto" has been ruled out. It's just custom.
|
||||
keyFile.set_string ("White Balance", "Setting", "Custom");
|
||||
else
|
||||
keyFile.set_string ("White Balance", "Setting", wb.method);
|
||||
|
||||
keyFile.set_string ("White Balance", "Setting", wb.method);
|
||||
keyFile.set_integer ("White Balance", "Temperature", wb.temperature);
|
||||
keyFile.set_double ("White Balance", "Green", wb.green);
|
||||
|
||||
|
@@ -57,7 +57,7 @@ template<class T> void freeArray2 (T** a, int H) {
|
||||
|
||||
class RawImageSource : public ImageSource {
|
||||
|
||||
private:
|
||||
private:
|
||||
static LUTf invGrad; // for fast_demosaic
|
||||
static LUTf initInvGrad ();
|
||||
static bool findInputProfile(Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, cmsHPROFILE& in);
|
||||
@@ -69,10 +69,10 @@ class RawImageSource : public ImageSource {
|
||||
ColorTemp wb;
|
||||
ProgressListener* plistener;
|
||||
float scale_mul[4]; // multiplier for each color
|
||||
float cblack[4];// black
|
||||
float scale_mu_l[4];// copy of scale_mul, for saturation
|
||||
float c_black[4]; // copy of cblack Dcraw for black level
|
||||
float cblacksom[4];
|
||||
float cblack[4];// black
|
||||
float scale_mu_l[4];// copy of scale_mul, for saturation
|
||||
float c_black[4]; // copy of cblack Dcraw for black level
|
||||
float cblacksom[4];
|
||||
double camwb_red;
|
||||
double camwb_green;
|
||||
double camwb_blue;
|
||||
@@ -86,8 +86,8 @@ class RawImageSource : public ImageSource {
|
||||
//char** hpmap;
|
||||
float** hrmap[3]; // for color propagation
|
||||
char** needhr; // for color propagation
|
||||
int max[3];
|
||||
float chmax[4],hlmax[4];
|
||||
int max[3];
|
||||
float chmax[4],hlmax[4];
|
||||
double initialGain; // initial gain calculated after scale_colors
|
||||
double defGain;
|
||||
bool full;
|
||||
@@ -149,6 +149,7 @@ class RawImageSource : public ImageSource {
|
||||
ColorTemp getWB () { return wb; }
|
||||
ColorTemp getAutoWB ();
|
||||
ColorTemp getSpotWB (std::vector<Coord2D> red, std::vector<Coord2D> green, std::vector<Coord2D>& blue, int tran);
|
||||
bool isWBProviderReady () { return rawData != NULL; };
|
||||
|
||||
double getDefGain () { return defGain; }
|
||||
|
||||
@@ -166,17 +167,17 @@ class RawImageSource : public ImageSource {
|
||||
static void colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], std::string camName, double& defgain);
|
||||
static void inverse33 (double (*coeff)[3], double (*icoeff)[3]);
|
||||
|
||||
void boxblur2(float** src, float** dst, int H, int W, int box );
|
||||
void boxblur_resamp(float **src, float **dst, float & max, int H, int W, int box, int samp );
|
||||
void boxblur2(float** src, float** dst, int H, int W, int box );
|
||||
void boxblur_resamp(float **src, float **dst, float & max, int H, int W, int box, int samp );
|
||||
|
||||
//void boxblur_resamp(float **red, float **green, float **blue, int H, int W, float thresh[3], float max[3], \
|
||||
multi_array2D<float,3> & hfsize, multi_array2D<float,3> & hilite, int box );
|
||||
void HLRecovery_inpaint (float** red, float** green, float** blue);
|
||||
//void HLRecovery_inpaint ();
|
||||
//void boxblur_resamp(float **red, float **green, float **blue, int H, int W, float thresh[3], float max[3],
|
||||
// multi_array2D<float,3> & hfsize, multi_array2D<float,3> & hilite, int box );
|
||||
void HLRecovery_inpaint (float** red, float** green, float** blue);
|
||||
//void HLRecovery_inpaint ();
|
||||
|
||||
static void HLRecovery_Luminance (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval);
|
||||
static void HLRecovery_CIELab (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval, double cam[3][3], double icam[3][3]);
|
||||
static void HLRecovery_blend (float* rin, float* gin, float* bin, int width, float maxval, float* pre_mul, const RAWParams &raw, float* hlmax);
|
||||
static void HLRecovery_blend (float* rin, float* gin, float* bin, int width, float maxval, float* pre_mul, const RAWParams &raw, float* hlmax);
|
||||
|
||||
protected:
|
||||
typedef unsigned short ushort;
|
||||
|
@@ -296,7 +296,7 @@ namespace rtengine {
|
||||
/** Creates and returns a Crop instance that acts as a window on the image */
|
||||
virtual DetailedCrop* createCrop () =0;
|
||||
|
||||
virtual void getAutoWB (double& temp, double& green) =0;
|
||||
virtual bool getAutoWB (double& temp, double& green) =0;
|
||||
virtual void getCamWB (double& temp, double& green) =0;
|
||||
virtual void getSpotWB (int x, int y, int rectSize, double& temp, double& green) =0;
|
||||
virtual void getAutoCrop (double ratio, int &x, int &y, int &w, int &h) =0;
|
||||
|
@@ -46,6 +46,7 @@ class StdImageSource : public ImageSource {
|
||||
ColorTemp getWB () { return wb; }
|
||||
ColorTemp getAutoWB ();
|
||||
ColorTemp getSpotWB (std::vector<Coord2D> red, std::vector<Coord2D> green, std::vector<Coord2D>& blue, int tran);
|
||||
bool isWBProviderReady () { return true; };
|
||||
|
||||
void getAutoExpHistogram (LUTu &histogram, int& histcompr);
|
||||
|
||||
|
@@ -264,8 +264,10 @@ void WhiteBalance::optChanged () {
|
||||
if (wbp) {
|
||||
double ctemp, cgreen;
|
||||
wbp->getAutoWB (ctemp, cgreen);
|
||||
temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp);
|
||||
green->setValue (green->getAddMode() ? 0.0 : cgreen);
|
||||
if (ctemp != -1.0) {
|
||||
temp->setValue (temp->getAddMode() ? 0.0 : (int)ctemp);
|
||||
green->setValue (green->getAddMode() ? 0.0 : cgreen);
|
||||
}
|
||||
if (batchMode) {
|
||||
temp->setEditedState (UnEdited);
|
||||
green->setEditedState (UnEdited);
|
||||
@@ -371,10 +373,12 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) {
|
||||
double ctemp; double cgreen;
|
||||
wbp->getAutoWB (ctemp, cgreen);
|
||||
|
||||
// Set the automatics temperature value, or 0.0 if in ADD mode
|
||||
temp->setValue (temp->getAddMode() ? 0.0 : ctemp);
|
||||
// Set the automatics green value, or 0.0 if in ADD mode
|
||||
green->setValue (green->getAddMode() ? 0.0 : cgreen);
|
||||
if (ctemp != -1.0) {
|
||||
// Set the automatics temperature value, or 0.0 if in ADD mode
|
||||
temp->setValue (temp->getAddMode() ? 0.0 : ctemp);
|
||||
// Set the automatics green value, or 0.0 if in ADD mode
|
||||
green->setValue (green->getAddMode() ? 0.0 : cgreen);
|
||||
}
|
||||
|
||||
//cache_customWB ((int)ctemp, cgreen); // this will be used to set initial Custom WB setting
|
||||
}
|
||||
@@ -420,7 +424,7 @@ void WhiteBalance::write (ProcParams* pp, ParamsEdited* pedited) {
|
||||
WBEntry* ppMethod = findWBEntry (row[methodColumns.colLabel], WBLT_GUI);
|
||||
|
||||
if (ppMethod)
|
||||
pp->wb.method = ppMethod->ppLabel == "Auto" ? "Custom" : ppMethod->ppLabel;
|
||||
pp->wb.method = ppMethod->ppLabel;
|
||||
pp->wb.temperature = temp->getIntValue ();
|
||||
pp->wb.green = green->getValue ();
|
||||
|
||||
@@ -435,10 +439,19 @@ void WhiteBalance::setDefaults (const ProcParams* defParams, const ParamsEdited*
|
||||
green->setDefault (green->getAddMode() ? 0 : cgreen);
|
||||
}
|
||||
else if (wbp && defParams->wb.method == "Auto") {
|
||||
// this setDefaults method is called too early ; the wbp has been set,
|
||||
// but wbp is not ready to provide!
|
||||
double ctemp; double cgreen;
|
||||
wbp->getAutoWB (ctemp, cgreen);
|
||||
temp->setDefault (temp->getAddMode() ? 0 : (int)ctemp);
|
||||
green->setDefault (green->getAddMode() ? 0 : cgreen);
|
||||
if (ctemp != -1.0) {
|
||||
temp->setDefault (temp->getAddMode() ? 0 : (int)ctemp);
|
||||
green->setDefault (green->getAddMode() ? 0 : cgreen);
|
||||
}
|
||||
else {
|
||||
// 6504 & 1.0 = same values as in ProcParams::setDefaults
|
||||
temp->setDefault (temp->getAddMode() ? 0 : 6504);
|
||||
green->setDefault (green->getAddMode() ? 0 : 1.0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
temp->setDefault (defParams->wb.temperature);
|
||||
|
Reference in New Issue
Block a user