HLRecovery preview speedup: decoupling from demosaic (see issue 1038)
This commit is contained in:
@@ -68,9 +68,12 @@ class ImageSource : public InitialImage {
|
|||||||
|
|
||||||
virtual ~ImageSource () {}
|
virtual ~ImageSource () {}
|
||||||
virtual int load (Glib::ustring fname, bool batch = false) =0;
|
virtual int load (Glib::ustring fname, bool batch = false) =0;
|
||||||
virtual void preprocess (const RAWParams &raw, HRecParams hrp){};
|
virtual void preprocess (const RAWParams &raw){};
|
||||||
virtual void demosaic (const RAWParams &raw, HRecParams hrp){};
|
virtual void demosaic (const RAWParams &raw){};
|
||||||
virtual void HLRecovery_inpaint (float** red, float** green, float** blue){};
|
virtual void HLRecovery_Global (HRecParams hrp){};
|
||||||
|
virtual void HLRecovery_inpaint (float** red, float** green, float** blue){};
|
||||||
|
|
||||||
|
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 void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, HRecParams hlp, ColorManagementParams cmp, RAWParams raw) {}
|
||||||
virtual ColorTemp getWB () =0;
|
virtual ColorTemp getWB () =0;
|
||||||
|
|||||||
@@ -117,14 +117,28 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
|
|||||||
|
|
||||||
progress ("Applying white balance, color correction & sRBG conversion...",100*readyphase/numofphases);
|
progress ("Applying white balance, color correction & sRBG conversion...",100*readyphase/numofphases);
|
||||||
if ( todo & M_PREPROC) {
|
if ( todo & M_PREPROC) {
|
||||||
imgsrc->preprocess( rp, params.hlrecovery );
|
imgsrc->preprocess( rp );
|
||||||
imgsrc->getRAWHistogram( histRedRaw, histGreenRaw, histBlueRaw );
|
imgsrc->getRAWHistogram( histRedRaw, histGreenRaw, histBlueRaw );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Demosaic is kicked off only when
|
||||||
|
Detail considerations:
|
||||||
|
accurate detail is not displayed yet needed based on preview specifics (driven via highDetailNeeded flag)
|
||||||
|
OR
|
||||||
|
HLR considerations:
|
||||||
|
Color HLR alters rgb output of demosaic, so re-demosaic is needed when Color HLR is being turned off;
|
||||||
|
if HLR is enabled and changing method *from* Color to any other method
|
||||||
|
OR HLR gets disabled when Color method was selected
|
||||||
|
*/
|
||||||
// If high detail (=100%) is newly selected, do a demosaic update, since the last was just with FAST
|
// If high detail (=100%) is newly selected, do a demosaic update, since the last was just with FAST
|
||||||
if ((todo & M_RAW) || (!lastHighDetail && highDetailNeeded)) {
|
if ((todo & M_RAW)
|
||||||
if (settings->verbose) printf("Demosaic %s\n",rp.dmethod.c_str());
|
|| (!lastHighDetail && highDetailNeeded)
|
||||||
imgsrc->demosaic( rp, params.hlrecovery );
|
|| (params.hlrecovery.enabled && params.hlrecovery.method!="Color" && imgsrc->IsrgbSourceModified())
|
||||||
|
|| (!params.hlrecovery.enabled && params.hlrecovery.method=="Color" && imgsrc->IsrgbSourceModified())){
|
||||||
|
|
||||||
|
if (settings->verbose) printf("Demosaic %s\n",rp.dmethod.c_str());
|
||||||
|
imgsrc->demosaic( rp );
|
||||||
}
|
}
|
||||||
lastHighDetail=highDetailNeeded;
|
lastHighDetail=highDetailNeeded;
|
||||||
|
|
||||||
@@ -132,6 +146,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
|
|||||||
if (todo & M_INIT) {
|
if (todo & M_INIT) {
|
||||||
Glib::Mutex::Lock lock(minit); // Also used in crop window
|
Glib::Mutex::Lock lock(minit); // Also used in crop window
|
||||||
|
|
||||||
|
imgsrc->HLRecovery_Global( params.hlrecovery ); // this handles Color HLRecovery
|
||||||
|
|
||||||
if (settings->verbose) printf ("Applying white balance, color correction & sRBG conversion...\n");
|
if (settings->verbose) printf ("Applying white balance, color correction & sRBG conversion...\n");
|
||||||
currWB = ColorTemp (params.wb.temperature, params.wb.green);
|
currWB = ColorTemp (params.wb.temperature, params.wb.green);
|
||||||
if (params.wb.method=="Camera")
|
if (params.wb.method=="Camera")
|
||||||
@@ -531,8 +547,8 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname) {
|
|||||||
ppar.icm.input = "(none)";
|
ppar.icm.input = "(none)";
|
||||||
Imagefloat* im = new Imagefloat (fW, fH);
|
Imagefloat* im = new Imagefloat (fW, fH);
|
||||||
Image16* im16 = new Image16 (fW, fH);
|
Image16* im16 = new Image16 (fW, fH);
|
||||||
imgsrc->preprocess( ppar.raw, ppar.hlrecovery );
|
imgsrc->preprocess( ppar.raw );
|
||||||
imgsrc->demosaic(ppar.raw, ppar.hlrecovery );
|
imgsrc->demosaic(ppar.raw );
|
||||||
//imgsrc->getImage (imgsrc->getWB(), 0, im, pp, ppar.hlrecovery, ppar.icm, ppar.raw);
|
//imgsrc->getImage (imgsrc->getWB(), 0, im, pp, ppar.hlrecovery, ppar.icm, ppar.raw);
|
||||||
ColorTemp currWB = ColorTemp (params.wb.temperature, params.wb.green);
|
ColorTemp currWB = ColorTemp (params.wb.temperature, params.wb.green);
|
||||||
if (params.wb.method=="Camera")
|
if (params.wb.method=="Camera")
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ RawImageSource::RawImageSource ()
|
|||||||
//hpmap = NULL;
|
//hpmap = NULL;
|
||||||
camProfile = NULL;
|
camProfile = NULL;
|
||||||
embProfile = NULL;
|
embProfile = NULL;
|
||||||
|
rgbSourceModified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
@@ -951,7 +952,7 @@ int RawImageSource::load (Glib::ustring fname, bool batch) {
|
|||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void RawImageSource::preprocess (const RAWParams &raw, HRecParams hrp)
|
void RawImageSource::preprocess (const RAWParams &raw)
|
||||||
{
|
{
|
||||||
MyTime t1,t2;
|
MyTime t1,t2;
|
||||||
t1.set();
|
t1.set();
|
||||||
@@ -1098,7 +1099,7 @@ void RawImageSource::preprocess (const RAWParams &raw, HRecParams hrp)
|
|||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void RawImageSource::demosaic(const RAWParams &raw, HRecParams hrp )
|
void RawImageSource::demosaic(const RAWParams &raw)
|
||||||
{
|
{
|
||||||
if (ri->isBayer()) {
|
if (ri->isBayer()) {
|
||||||
MyTime t1,t2;
|
MyTime t1,t2;
|
||||||
@@ -1125,14 +1126,25 @@ void RawImageSource::demosaic(const RAWParams &raw, HRecParams hrp )
|
|||||||
printf("Demosaicing: %s - %d usec\n",raw.dmethod.c_str(), t2.etime(t1));
|
printf("Demosaicing: %s - %d usec\n",raw.dmethod.c_str(), t2.etime(t1));
|
||||||
|
|
||||||
if (raw.all_enhance) refinement_lassus();
|
if (raw.all_enhance) refinement_lassus();
|
||||||
|
|
||||||
|
rgbSourceModified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//color propagation highlight recovery
|
|
||||||
if (hrp.enabled && hrp.method=="Color")
|
|
||||||
HLRecovery_inpaint (red,green,blue);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RawImageSource::HLRecovery_Global(HRecParams hrp )
|
||||||
|
{
|
||||||
|
//color propagation highlight recovery
|
||||||
|
if (hrp.enabled && hrp.method=="Color"){
|
||||||
|
if (settings->verbose) printf ("Applying Highlight Recovery: Color propagation...\n");
|
||||||
|
HLRecovery_inpaint (red,green,blue);
|
||||||
|
rgbSourceModified = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rgbSourceModified = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
/* Copy original pixel data and
|
/* Copy original pixel data and
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class RawImageSource : public ImageSource {
|
|||||||
bool full;
|
bool full;
|
||||||
cmsHPROFILE camProfile;
|
cmsHPROFILE camProfile;
|
||||||
cmsHPROFILE embProfile;
|
cmsHPROFILE embProfile;
|
||||||
|
bool rgbSourceModified;
|
||||||
|
|
||||||
RawImage* ri; // Copy of raw pixels, NOT corrected for initial gain, blackpoint etc.
|
RawImage* ri; // Copy of raw pixels, NOT corrected for initial gain, blackpoint etc.
|
||||||
|
|
||||||
@@ -131,10 +132,13 @@ class RawImageSource : public ImageSource {
|
|||||||
~RawImageSource ();
|
~RawImageSource ();
|
||||||
|
|
||||||
int load (Glib::ustring fname, bool batch = false);
|
int load (Glib::ustring fname, bool batch = false);
|
||||||
void preprocess (const RAWParams &raw, HRecParams hrp);
|
void preprocess (const RAWParams &raw);
|
||||||
void demosaic (const RAWParams &raw, HRecParams hrp);
|
void demosaic (const RAWParams &raw);
|
||||||
|
void HLRecovery_Global (HRecParams hrp);
|
||||||
void refinement_lassus ();
|
void refinement_lassus ();
|
||||||
|
|
||||||
|
bool IsrgbSourceModified() {return rgbSourceModified;} // tracks whether cached rgb output of demosaic has been modified
|
||||||
|
|
||||||
void copyOriginalPixels(const RAWParams &raw, RawImage *ri, RawImage *riDark, RawImage *riFlatFile );
|
void copyOriginalPixels(const RAWParams &raw, RawImage *ri, RawImage *riDark, RawImage *riFlatFile );
|
||||||
void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW );
|
void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW );
|
||||||
void scaleColors (int winx,int winy,int winw,int winh, const RAWParams &raw);// raw for cblack
|
void scaleColors (int winx,int winy,int winw,int winh, const RAWParams &raw);// raw for cblack
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ TRANSFORM, // EvDISTAmount,
|
|||||||
ALL, // EvBookmarkSelected,
|
ALL, // EvBookmarkSelected,
|
||||||
CROP, // EvCrop,
|
CROP, // EvCrop,
|
||||||
TRANSFORM, // EvCACorr,
|
TRANSFORM, // EvCACorr,
|
||||||
ALL, // EvHREnabled,
|
ALLNORAW, // EvHREnabled,
|
||||||
ALL, // EvHRAmount,
|
ALLNORAW, // EvHRAmount,
|
||||||
ALL, // EvHRMethod,
|
ALLNORAW, // EvHRMethod,
|
||||||
ALL, // EvWProfile,
|
ALL, // EvWProfile,
|
||||||
ALL, // EvOProfile,
|
ALL, // EvOProfile,
|
||||||
ALL, // EvIProfile,
|
ALL, // EvIProfile,
|
||||||
|
|||||||
@@ -98,10 +98,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
|
|||||||
currWB = imgsrc->getAutoWB ();
|
currWB = imgsrc->getAutoWB ();
|
||||||
|
|
||||||
PreviewProps pp (0, 0, fw, fh, 1);
|
PreviewProps pp (0, 0, fw, fh, 1);
|
||||||
imgsrc->preprocess( params.raw, params.hlrecovery );
|
imgsrc->preprocess( params.raw);
|
||||||
if (pl) pl->setProgress (0.20);
|
if (pl) pl->setProgress (0.20);
|
||||||
imgsrc->demosaic( params.raw, params.hlrecovery );
|
imgsrc->demosaic( params.raw);
|
||||||
if (pl) pl->setProgress (0.40);
|
if (pl) pl->setProgress (0.30);
|
||||||
|
imgsrc->HLRecovery_Global( params.hlrecovery );
|
||||||
|
if (pl) pl->setProgress (0.40);
|
||||||
Imagefloat* baseImg = new Imagefloat (fw, fh);
|
Imagefloat* baseImg = new Imagefloat (fw, fh);
|
||||||
imgsrc->getImage (currWB, tr, baseImg, pp, params.hlrecovery, params.icm, params.raw);
|
imgsrc->getImage (currWB, tr, baseImg, pp, params.hlrecovery, params.icm, params.raw);
|
||||||
if (pl) pl->setProgress (0.45);
|
if (pl) pl->setProgress (0.45);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class StdImageSource : public ImageSource {
|
|||||||
|
|
||||||
void transform (PreviewProps pp, int tran, int &sx1, int &sy1, int &sx2, int &sy2);
|
void transform (PreviewProps pp, int tran, int &sx1, int &sy1, int &sx2, int &sy2);
|
||||||
void transformPixel (int x, int y, int tran, int& tx, int& ty);
|
void transformPixel (int x, int y, int tran, int& tx, int& ty);
|
||||||
|
bool rgbSourceModified;
|
||||||
public:
|
public:
|
||||||
StdImageSource ();
|
StdImageSource ();
|
||||||
~StdImageSource ();
|
~StdImageSource ();
|
||||||
@@ -62,7 +62,7 @@ class StdImageSource : public ImageSource {
|
|||||||
|
|
||||||
|
|
||||||
static inline double intpow (double a, int b) { double r = 1.0; for (int i=0; i<b; i++) r *= a; return r; }
|
static inline double intpow (double a, int b) { double r = 1.0; for (int i=0; i<b; i++) r *= a; return r; }
|
||||||
|
bool IsrgbSourceModified() {return rgbSourceModified;}
|
||||||
protected:
|
protected:
|
||||||
void getImage_ (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, bool first, HRecParams hrp);
|
void getImage_ (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, bool first, HRecParams hrp);
|
||||||
void hflip (Imagefloat* im);
|
void hflip (Imagefloat* im);
|
||||||
|
|||||||
Reference in New Issue
Block a user