Dehaze with Rawprocess
This commit is contained in:
parent
b941188ac8
commit
3bddbc8d6f
@ -642,6 +642,8 @@ HISTORY_MSG_409;Dehaze gain
|
||||
HISTORY_MSG_410;Dehaze offset
|
||||
HISTORY_MSG_411;Dehaze strength
|
||||
HISTORY_MSG_412;Dehaze scales
|
||||
HISTORY_MSG_413;Dehaze var
|
||||
HISTORY_MSG_414;Dehaze histogram
|
||||
HISTORY_NEWSNAPSHOT;Add
|
||||
HISTORY_NEWSNAPSHOT_TOOLTIP;Shortcut: <b>Alt-s</b>
|
||||
HISTORY_SNAPSHOTS;Snapshots
|
||||
@ -1511,6 +1513,7 @@ TP_LABCURVE_BRIGHTNESS;Lightness
|
||||
TP_LABCURVE_CHROMATICITY;Chromaticity
|
||||
TP_LABCURVE_CHROMA_TOOLTIP;To apply B&W toning, set Chromaticity to -100.
|
||||
TP_LABCURVE_CONTRAST;Contrast
|
||||
TP_LABCURVE_CONTEDIT;Histogram equalizer
|
||||
TP_LABCURVE_CURVEEDITOR;Luminance Curve
|
||||
TP_LABCURVE_CURVEEDITOR_A_RANGE1;Green Saturated
|
||||
TP_LABCURVE_CURVEEDITOR_A_RANGE2;Green Pastel
|
||||
@ -1526,6 +1529,8 @@ TP_LABCURVE_CURVEEDITOR_CC_RANGE2;Dull
|
||||
TP_LABCURVE_CURVEEDITOR_CC_RANGE3;Pastel
|
||||
TP_LABCURVE_CURVEEDITOR_CC_RANGE4;Saturated
|
||||
TP_LABCURVE_CURVEEDITOR_CC_TOOLTIP;Chromaticity according to chromaticity C=f(C)
|
||||
TP_LABCURVE_CURVEEDITOR_CD;CL
|
||||
TP_LABCURVE_CURVEEDITOR_CD_TOOLTIP;Luminance according to luminance L=f(L)
|
||||
TP_LABCURVE_CURVEEDITOR_CH;CH
|
||||
TP_LABCURVE_CURVEEDITOR_CH_TOOLTIP;Chromaticity according to hue C=f(H)
|
||||
TP_LABCURVE_CURVEEDITOR_CL;CL
|
||||
@ -1549,6 +1554,7 @@ TP_LABCURVE_GAIN;Gain
|
||||
TP_LABCURVE_OFFS;Offset
|
||||
TP_DEHAZE_LAB;Dehaze
|
||||
TP_DEHAZE_LAB_TOOLTIP;Use Retinex algorithm (Lab) to improve dehaze..defog...
|
||||
TP_LABCURVE_VART;Variance
|
||||
TP_DEHAZE_MET;Dehaze method
|
||||
TP_DEHAZ_NONE;None
|
||||
TP_DEHAZ_UNI;Uniform
|
||||
|
@ -502,6 +502,40 @@ void CurveFactory::curveCL ( bool & clcutili, const std::vector<double>& clcurve
|
||||
dCurve = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CurveFactory::curveDehaContL ( bool & dehacontlutili, const std::vector<double>& dehaclcurvePoints, LUTf & dehaclCurve, int skip)
|
||||
{
|
||||
bool needed;
|
||||
DiagonalCurve* dCurve = NULL;
|
||||
|
||||
bool histNeededCL = false;
|
||||
|
||||
needed = false;
|
||||
|
||||
if (!dehaclcurvePoints.empty() && dehaclcurvePoints[0] != 0) {
|
||||
dCurve = new DiagonalCurve (dehaclcurvePoints, CURVES_MIN_POLY_POINTS / skip);
|
||||
|
||||
if (dCurve && !dCurve->isIdentity()) {
|
||||
needed = true;
|
||||
dehacontlutili = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 32768; i++) { //32768*1.414 + ...
|
||||
int hi = (int)(255.0 * CLIPD((float)i / 32767.0)); //
|
||||
}
|
||||
|
||||
|
||||
fillCurveArray(dCurve, dehaclCurve, skip, needed);
|
||||
|
||||
if (dCurve) {
|
||||
delete dCurve;
|
||||
dCurve = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// add curve Lab wavelet : Cont=f(L)
|
||||
void CurveFactory::curveWavContL ( bool & wavcontlutili, const std::vector<double>& wavclcurvePoints, LUTf & wavclCurve, /*LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip)
|
||||
{
|
||||
|
@ -282,6 +282,7 @@ public:
|
||||
static void curveCL ( bool & clcutili, const std::vector<double>& clcurvePoints, LUTf & clCurve, LUTu & histogramcl, LUTu & outBeforeCLurveHistogram, int skip);
|
||||
|
||||
static void curveWavContL ( bool & wavcontlutili, const std::vector<double>& wavclcurvePoints, LUTf & wavclCurve,/* LUTu & histogramwavcl, LUTu & outBeforeWavCLurveHistogram,*/int skip);
|
||||
static void curveDehaContL ( bool & dehacontlutili, const std::vector<double>& dehaclcurvePoints, LUTf & dehaclCurve, int skip);
|
||||
|
||||
static void curveToningCL ( bool & clctoningutili, const std::vector<double>& clcurvePoints, LUTf & clToningCurve, int skip);
|
||||
static void curveToningLL ( bool & llctoningutili, const std::vector<double>& llcurvePoints, LUTf & llToningCurve, int skip);
|
||||
|
@ -808,7 +808,7 @@ void Crop::update (int todo)
|
||||
|
||||
LUTu dummy;
|
||||
int modedehaz;
|
||||
parent->ipf.MSR(labnCrop, labnCrop->W, labnCrop->H, 1);
|
||||
// parent->ipf.MSR(labnCrop, labnCrop->W, labnCrop->H, 1);
|
||||
parent->ipf.chromiLuminanceCurve (this, 1, labnCrop, labnCrop, parent->chroma_acurve, parent->chroma_bcurve, parent->satcurve, parent->lhskcurve, parent->clcurve, parent->lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy, dummy, dummy);
|
||||
parent->ipf.vibrance (labnCrop);
|
||||
|
||||
|
@ -69,12 +69,15 @@ public:
|
||||
virtual int load (Glib::ustring fname, bool batch = false) = 0;
|
||||
virtual void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse) {};
|
||||
virtual void demosaic (const RAWParams &raw) {};
|
||||
virtual void dehaz (RAWParams raw, ColorManagementParams cmp, LCurveParams lcur, LUTf & cdcurve, bool dehacontlutili) {};
|
||||
virtual void flushRawData () {};
|
||||
virtual void flushRGB () {};
|
||||
virtual void HLRecovery_Global (ToneCurveParams hrp) {};
|
||||
virtual void HLRecovery_inpaint (float** red, float** green, float** blue) {};
|
||||
virtual void MSR(LabImage* lab, int width, int height, int skip, LCurveParams lcur) {};
|
||||
|
||||
virtual bool IsrgbSourceModified() = 0; // tracks whether cached rgb output of demosaic has been modified
|
||||
// virtual void MSR(LabImage* lab, int width, int height, int skip, const LCurveParams &lcur);
|
||||
|
||||
// use right after demosaicing image, add coarse transformation and put the result in the provided Imagefloat*
|
||||
virtual void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, ToneCurveParams hlp, ColorManagementParams cmp, RAWParams raw) {}
|
||||
|
@ -46,6 +46,7 @@ ImProcCoordinator::ImProcCoordinator ()
|
||||
satcurve(65536, 0),
|
||||
lhskcurve(65536, 0),
|
||||
clcurve(65536, 0),
|
||||
cdcurve(65536, 0),
|
||||
wavclCurve(65536, 0),
|
||||
clToningcurve(65536, 0),
|
||||
cl2Toningcurve(65536, 0),
|
||||
@ -163,7 +164,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
|
||||
}
|
||||
|
||||
RAWParams rp = params.raw;
|
||||
|
||||
ColorManagementParams cmp = params.icm;
|
||||
LCurveParams lcur = params.labCurve;
|
||||
if( !highDetailNeeded ) {
|
||||
// if below 100% magnification, take a fast path
|
||||
if(rp.bayersensor.method != RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::none] && rp.bayersensor.method != RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::mono]) {
|
||||
@ -219,7 +221,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
|
||||
}
|
||||
}
|
||||
|
||||
imgsrc->demosaic( rp );
|
||||
imgsrc->demosaic( rp);//enabled demosaic
|
||||
|
||||
|
||||
if (highDetailNeeded) {
|
||||
highDetailRawComputed = true;
|
||||
@ -231,7 +234,14 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
|
||||
highDetailRawComputed = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool dehacontlutili=false;
|
||||
CurveFactory::curveDehaContL (dehacontlutili, params.labCurve.cdcurve, cdcurve, 1);
|
||||
|
||||
if (todo & M_INIT || params.labCurve.dehazmet!="none"){
|
||||
if(params.labCurve.dehazmet!="none")
|
||||
imgsrc->dehaz( params.raw, params.icm, params.labCurve, cdcurve, dehacontlutili);//enabled Dehaze
|
||||
|
||||
}
|
||||
// Updating toneCurve.hrenabled if necessary
|
||||
// It has to be done there, because the next 'if' statement will use the value computed here
|
||||
if (todo & M_AUTOEXP) {
|
||||
@ -248,8 +258,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
|
||||
|
||||
if (todo & (M_INIT | M_LINDENOISE)) {
|
||||
MyMutex::MyLock initLock(minit); // Also used in crop window
|
||||
|
||||
imgsrc->HLRecovery_Global( params.toneCurve ); // this handles Color HLRecovery
|
||||
|
||||
imgsrc->HLRecovery_Global( params.toneCurve); // this handles Color HLRecovery
|
||||
|
||||
|
||||
if (settings->verbose) {
|
||||
printf ("Applying white balance, color correction & sRBG conversion...\n");
|
||||
@ -294,7 +305,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
|
||||
|
||||
imgsrc->getImage (currWB, tr, orig_prev, pp, params.toneCurve, params.icm, params.raw);
|
||||
//ColorTemp::CAT02 (orig_prev, ¶ms) ;
|
||||
|
||||
// printf("orig_prevW=%d\n scale=%d",orig_prev->width, scale);
|
||||
/* Issue 2785, disabled some 1:1 tools
|
||||
if (todo & M_LINDENOISE) {
|
||||
DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise;
|
||||
@ -576,7 +587,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
|
||||
nprevl->CopyFrom(oprevl);
|
||||
|
||||
progress ("Applying Color Boost...", 100 * readyphase / numofphases);
|
||||
ipf.MSR(nprevl, nprevl->W, nprevl->H, 1);
|
||||
// ipf.MSR(nprevl, nprevl->W, nprevl->H, 1);
|
||||
|
||||
ipf.chromiLuminanceCurve (NULL, pW, nprevl, nprevl, chroma_acurve, chroma_bcurve, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, histCCurve, histCLurve, histLLCurve, histLCurve);
|
||||
ipf.vibrance(nprevl);
|
||||
|
@ -94,6 +94,7 @@ protected:
|
||||
LUTf satcurve;
|
||||
LUTf lhskcurve;
|
||||
LUTf clcurve;
|
||||
LUTf cdcurve;
|
||||
LUTf wavclCurve;
|
||||
LUTf clToningcurve;
|
||||
LUTf cl2Toningcurve;
|
||||
|
@ -306,7 +306,7 @@ public:
|
||||
//void RGB_OutputTransf(LabImage * src, Imagefloat * dst, const procparams::DirPyrDenoiseParams & dnparams);
|
||||
//void output_tile_row (float *Lbloxrow, float ** Lhipassdn, float ** tilemask, int height, int width, int top, int blkrad );
|
||||
|
||||
void MSR(LabImage* lab, int width, int height, int skip);
|
||||
// void MSR(LabImage* lab, int width, int height, int skip);
|
||||
|
||||
void Tile_calc (int tilesize, int overlap, int kall, int imwidth, int imheight, int &numtiles_W, int &numtiles_H, int &tilewidth, int &tileheight, int &tileWskip, int &tileHskip);
|
||||
void ip_wavelet(LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip);
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <string.h>
|
||||
#include "rtengine.h"
|
||||
#include "gauss.h"
|
||||
|
||||
#include "rawimagesource.h"
|
||||
#include "improcfun.h"
|
||||
#define MAX_DEHAZE_SCALES 6
|
||||
#define clipdehaz( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val )
|
||||
@ -100,25 +100,29 @@ void mean_stddv( float **dst, float &mean, float &stddv, int W_L, int H_L )
|
||||
|
||||
|
||||
|
||||
void ImProcFunctions::MSR(LabImage* lab, int width, int height, int skip)
|
||||
void RawImageSource::MSR(LabImage* lab, int width, int height, int skip, LCurveParams lcur)
|
||||
|
||||
{
|
||||
float pond;
|
||||
float mean, stddv;
|
||||
float mini, delta, maxi;
|
||||
float eps = 2.f;
|
||||
float gain = (float) params->labCurve.gain;//def =1 not use
|
||||
float offset = 1.f;
|
||||
float neg=(float) params->labCurve.offs;//def = 0 not use
|
||||
float strength = (float) params->labCurve.str;
|
||||
int scal = params->labCurve.scal;//def=3
|
||||
int nei = (int) 2.5f*params->labCurve.neigh;//def = 200
|
||||
int vart= params->labCurve.vart;
|
||||
float gain = (float) lcur.gain;//def =1 not use
|
||||
gain=1.f;
|
||||
float gain2 = (float) lcur.gain;//def =1 not use
|
||||
gain2/=100.f;
|
||||
float offset =(float) lcur.offs;//def = 0 not use
|
||||
offset = 0.f;
|
||||
float strength = (float) lcur.str;
|
||||
int scal = lcur.scal;//def=3
|
||||
int nei = (int) 2.5f*lcur.neigh;//def = 200
|
||||
float vart = (float)lcur.vart;//variance
|
||||
vart /=100.f;
|
||||
int modedehaz;
|
||||
if(params->labCurve.dehazmet=="none") modedehaz=-1;//enabled disabled
|
||||
if(params->labCurve.dehazmet=="uni") modedehaz=0;
|
||||
if(params->labCurve.dehazmet=="low") modedehaz=1;
|
||||
if(params->labCurve.dehazmet=="high") modedehaz=2;
|
||||
if(lcur.dehazmet=="none") modedehaz=-1;//enabled disabled
|
||||
if(lcur.dehazmet=="uni") modedehaz=0;
|
||||
if(lcur.dehazmet=="low") modedehaz=1;
|
||||
if(lcur.dehazmet=="high") modedehaz=2;
|
||||
if (modedehaz !=-1) {//enabled
|
||||
int H_L=height;
|
||||
int W_L=width;
|
||||
@ -171,9 +175,10 @@ void ImProcFunctions::MSR(LabImage* lab, int width, int height, int skip)
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
AlignedBufferMP<double> buffer(max(W_L,H_L));
|
||||
gaussHorizontal<float> (in, out, buffer, W_L, H_L, DehazeScales[scale]);
|
||||
gaussVertical<float> (out, out, buffer,W_L, H_L, DehazeScales[scale]);
|
||||
AlignedBufferMP<double>* pBuffer = new AlignedBufferMP<double> (max(W_L, H_L));
|
||||
gaussHorizontal<float> (in, out, *pBuffer, W_L, H_L, DehazeScales[scale]);
|
||||
gaussVertical<float> (out, out, *pBuffer,W_L, H_L, DehazeScales[scale]);
|
||||
delete pBuffer;
|
||||
}
|
||||
for ( int i=0; i < H_L; i++)
|
||||
for (int j=0; j < W_L; j++)
|
||||
@ -210,13 +215,10 @@ float beta=16384.0f;
|
||||
|
||||
mean=0.f;stddv=0.f;
|
||||
mean_stddv( dst, mean, stddv, W_L, H_L);
|
||||
float nstdv=1.25f;
|
||||
|
||||
mini = mean - 1.2f*stddv;
|
||||
maxi = mean + 1.2f*stddv;
|
||||
// mini = neg;
|
||||
mini = mean - vart*stddv;
|
||||
maxi = mean + vart*stddv;
|
||||
delta = maxi - mini;
|
||||
// delta = vart;
|
||||
printf("maxi=%f mini=%f mean=%f std=%f delta=%f\n", maxi, mini, mean, stddv, delta);
|
||||
|
||||
if ( !delta ) delta = 1.0f;
|
||||
@ -225,7 +227,7 @@ float beta=16384.0f;
|
||||
#endif
|
||||
for ( int i=0; i < H_L; i ++ )
|
||||
for (int j=0; j< W_L; j++) {
|
||||
float cd = vart*32768.f * ( dst[i][j] - mini ) / delta;
|
||||
float cd = gain2*32768.f * ( dst[i][j] - mini ) / delta;
|
||||
src[i][j] = clipdehaz( cd, 0.f, 32768.f );
|
||||
lab->L[i][j]=((100.f - strength)* lab->L[i][j] + strength * src[i][j])/100.f;
|
||||
}
|
||||
|
@ -121,6 +121,9 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext
|
||||
rtengine::Image8 *output = NULL;
|
||||
const unsigned char *data = NULL;
|
||||
int fw, fh;
|
||||
LUTf cdcurve;
|
||||
bool dehacontlutili=false;
|
||||
|
||||
procparams::ProcParams params;
|
||||
/*rtengine::RAWParams raw;
|
||||
rtengine::LensProfParams lensProf;
|
||||
@ -137,6 +140,7 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext
|
||||
params.raw.xtranssensor.method = RAWParams::XTransSensor::methodstring[RAWParams::XTransSensor::fast];
|
||||
rawImage.preprocess(params.raw, params.lensProf, params.coarse);
|
||||
rawImage.demosaic(params.raw);
|
||||
// rawImage.dehaz(params.raw, params.icm, params.labCurve, cdcurve, dehacontlutili);
|
||||
Imagefloat* image = new rtengine::Imagefloat (fw, fh);
|
||||
rawImage.getImage (wb, TR_NONE, image, pp, params.toneCurve, params.icm, params.raw);
|
||||
output = new Image8(fw, fh);
|
||||
|
@ -439,7 +439,7 @@ enum ProcEvent {
|
||||
EvLstr = 410,
|
||||
EvLscal = 411,
|
||||
EvLvart = 412,
|
||||
|
||||
EvLCDCurve = 413,
|
||||
NUMOFEVENTS
|
||||
};
|
||||
}
|
||||
|
@ -882,12 +882,12 @@ void ProcParams::setDefaults ()
|
||||
labCurve.brightness = 0;
|
||||
labCurve.contrast = 0;
|
||||
labCurve.chromaticity = 0;
|
||||
labCurve.str = 70;
|
||||
labCurve.str = 60;
|
||||
labCurve.scal = 3;
|
||||
labCurve.neigh = 80;
|
||||
labCurve.gain = 1;
|
||||
labCurve.gain = 100;
|
||||
labCurve.offs = 0;
|
||||
labCurve.vart = 1;
|
||||
labCurve.vart = 125;
|
||||
labCurve.avoidcolorshift = false;
|
||||
labCurve.lcredsk = true;
|
||||
labCurve.rstprotection = 0;
|
||||
@ -911,6 +911,8 @@ void ProcParams::setDefaults ()
|
||||
labCurve.lccurve.push_back(DCT_Linear);
|
||||
labCurve.clcurve.clear ();
|
||||
labCurve.clcurve.push_back(DCT_Linear);
|
||||
labCurve.cdcurve.clear ();
|
||||
labCurve.cdcurve.push_back(DCT_Linear);
|
||||
|
||||
rgbCurves.lumamode = false;
|
||||
rgbCurves.rcurve.clear ();
|
||||
@ -1624,6 +1626,11 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol
|
||||
keyFile.set_double_list("Luminance Curve", "ClCurve", clcurve);
|
||||
}
|
||||
|
||||
if (!pedited || pedited->labCurve.cdcurve) {
|
||||
Glib::ArrayHandle<double> cdcurve = labCurve.cdcurve;
|
||||
keyFile.set_double_list("Luminance Curve", "CDCurve", cdcurve);
|
||||
}
|
||||
|
||||
// save sharpening
|
||||
if (!pedited || pedited->sharpening.enabled) {
|
||||
keyFile.set_boolean ("Sharpening", "Enabled", sharpening.enabled);
|
||||
@ -3872,6 +3879,14 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
|
||||
}
|
||||
}
|
||||
|
||||
if (keyFile.has_key ("Luminance Curve", "CDCurve")) {
|
||||
labCurve.cdcurve = keyFile.get_double_list ("Luminance Curve", "CDCurve");
|
||||
|
||||
if (pedited) {
|
||||
pedited->labCurve.cdcurve = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// load sharpening
|
||||
@ -7083,6 +7098,7 @@ bool ProcParams::operator== (const ProcParams& other)
|
||||
&& labCurve.hhcurve == other.labCurve.hhcurve
|
||||
&& labCurve.lccurve == other.labCurve.lccurve
|
||||
&& labCurve.clcurve == other.labCurve.clcurve
|
||||
&& labCurve.cdcurve == other.labCurve.cdcurve
|
||||
&& labCurve.str == other.labCurve.str
|
||||
&& labCurve.scal == other.labCurve.scal
|
||||
&& labCurve.neigh == other.labCurve.neigh
|
||||
|
@ -277,6 +277,7 @@ public:
|
||||
std::vector<double> hhcurve;
|
||||
std::vector<double> lccurve;
|
||||
std::vector<double> clcurve;
|
||||
std::vector<double> cdcurve;
|
||||
int brightness;
|
||||
int contrast;
|
||||
int chromaticity;
|
||||
|
@ -1734,7 +1734,6 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void RawImageSource::demosaic(const RAWParams &raw)
|
||||
@ -1787,8 +1786,10 @@ void RawImageSource::demosaic(const RAWParams &raw)
|
||||
}
|
||||
|
||||
t2.set();
|
||||
|
||||
|
||||
rgbSourceModified = false;
|
||||
|
||||
|
||||
if( settings->verbose ) {
|
||||
if (getSensorType() == ST_BAYER) {
|
||||
@ -1797,9 +1798,83 @@ void RawImageSource::demosaic(const RAWParams &raw)
|
||||
printf("Demosaicing X-Trans data: %s - %d usec\n", raw.xtranssensor.method.c_str(), t2.etime(t1));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RawImageSource::dehaz(RAWParams raw, ColorManagementParams cmp, LCurveParams lcur, LUTf & cdcurve, bool dehacontlutili)
|
||||
{
|
||||
|
||||
MyTime t4, t5;
|
||||
t4.set();
|
||||
if(!rgbSourceModified) {
|
||||
if (settings->verbose) {
|
||||
printf ("Applying DeHaze\n");
|
||||
}
|
||||
|
||||
TMatrix wprof = iccStore->workingSpaceMatrix (cmp.working);
|
||||
TMatrix wiprof = iccStore->workingSpaceInverseMatrix (cmp.working);
|
||||
|
||||
double wip[3][3] = {
|
||||
{wiprof[0][0], wiprof[0][1], wiprof[0][2]},
|
||||
{wiprof[1][0], wiprof[1][1], wiprof[1][2]},
|
||||
{wiprof[2][0], wiprof[2][1], wiprof[2][2]}
|
||||
};
|
||||
|
||||
double wp[3][3] = {
|
||||
{wprof[0][0], wprof[0][1], wprof[0][2]},
|
||||
{wprof[1][0], wprof[1][1], wprof[1][2]},
|
||||
{wprof[2][0], wprof[2][1], wprof[2][2]}
|
||||
};
|
||||
LabImage * labdeha = new LabImage(W, H);
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i <H; i++ )
|
||||
for (int j=0; j<W; j++) {
|
||||
float X, Y, Z, L, aa, bb;
|
||||
//rgb=>lab
|
||||
Color::rgbxyz(red[i][j], green[i][j], blue[i][j], X, Y, Z, wp);
|
||||
//convert Lab
|
||||
Color::XYZ2Lab(X, Y, Z, L, aa, bb);
|
||||
labdeha->L[i][j]=L;
|
||||
// if(lcur.dehazmet !="none") {
|
||||
if(dehacontlutili) labdeha->L[i][j]=cdcurve[L];//apply curve to equalize histogram
|
||||
// }
|
||||
labdeha->a[i][j]=aa;
|
||||
labdeha->b[i][j]=bb;
|
||||
|
||||
}
|
||||
|
||||
MSR(labdeha, W, H, 1, lcur);
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i <H; i++ )
|
||||
for (int j=0; j<W; j++) {
|
||||
float L2,a2,b2,x_,y_,z_;
|
||||
float R,G,B;
|
||||
L2=labdeha->L[i][j];
|
||||
a2=labdeha->a[i][j];
|
||||
b2=labdeha->b[i][j];
|
||||
Color::Lab2XYZ(L2, a2, b2, x_, y_, z_) ;
|
||||
Color::xyz2rgb(x_, y_, z_, R, G, B, wip);
|
||||
red[i][j]=R;
|
||||
green[i][j]=G;
|
||||
blue[i][j]=B;
|
||||
}
|
||||
|
||||
delete labdeha;
|
||||
|
||||
t5.set();
|
||||
|
||||
|
||||
|
||||
if( settings->verbose ) {
|
||||
printf("Dehaz=%d usec\n", t5.etime(t4));
|
||||
|
||||
}
|
||||
rgbSourceModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RawImageSource::flushRawData()
|
||||
{
|
||||
if(cache) {
|
||||
@ -1827,18 +1902,18 @@ void RawImageSource::flushRGB()
|
||||
}
|
||||
}
|
||||
|
||||
void RawImageSource::HLRecovery_Global(ToneCurveParams hrp )
|
||||
void RawImageSource::HLRecovery_Global(ToneCurveParams hrp)
|
||||
{
|
||||
if (hrp.hrenabled && hrp.method == "Color") {
|
||||
if(!rgbSourceModified) {
|
||||
if (settings->verbose) {
|
||||
printf ("Applying Highlight Recovery: Color propagation...\n");
|
||||
}
|
||||
|
||||
HLRecovery_inpaint (red, green, blue);
|
||||
rgbSourceModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,6 +151,7 @@ public:
|
||||
int load (Glib::ustring fname, bool batch = false);
|
||||
void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse);
|
||||
void demosaic (const RAWParams &raw);
|
||||
void dehaz (RAWParams raw, ColorManagementParams cmp, LCurveParams lcur, LUTf & cdcurve, bool dehacontlutili);
|
||||
void flushRawData ();
|
||||
void flushRGB ();
|
||||
void HLRecovery_Global (ToneCurveParams hrp);
|
||||
@ -226,6 +227,7 @@ public:
|
||||
|
||||
void boxblur2(float** src, float** dst, int H, int W, int box );
|
||||
void boxblur_resamp(float **src, float **dst, int H, int W, int box, int samp );
|
||||
void MSR(LabImage* lab, int width, int height, int skip, LCurveParams lcur);
|
||||
|
||||
//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 );
|
||||
@ -271,6 +273,7 @@ protected:
|
||||
void jdl_interpolate_omp();
|
||||
void igv_interpolate(int winw, int winh);
|
||||
void lmmse_interpolate_omp(int winw, int winh, int iterations);
|
||||
// void MSR(LabImage* lab, int width, int height, int skip, const LCurveParams &lcur);
|
||||
|
||||
void amaze_demosaic_RT(int winx, int winy, int winw, int winh);//Emil's code for AMaZE
|
||||
void fast_demosaic(int winx, int winy, int winw, int winh );//Emil's code for fast demosaicing
|
||||
|
@ -428,13 +428,14 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
|
||||
DIRPYREQUALIZER, // EvWavedgeampli
|
||||
DIRPYREQUALIZER, //EvWavlev3nois
|
||||
DIRPYREQUALIZER, //EvWavNPmet
|
||||
LUMINANCECURVE, // Evdehazmet
|
||||
LUMINANCECURVE, // EvLneigh
|
||||
LUMINANCECURVE, // EvLgain
|
||||
LUMINANCECURVE, // EvLoffs
|
||||
LUMINANCECURVE, // EvLstr
|
||||
LUMINANCECURVE, // EvLscal
|
||||
LUMINANCECURVE // EvLvart
|
||||
ALLNORAW, // Evdehazmet
|
||||
ALLNORAW, // EvLneigh
|
||||
ALLNORAW, // EvLgain
|
||||
ALLNORAW, // EvLoffs
|
||||
ALLNORAW, // EvLstr
|
||||
ALLNORAW, // EvLscal
|
||||
ALLNORAW, // EvLvart
|
||||
ALLNORAW // EvLCDCurve
|
||||
|
||||
|
||||
};
|
||||
|
@ -115,13 +115,25 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
if (pl) {
|
||||
pl->setProgress (0.30);
|
||||
}
|
||||
LUTf cdcurve (65536, 0);
|
||||
|
||||
bool dehacontlutili=false;
|
||||
CurveFactory::curveDehaContL (dehacontlutili, params.labCurve.cdcurve, cdcurve, 1);
|
||||
|
||||
if(params.labCurve.dehazmet!="none")
|
||||
imgsrc->dehaz( params.raw, params.icm, params.labCurve, cdcurve, dehacontlutili );//enabled Dehaze
|
||||
|
||||
imgsrc->HLRecovery_Global( params.toneCurve );
|
||||
|
||||
if (pl) {
|
||||
pl->setProgress (0.40);
|
||||
}
|
||||
imgsrc->HLRecovery_Global( params.toneCurve );
|
||||
|
||||
|
||||
if (pl) {
|
||||
pl->setProgress (0.45);
|
||||
}
|
||||
|
||||
// set the color temperature
|
||||
ColorTemp currWB = ColorTemp (params.wb.temperature, params.wb.green, params.wb.equal, params.wb.method);
|
||||
|
||||
@ -610,7 +622,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
imgsrc->getImage (currWB, tr, baseImg, pp, params.toneCurve, params.icm, params.raw);
|
||||
|
||||
if (pl) {
|
||||
pl->setProgress (0.45);
|
||||
pl->setProgress (0.50);
|
||||
}
|
||||
|
||||
// LUTf Noisecurve (65536,0);
|
||||
@ -847,7 +859,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
shmap = NULL;
|
||||
|
||||
if (pl) {
|
||||
pl->setProgress (0.5);
|
||||
pl->setProgress (0.55);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
@ -901,7 +913,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
||||
params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve, params.labCurve.lccurve, curve1, curve2, satcurve, lhskcurve,
|
||||
hist16C, hist16C, dummy, dummy,
|
||||
1);
|
||||
ipf.MSR(labView, labView->W, labView->H, 1);
|
||||
// ipf.MSR(labView, labView->W, labView->H, 1);
|
||||
|
||||
ipf.chromiLuminanceCurve (NULL, 1, labView, labView, curve1, curve2, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy, dummy, dummy);
|
||||
|
||||
|
@ -233,29 +233,46 @@ LCurve::LCurve () : FoldableToolPanel(this, "labcurves", M("TP_LABCURVE_LABEL"))
|
||||
// dehazmet->set_tooltip_markup (M("TP_DEHAZ_MET_TOOLTIP"));
|
||||
dhbox->pack_start(*dehazmet);
|
||||
dehazVBox->pack_start(*dhbox);
|
||||
|
||||
curveEditorGD = new CurveEditorGroup (options.lastLabCurvesDir, M("TP_LABCURVE_CONTEDIT"));
|
||||
curveEditorGD->setCurveListener (this);
|
||||
cdshape = static_cast<DiagonalCurveEditor*>(curveEditorGD->addCurve(CT_Diagonal, M("TP_LABCURVE_CURVEEDITOR_CD")));
|
||||
cdshape->setTooltip(M("TP_LABCURVE_CURVEEDITOR_CD_TOOLTIP"));
|
||||
std::vector<GradientMilestone> milestones22;
|
||||
|
||||
str = Gtk::manage (new Adjuster (M("TP_LABCURVE_STR"), 0, 100., 1., 70.));
|
||||
milestones22.push_back( GradientMilestone(0., 0., 0., 0.) );
|
||||
milestones22.push_back( GradientMilestone(1., 1., 1., 1.) );
|
||||
cdshape->setBottomBarBgGradient(milestones22);
|
||||
cdshape->setLeftBarBgGradient(milestones22);
|
||||
|
||||
curveEditorGD->curveListComplete();
|
||||
|
||||
str = Gtk::manage (new Adjuster (M("TP_LABCURVE_STR"), 0, 100., 1., 60.));
|
||||
scal = Gtk::manage (new Adjuster (M("TP_LABCURVE_SCAL"), 1, 6., 1., 3.));
|
||||
neigh = Gtk::manage (new Adjuster (M("TP_LABCURVE_NEIGH"), 6, 100., 1., 80.));
|
||||
gain = Gtk::manage (new Adjuster (M("TP_LABCURVE_GAIN"), 0.8, 1.4, 0.01, 1.));
|
||||
offs = Gtk::manage (new Adjuster (M("TP_LABCURVE_OFFS"), -10, 5, 0.1, 0));
|
||||
vart = Gtk::manage (new Adjuster (M("TP_LABCURVE_VART"), 0.5, 15., 0.01, 1));
|
||||
gain = Gtk::manage (new Adjuster (M("TP_LABCURVE_GAIN"), 70, 130, 1, 100));
|
||||
offs = Gtk::manage (new Adjuster (M("TP_LABCURVE_OFFS"), 0, 40, 0.1, 0));
|
||||
vart = Gtk::manage (new Adjuster (M("TP_LABCURVE_VART"), 100, 160, 1, 125));
|
||||
dehazVBox->pack_start (*str);
|
||||
str->show ();
|
||||
|
||||
|
||||
dehazVBox->pack_start (*curveEditorGD, Gtk::PACK_SHRINK, 4);
|
||||
curveEditorGD->show();
|
||||
|
||||
dehazVBox->pack_start (*scal);
|
||||
scal->show ();
|
||||
|
||||
dehazVBox->pack_start (*neigh);
|
||||
neigh->show ();
|
||||
|
||||
// dehazVBox->pack_start (*gain);
|
||||
// gain->show ();
|
||||
dehazVBox->pack_start (*gain);
|
||||
gain->show ();
|
||||
|
||||
// dehazVBox->pack_start (*offs);
|
||||
// offs->show ();
|
||||
// dehazVBox->pack_start (*vart);
|
||||
// vart->show ();
|
||||
// offs->show ();
|
||||
|
||||
dehazVBox->pack_start (*vart);
|
||||
vart->show ();
|
||||
|
||||
str->setAdjusterListener (this);
|
||||
scal->setAdjusterListener (this);
|
||||
@ -271,6 +288,8 @@ LCurve::LCurve () : FoldableToolPanel(this, "labcurves", M("TP_LABCURVE_LABEL"))
|
||||
LCurve::~LCurve ()
|
||||
{
|
||||
delete curveEditorG;
|
||||
delete curveEditorGD;
|
||||
|
||||
}
|
||||
|
||||
void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited)
|
||||
@ -313,6 +332,7 @@ void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited)
|
||||
hhshape->setUnChanged (!pedited->labCurve.hhcurve);
|
||||
lcshape->setUnChanged (!pedited->labCurve.lccurve);
|
||||
clshape->setUnChanged (!pedited->labCurve.clcurve);
|
||||
cdshape->setUnChanged (!pedited->labCurve.cdcurve);
|
||||
}
|
||||
|
||||
brightness->setValue (pp->labCurve.brightness);
|
||||
@ -364,6 +384,7 @@ void LCurve::read (const ProcParams* pp, const ParamsEdited* pedited)
|
||||
hhshape->setCurve (pp->labCurve.hhcurve);
|
||||
lcshape->setCurve (pp->labCurve.lccurve);
|
||||
clshape->setCurve (pp->labCurve.clcurve);
|
||||
cdshape->setCurve (pp->labCurve.cdcurve);
|
||||
|
||||
queue_draw();
|
||||
dehazmetConn.block(false);
|
||||
@ -407,6 +428,10 @@ void LCurve::autoOpenCurve ()
|
||||
if (!active) {
|
||||
clshape->openIfNonlinear();
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
cdshape->openIfNonlinear();
|
||||
}
|
||||
}
|
||||
|
||||
void LCurve::setEditProvider (EditDataProvider *provider)
|
||||
@ -415,6 +440,7 @@ void LCurve::setEditProvider (EditDataProvider *provider)
|
||||
ccshape->setEditProvider(provider);
|
||||
lcshape->setEditProvider(provider);
|
||||
clshape->setEditProvider(provider);
|
||||
cdshape->setEditProvider(provider);
|
||||
lhshape->setEditProvider(provider);
|
||||
chshape->setEditProvider(provider);
|
||||
hhshape->setEditProvider(provider);
|
||||
@ -453,6 +479,7 @@ void LCurve::write (ProcParams* pp, ParamsEdited* pedited)
|
||||
pp->labCurve.hhcurve = hhshape->getCurve ();
|
||||
pp->labCurve.lccurve = lcshape->getCurve ();
|
||||
pp->labCurve.clcurve = clshape->getCurve ();
|
||||
pp->labCurve.cdcurve = cdshape->getCurve ();
|
||||
|
||||
if (pedited) {
|
||||
pedited->labCurve.brightness = brightness->getEditedState ();
|
||||
@ -485,6 +512,7 @@ void LCurve::write (ProcParams* pp, ParamsEdited* pedited)
|
||||
pedited->labCurve.hhcurve = !hhshape->isUnChanged ();
|
||||
pedited->labCurve.lccurve = !lcshape->isUnChanged ();
|
||||
pedited->labCurve.clcurve = !clshape->isUnChanged ();
|
||||
pedited->labCurve.cdcurve = !cdshape->isUnChanged ();
|
||||
|
||||
|
||||
}
|
||||
@ -650,6 +678,11 @@ void LCurve::curveChanged (CurveEditor* ce)
|
||||
if (ce == clshape) {
|
||||
listener->panelChanged (EvLCLCurve, M("HISTORY_CUSTOMCURVE"));
|
||||
}
|
||||
|
||||
if (ce == cdshape) {
|
||||
listener->panelChanged (EvLCDCurve, M("HISTORY_CUSTOMCURVE"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -796,6 +829,7 @@ void LCurve::setBatchMode (bool batchMode)
|
||||
str->showEditedCB ();
|
||||
scal->showEditedCB ();
|
||||
vart->showEditedCB ();
|
||||
curveEditorGD->setBatchMode (batchMode);
|
||||
|
||||
curveEditorG->setBatchMode (batchMode);
|
||||
lcshape->setBottomBarColorProvider(NULL, -1);
|
||||
|
@ -31,6 +31,7 @@ class LCurve : public ToolParamBlock, public AdjusterListener, public FoldableTo
|
||||
|
||||
protected:
|
||||
CurveEditorGroup* curveEditorG;
|
||||
CurveEditorGroup* curveEditorGD;
|
||||
Adjuster* brightness;
|
||||
Adjuster* contrast;
|
||||
Adjuster* chromaticity;
|
||||
@ -54,6 +55,7 @@ protected:
|
||||
MyComboBoxText* dehazmet;
|
||||
|
||||
DiagonalCurveEditor* clshape;
|
||||
DiagonalCurveEditor* cdshape;
|
||||
|
||||
//%%%%%%%%%%%%%%%%
|
||||
Gtk::CheckButton* avoidcolorshift;
|
||||
|
@ -58,6 +58,7 @@ void ParamsEdited::set (bool v)
|
||||
labCurve.hhcurve = v;
|
||||
labCurve.lccurve = v;
|
||||
labCurve.clcurve = v;
|
||||
labCurve.cdcurve = v;
|
||||
labCurve.dehazmet = v;
|
||||
labCurve.str = v;
|
||||
labCurve.scal = v;
|
||||
@ -520,6 +521,7 @@ void ParamsEdited::initFrom (const std::vector<rtengine::procparams::ProcParams>
|
||||
labCurve.hhcurve = labCurve.hhcurve && p.labCurve.hhcurve == other.labCurve.hhcurve;
|
||||
labCurve.lccurve = labCurve.lccurve && p.labCurve.lccurve == other.labCurve.lccurve;
|
||||
labCurve.clcurve = labCurve.clcurve && p.labCurve.clcurve == other.labCurve.clcurve;
|
||||
labCurve.cdcurve = labCurve.cdcurve && p.labCurve.cdcurve == other.labCurve.cdcurve;
|
||||
labCurve.dehazmet = labCurve.dehazmet && p.labCurve.dehazmet == other.labCurve.dehazmet;
|
||||
labCurve.str = labCurve.str && p.labCurve.str == other.labCurve.str;
|
||||
labCurve.scal = labCurve.scal && p.labCurve.scal == other.labCurve.scal;
|
||||
@ -1046,6 +1048,9 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
|
||||
if (labCurve.clcurve) {
|
||||
toEdit.labCurve.clcurve = mods.labCurve.clcurve;
|
||||
}
|
||||
if (labCurve.cdcurve) {
|
||||
toEdit.labCurve.cdcurve = mods.labCurve.cdcurve;
|
||||
}
|
||||
|
||||
if (labCurve.brightness) {
|
||||
toEdit.labCurve.brightness = dontforceSet && options.baBehav[ADDSET_LC_BRIGHTNESS] ? toEdit.labCurve.brightness + mods.labCurve.brightness : mods.labCurve.brightness;
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
bool hhcurve;
|
||||
bool lccurve;
|
||||
bool clcurve;
|
||||
bool cdcurve;
|
||||
|
||||
bool enabled;
|
||||
bool method;
|
||||
|
Loading…
x
Reference in New Issue
Block a user