diff --git a/rtdata/languages/default b/rtdata/languages/default index a1a1fe3c1..677114a4a 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -423,6 +423,8 @@ PREFERENCES_CACHESTRAT;Cache Strategy PREFERENCES_CACHETHUMBFORM;Cache Thumbnail Format PREFERENCES_CACHETHUMBHEIGHT;Maximal Thumbnail Height PREFERENCES_CACORRECTION;Apply CA auto correction +PREFERENCES_CARED;CA Red manual correction +PREFERENCES_CABLUE;CA Blue manual correction PREFERENCES_CARED;Red CA manual correction PREFERENCES_CABLUE;Blue CA manual correction PREFERENCES_CLIPPINGIND;Clipping indication diff --git a/rtengine/CA_correct_RT.cc b/rtengine/CA_correct_RT.cc index 69f4f14b6..db6cc43ef 100644 --- a/rtengine/CA_correct_RT.cc +++ b/rtengine/CA_correct_RT.cc @@ -5,7 +5,7 @@ // copyright (c) 2008-2010 Emil Martinec // // -// code dated: June 14, 2010 +// code dated: November 26, 2010 // // CA_correct_RT.cc is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -94,7 +94,7 @@ int RawImageSource::LinEqSolve(int nDim, float* pfMatr, float* pfVect, float* pf //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void RawImageSource::CA_correct_RT() { +void RawImageSource::CA_correct_RT(double cared, double cablue) { #define TS 256 // Tile size //#define border 8 @@ -136,7 +136,7 @@ void RawImageSource::CA_correct_RT() { //shifts to location of vertical and diagonal neighbors const 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; - float eps=1e-5; //tolerance to avoid dividing by zero + float eps=1e-5, eps2=1e-10; //tolerance to avoid dividing by zero //adaptive weights for green interpolation float wtu, wtd, wtl, wtr; @@ -230,6 +230,7 @@ void RawImageSource::CA_correct_RT() { int vctr=0, hctr=0; + if (cared==0 && cablue==0) { // Main algorithm: Tile loop //#pragma omp parallel for shared(image,height,width) private(top,left,indx,indx1) schedule(dynamic) for (top=-border, vblock=1; top < height; top += TS-border2, vblock++) { @@ -424,28 +425,21 @@ void RawImageSource::CA_correct_RT() { //printf("hblock %d vblock %d j %d c %d areawt %d \n",hblock,vblock,j,c,areawt[j][c]); //printf("hblock %d vblock %d j %d c %d areawt %d ",hblock,vblock,j,c,areawt[j][c]); - if (areawt[j][c]>0) { + if (areawt[j][c]>0 && coeff[j][2][c]>eps2) { CAshift[j][c]=coeff[j][1][c]/coeff[j][2][c]; blockwt[vblock*hblsz+hblock]= areawt[j][c];//*coeff[j][2][c]/(eps+coeff[j][0][c]) ; } else { CAshift[j][c]=17.0; blockwt[vblock*hblsz+hblock]=0; } - + //if (c==0 && j==0) printf("vblock= %d hblock= %d denom= %f areawt= %d \n",vblock,hblock,coeff[j][2][c],areawt[j][c]); + //printf("%f \n",CAshift[j][c]); - //CAshift[j][c]=coeff[j][1][c]/coeff[j][2][c]; - //blockwt[vblock*hblsz+hblock] = (float)(rr1-8)*(cc1-8)/4 * coeff[j][2][c]/(eps+coeff[j][0][c]) ; - //data structure = CAshift[vert/hor][color] //j=0=vert, 1=hor - - if ((CAshift[j][c])<0) { - GRBdir[j][c]=-1; - } else { - GRBdir[j][c]=1; - } + offset[j][c]=floor(CAshift[j][c]); //offset gives NW corner of square containing the min; j=0=vert, 1=hor @@ -468,8 +462,9 @@ void RawImageSource::CA_correct_RT() { blockshifts[(vblock)*hblsz+hblock][c][0]=(CAshift[0][c]); //vert CA shift for R/B blockshifts[(vblock)*hblsz+hblock][c][1]=(CAshift[1][c]); //hor CA shift for R/B //data structure: blockshifts[blocknum][R/B][v/h] + //if (c==0) printf("vblock= %d hblock= %d blockshiftsmedian= %f \n",vblock,hblock,blockshifts[(vblock)*hblsz+hblock][c][0]); } - + if(plistener) plistener->setProgress(0.5*fabs((float)top/height)); } @@ -481,7 +476,7 @@ void RawImageSource::CA_correct_RT() { if (blockdenom[j][c]) { blockvar[j][c] = blocksqave[j][c]/blockdenom[j][c]-SQR(blockave[j][c]/blockdenom[j][c]); } else { - fprintf (stderr,"blockdenom vanishes"); + printf ("blockdenom vanishes \n"); return; } } @@ -537,7 +532,7 @@ void RawImageSource::CA_correct_RT() { PIX_SORT(p[4],p[7]); PIX_SORT(p[4],p[2]); PIX_SORT(p[6],p[4]); PIX_SORT(p[4],p[2]); blockshifts[(vblock)*hblsz+hblock][c][dir] = p[4]; - if (p[4]<0) {GRBdir[dir][c]=-1;} else {GRBdir[dir][c]=1;} + //if (c==0 && dir==0) printf("vblock= %d hblock= %d blockshiftsmedian= %f \n",vblock,hblock,p[4]); } @@ -556,6 +551,7 @@ void RawImageSource::CA_correct_RT() { } shiftmat[c][dir][(polyord*i+j)] += (float)pow((float)vblock,i)*pow((float)hblock,j)*blockshifts[(vblock)*hblsz+hblock][c][dir]*blockwt[vblock*hblsz+hblock]; } + //if (c==0 && dir==0) {printf("i= %d j= %d shiftmat= %f \n",i,j,shiftmat[c][dir][(polyord*i+j)]);} }//monomials }//dir @@ -567,7 +563,7 @@ void RawImageSource::CA_correct_RT() { if (numblox[1]<32) { polyord=2; numpar=4; if (numblox[1]< 10) { - fprintf (stderr,("numblox = %d \n"),numblox[1]); + printf ("numblox = %d \n",numblox[1]); return; } } @@ -577,14 +573,14 @@ void RawImageSource::CA_correct_RT() { for (dir=0; dir<2; dir++) { res = LinEqSolve(numpar, polymat[c][dir], shiftmat[c][dir], fitparams[c][dir]); if (res) { - fprintf (stderr,("CA correction pass failed -- can't solve linear equations for color %d direction %d...\n"),c,dir); + printf ("CA correction pass failed -- can't solve linear equations for color %d direction %d...\n",c,dir); return; } } //fitparams[polyord*i+j] gives the coefficients of (vblock^i hblock^j) in a polynomial fit for i,j<=4 - + } //end of initialization for CA correction pass - + //only executed if cared and cablue are zero // Main algorithm: Tile loop //#pragma omp parallel for shared(image,height,width) private(top,left,indx,indx1) schedule(dynamic) @@ -700,20 +696,51 @@ void RawImageSource::CA_correct_RT() { //end of border fill // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - blockshifts[(vblock)*hblsz+hblock][0][0] = blockshifts[(vblock)*hblsz+hblock][0][1] = 0; - blockshifts[(vblock)*hblsz+hblock][2][0] = blockshifts[(vblock)*hblsz+hblock][2][1] = 0; - for (i=0; i-1 && row-1 && col0) { + GRBdir[0][c] = 1; + } else { + GRBdir[0][c] = -1; + } + if (blockshifts[(vblock)*hblsz+hblock][c][1]>0) { + GRBdir[1][c] = 1; + } else { + GRBdir[1][c] = -1; + } + } @@ -741,8 +781,6 @@ void RawImageSource::CA_correct_RT() { //but first we need to interpolate G-R/G-B to grid points... grbdiff[(rr)*TS+cc]=Gint-rgb[(rr)*TS+cc][c]; gshift[(rr)*TS+cc]=Gint; - float tmp1=grbdiff[(rr)*TS+cc]; - } for (rr=8; rr < rr1-8; rr++) diff --git a/rtengine/alignedbuffer.h b/rtengine/alignedbuffer.h index eb8b53b0a..f16a87ded 100644 --- a/rtengine/alignedbuffer.h +++ b/rtengine/alignedbuffer.h @@ -18,6 +18,7 @@ */ #ifndef _ALIGNEDBUFFER_ #define _ALIGNEDBUFFER_ +#include #include diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index d89bc48c8..ea2eefb6f 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -199,6 +199,8 @@ void ProcParams::setDefaults () { hsvequalizer.hue[i] = 0; } raw.df_autoselect = false; + raw.cared = 0; + raw.cablue = 0; raw.ca_autocorrect = false; raw.hotdeadpix_filt = false; raw.linenoise = 0; @@ -422,6 +424,8 @@ int ProcParams::save (Glib::ustring fname) const { keyFile.set_string ("RAW", "DarkFrame", raw.dark_frame ); keyFile.set_boolean ("RAW", "DarkFrameAuto", raw.df_autoselect ); keyFile.set_boolean ("RAW", "CA", raw.ca_autocorrect ); + keyFile.set_double ("RAW", "CARed", raw.cared ); + keyFile.set_double ("RAW", "CABlue", raw.cablue ); keyFile.set_boolean ("RAW", "HotDeadPixels", raw.hotdeadpix_filt ); keyFile.set_integer ("RAW", "LineDenoise", raw.linenoise); keyFile.set_integer ("RAW", "GreenEqThreshold", raw.greenthresh); @@ -736,6 +740,8 @@ if (keyFile.has_group ("RAW")) { if (keyFile.has_key ("RAW", "DarkFrame")) raw.dark_frame = keyFile.get_string ("RAW", "DarkFrame" ); if (keyFile.has_key ("RAW", "DarkFrameAuto")) raw.df_autoselect = keyFile.get_boolean ("RAW", "DarkFrameAuto" ); if (keyFile.has_key ("RAW", "CA")) raw.ca_autocorrect = keyFile.get_boolean ("RAW", "CA" ); + if (keyFile.has_key ("RAW", "CARed")) raw.cared = keyFile.get_boolean ("RAW", "CARed" ); + if (keyFile.has_key ("RAW", "CABlue")) raw.cablue = keyFile.get_boolean ("RAW", "CABlue" ); if (keyFile.has_key ("RAW", "HotDeadPixels")) raw.hotdeadpix_filt = keyFile.get_boolean ("RAW", "HotDeadPixels" ); if (keyFile.has_key ("RAW", "LineDenoise")) raw.linenoise = keyFile.get_integer ("RAW", "LineDenoise" ); if (keyFile.has_key ("RAW", "GreenEqThreshold")) raw.greenthresh= keyFile.get_integer ("RAW", "GreenEqThreshold"); @@ -927,6 +933,8 @@ bool ProcParams::operator== (const ProcParams& other) { && raw.dcb_iterations == other.raw.dcb_iterations && raw.ccSteps == other.raw.ccSteps && raw.ca_autocorrect == other.raw.ca_autocorrect + && raw.cared == other.raw.cared + && raw.cablue == other.raw.cablue && raw.hotdeadpix_filt == other.raw.hotdeadpix_filt && raw.dmethod == other.raw.dmethod && raw.greenthresh == other.raw.greenthresh diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 5cafcbb7c..b506690c7 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -392,6 +392,8 @@ class RAWParams { Glib::ustring dark_frame; bool df_autoselect; bool ca_autocorrect; + double cared; + double cablue; bool hotdeadpix_filt; int linenoise; int greenthresh; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index e92a48891..891be0dae 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -985,17 +985,17 @@ void RawImageSource::preprocess (const RAWParams &raw) plistener->setProgressStr ("Line Denoise..."); plistener->setProgress (0.0); } - + cfa_linedn(0.00002*(raw.linenoise)); } - if ( raw.ca_autocorrect ) { + if ( raw.ca_autocorrect || raw.cared || raw.cablue ) { if (plistener) { plistener->setProgressStr ("CA Auto Correction..."); plistener->setProgress (0.0); } - CA_correct_RT(); + CA_correct_RT(raw.cared, raw.cablue); } t2.set(); if( settings->verbose ) diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 2e348ef7f..f95c5414f 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -148,7 +148,7 @@ class RawImageSource : public ImageSource { inline void interpolate_row_rb_mul_pp (unsigned short* ar, unsigned short* ab, unsigned short* pg, unsigned short* cg, unsigned short* ng, int i, double r_mul, double g_mul, double b_mul, int x1, int width, int skip); int LinEqSolve( int nDim, float* pfMatr, float* pfVect, float* pfSolution);//Emil's CA auto correction - void CA_correct_RT (); + void CA_correct_RT (double cared, double cablue); int cfaCleanFromMap( BYTE* bitmapBads ); int findHotDeadPixel( BYTE *bpMap, float thresh); void ddct8x8s(int isgn, float **a); diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index 87ef8ec6d..aae7386f3 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -174,6 +174,10 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h, int rtmp=CurveFactory::igamma_srgb (img->data[ix++]); int gtmp=CurveFactory::igamma_srgb (img->data[ix++]); int btmp=CurveFactory::igamma_srgb (img->data[ix++]); + + tpp->aeHistogram[rtmp>>tpp->aeHistCompression]++; + tpp->aeHistogram[gtmp>>tpp->aeHistCompression]+=2; + tpp->aeHistogram[btmp>>tpp->aeHistCompression]++; if (rtmp<64000 && gtmp<64000 && btmp<64000) { // autowb computation @@ -182,9 +186,6 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h, avg_b += btmp; n++; } - tpp->aeHistogram[rtmp>>tpp->aeHistCompression]++; - tpp->aeHistogram[gtmp>>tpp->aeHistCompression]++; - tpp->aeHistogram[btmp>>tpp->aeHistCompression]++; } if (n>0) diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index b0afae6c2..9c9a7f31e 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -284,6 +284,8 @@ void ParamsEdited::initFrom (const std::vector raw.dcbIterations = raw.dcbIterations && p.raw.dcb_iterations == other.raw.dcb_iterations; raw.dmethod = raw.dmethod && p.raw.dmethod == other.raw.dmethod; raw.caCorrection = raw.caCorrection && p.raw.ca_autocorrect == other.raw.ca_autocorrect; + raw.caRed = raw.caRed && p.raw.cared == other.raw.cared; + raw.caBlue = raw.caBlue && p.raw.cablue == other.raw.cablue; raw.darkFrame = raw.darkFrame && p.raw.dark_frame == other.raw.dark_frame; raw.dfAuto = raw.dfAuto && p.raw.df_autoselect == other.raw.df_autoselect; raw.greenEq = raw.greenEq && p.raw.greenthresh == other.raw.greenthresh; @@ -427,6 +429,8 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten if (raw.dcbIterations) toEdit.raw.dcb_iterations = mods.raw.dcb_iterations; if (raw.dcbEnhance) toEdit.raw.dcb_enhance = mods.raw.dcb_enhance; if (raw.caCorrection) toEdit.raw.ca_autocorrect = mods.raw.ca_autocorrect; + if (raw.caRed) toEdit.raw.cared = mods.raw.cared; + if (raw.caBlue) toEdit.raw.cablue = mods.raw.cablue; if (raw.greenEq) toEdit.raw.greenthresh = mods.raw.greenthresh; if (raw.hotDeadPixel) toEdit.raw.hotdeadpix_filt= mods.raw.hotdeadpix_filt; if (raw.linenoise) toEdit.raw.linenoise = mods.raw.linenoise; diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index bad4f2281..b0daec1b1 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -279,6 +279,8 @@ class RAWParamsEdited { bool dcbIterations; bool dcbEnhance; bool caCorrection; + bool caRed; + bool caBlue; bool greenEq; bool hotDeadPixel; bool linenoise; diff --git a/rtgui/preprocess.cc b/rtgui/preprocess.cc index 3b3609370..b8b1bc666 100644 --- a/rtgui/preprocess.cc +++ b/rtgui/preprocess.cc @@ -1,220 +1,246 @@ -/* - * This file is part of RawTherapee. - * - * Copyright (c) 2004-2010 Gabor Horvath - * - * RawTherapee is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * RawTherapee is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with RawTherapee. If not, see . - */ -#include -#include -#include -using namespace rtengine; -using namespace rtengine::procparams; - -PreProcess::PreProcess () -{ - hbdf = Gtk::manage(new Gtk::HBox()); - darkFrameFile = Gtk::manage(new Gtk::FileChooserButton(M("TP_PREPROCESS_DARKFRAME"), Gtk::FILE_CHOOSER_ACTION_OPEN)); - dfLabel = Gtk::manage(new Gtk::Label(M("TP_PREPROCESS_DARKFRAME"))); - btnReset = Gtk::manage(new Gtk::Button()); - btnReset->set_image (*Gtk::manage(new Gtk::Image (Gtk::StockID("gtk-cancel"), Gtk::ICON_SIZE_BUTTON))); - hbdf->pack_start(*dfLabel, Gtk::PACK_SHRINK, 4); - hbdf->pack_start(*darkFrameFile); - hbdf->pack_start(*btnReset, Gtk::PACK_SHRINK, 4); - dfAuto = Gtk::manage(new Gtk::CheckButton((M("TP_PREPROCESS_DFAUTOSELECT")))); - caAutocorrect = Gtk::manage(new Gtk::CheckButton((M("PREFERENCES_CACORRECTION")))); - hotDeadPixel = Gtk::manage(new Gtk::CheckButton((M("PREFERENCES_HOTDEADPIXFILT")))); - - lineDenoise = Gtk::manage(new Adjuster (M("PREFERENCES_LINEDENOISE"),0,1000,1,0)); - lineDenoise->setAdjusterListener (this); - lineDenoise->show(); - - greenEqThreshold = Gtk::manage(new Adjuster (M("PREFERENCES_GREENEQUIL"),0,100,1,0)); - greenEqThreshold->setAdjusterListener (this); - greenEqThreshold->show(); - - pack_start( *hbdf, Gtk::PACK_SHRINK, 4); - pack_start( *dfAuto, Gtk::PACK_SHRINK, 4); - pack_start( *Gtk::manage (new Gtk::HSeparator())); - pack_start( *hotDeadPixel, Gtk::PACK_SHRINK, 4); - pack_start( *Gtk::manage (new Gtk::HSeparator())); - pack_start( *caAutocorrect, Gtk::PACK_SHRINK, 4); - pack_start( *Gtk::manage (new Gtk::HSeparator())); - pack_start( *lineDenoise, Gtk::PACK_SHRINK, 4); - pack_start( *Gtk::manage (new Gtk::HSeparator())); - pack_start( *greenEqThreshold, Gtk::PACK_SHRINK, 4); - - caacsconn = caAutocorrect->signal_toggled().connect ( sigc::mem_fun(*this, &PreProcess::caCorrectionChanged), true); - dfautoconn = dfAuto->signal_toggled().connect ( sigc::mem_fun(*this, &PreProcess::dfAutoChanged), true); - hdpixelconn = hotDeadPixel->signal_toggled().connect ( sigc::mem_fun(*this, &PreProcess::hotDeadPixelChanged), true); - dfFile = darkFrameFile->signal_file_set().connect ( sigc::mem_fun(*this, &PreProcess::darkFrameChanged), true); - btnReset->signal_clicked().connect( sigc::mem_fun(*this, &PreProcess::darkFrameReset), true ); -} - - -void PreProcess::read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited) -{ - disableListener (); - caacsconn.block (true); - dfautoconn.block(true); - hdpixelconn.block (true); - - if(pedited ){ - dfAuto->set_inconsistent(!pedited->raw.dfAuto ); - caAutocorrect->set_inconsistent(!pedited->raw.caCorrection); - hotDeadPixel->set_inconsistent (!pedited->raw.hotDeadPixel); - lineDenoise->setEditedState( pedited->raw.linenoise ? Edited : UnEdited ); - greenEqThreshold->setEditedState( pedited->raw.greenEq ? Edited : UnEdited ); - } - - if (Glib::file_test (pp->raw.dark_frame, Glib::FILE_TEST_EXISTS)) - darkFrameFile->set_filename (pp->raw.dark_frame); - else if( !options.rtSettings.darkFramesPath.empty() ) - darkFrameFile->set_current_folder( options.rtSettings.darkFramesPath ); - - lastCA = pp->raw.ca_autocorrect; - lastHot = pp->raw.hotdeadpix_filt; - lastDFauto = pp->raw.df_autoselect; - - dfAuto->set_active( pp->raw.df_autoselect ); - caAutocorrect->set_active(pp->raw.ca_autocorrect); - hotDeadPixel->set_active (pp->raw.hotdeadpix_filt); - lineDenoise->setValue (pp->raw.linenoise); - greenEqThreshold->setValue (pp->raw.greenthresh); - - dfChanged = false; - - - caacsconn.block (false); - dfautoconn.block(false); - hdpixelconn.block (false); - - enableListener (); -} - -void PreProcess::write( rtengine::procparams::ProcParams* pp, ParamsEdited* pedited) -{ - pp->raw.dark_frame = darkFrameFile->get_filename(); - pp->raw.df_autoselect = dfAuto->get_active(); - pp->raw.ca_autocorrect = caAutocorrect->get_active(); - pp->raw.hotdeadpix_filt = hotDeadPixel->get_active(); - pp->raw.linenoise = (int)lineDenoise->getValue(); - pp->raw.greenthresh = (int)greenEqThreshold->getValue(); - - if (pedited) { - pedited->raw.darkFrame = dfChanged; - pedited->raw.dfAuto = !dfAuto->get_inconsistent(); - pedited->raw.linenoise = lineDenoise->getEditedState (); - pedited->raw.greenEq= greenEqThreshold->getEditedState (); - pedited->raw.caCorrection = !caAutocorrect->get_inconsistent(); - pedited->raw.hotDeadPixel = !hotDeadPixel->get_inconsistent(); - } -} - -void PreProcess::adjusterChanged (Adjuster* a, double newval) -{ - if (listener) - listener->panelChanged (EvPreProcess, Glib::ustring("params") ); -} - -void PreProcess::setBatchMode(bool batchMode) -{ - ToolPanel::setBatchMode (batchMode); - lineDenoise->showEditedCB (); - greenEqThreshold->showEditedCB (); -} - -void PreProcess::setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited) -{ - lineDenoise->setDefault( defParams->raw.linenoise); - greenEqThreshold->setDefault (defParams->raw.greenthresh); - if (pedited) { - lineDenoise->setDefaultEditedState( pedited->raw.linenoise ? Edited : UnEdited); - greenEqThreshold->setDefaultEditedState(pedited->raw.greenEq ? Edited : UnEdited); - }else{ - lineDenoise->setDefaultEditedState( Irrelevant ); - greenEqThreshold->setDefaultEditedState(Irrelevant ); - } -} - -void PreProcess::caCorrectionChanged() -{ - if (batchMode) { - if (caAutocorrect->get_inconsistent()) { - caAutocorrect->set_inconsistent (false); - caacsconn.block (true); - caAutocorrect->set_active (false); - caacsconn.block (false); - } - else if (lastCA) - caAutocorrect->set_inconsistent (true); - - lastCA = caAutocorrect->get_active (); - } - if (listener) - listener->panelChanged (EvPreProcess, Glib::ustring(M("PREFERENCES_CACORRECTION"))+"="+(caAutocorrect->get_active()?"ON":"OFF") ); -} - -void PreProcess::dfAutoChanged() -{ - if (batchMode) { - if (dfAuto->get_inconsistent()) { - dfAuto->set_inconsistent (false); - dfautoconn.block (true); - dfAuto->set_active (false); - dfautoconn.block (false); - } - else if (lastDFauto) - dfAuto->set_inconsistent (true); - - lastDFauto = dfAuto->get_active (); - } - hbdf->set_sensitive( !dfAuto->get_active() ); - if (listener) - listener->panelChanged (EvPreProcess, Glib::ustring(M("TP_PREPROCESS_DFAUTOSELECT"))+"="+(dfAuto->get_active()?"ON":"OFF") ); -} - -void PreProcess::hotDeadPixelChanged () -{ - if (batchMode) { - if (hotDeadPixel->get_inconsistent()) { - hotDeadPixel->set_inconsistent (false); - hdpixelconn.block (true); - hotDeadPixel->set_active (false); - hdpixelconn.block (false); - } - else if (lastHot) - hotDeadPixel->set_inconsistent (true); - - lastHot = hotDeadPixel->get_active (); - } - if (listener) - listener->panelChanged (EvPreProcess, Glib::ustring(M("PREFERENCES_HOTDEADPIXFILT"))+"="+(hotDeadPixel->get_active()?"ON":"OFF") ); -} -void PreProcess::darkFrameChanged() -{ - dfChanged=true; - if (listener) - listener->panelChanged (EvPreProcess, Glib::ustring(M("TP_PREPROCESS_DARKFRAME"))+"="+darkFrameFile->get_filename()); -} - -void PreProcess::darkFrameReset() -{ - dfChanged=true; - darkFrameFile->set_current_name(""); - darkFrameFile->set_filename (""); - if (listener) - listener->panelChanged (EvPreProcess, Glib::ustring(M("TP_PREPROCESS_DARKFRAME"))+"=0" ); - -} +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#include +#include +#include +using namespace rtengine; +using namespace rtengine::procparams; + +PreProcess::PreProcess () +{ + hbdf = Gtk::manage(new Gtk::HBox()); + darkFrameFile = Gtk::manage(new Gtk::FileChooserButton(M("TP_PREPROCESS_DARKFRAME"), Gtk::FILE_CHOOSER_ACTION_OPEN)); + dfLabel = Gtk::manage(new Gtk::Label(M("TP_PREPROCESS_DARKFRAME"))); + btnReset = Gtk::manage(new Gtk::Button()); + btnReset->set_image (*Gtk::manage(new Gtk::Image (Gtk::StockID("gtk-cancel"), Gtk::ICON_SIZE_BUTTON))); + hbdf->pack_start(*dfLabel, Gtk::PACK_SHRINK, 4); + hbdf->pack_start(*darkFrameFile); + hbdf->pack_start(*btnReset, Gtk::PACK_SHRINK, 4); + dfAuto = Gtk::manage(new Gtk::CheckButton((M("TP_PREPROCESS_DFAUTOSELECT")))); + + caAutocorrect = Gtk::manage(new Gtk::CheckButton((M("PREFERENCES_CACORRECTION")))); + caRed = Gtk::manage(new Adjuster (M("PREFERENCES_CARED"),-4.0,4.0,0.1,0)); + caRed->setAdjusterListener (this); + caRed->show(); + caBlue = Gtk::manage(new Adjuster (M("PREFERENCES_CABLUE"),-4.0,4.0,0.1,0)); + caBlue->setAdjusterListener (this); + caBlue->show(); + + hotDeadPixel = Gtk::manage(new Gtk::CheckButton((M("PREFERENCES_HOTDEADPIXFILT")))); + + lineDenoise = Gtk::manage(new Adjuster (M("PREFERENCES_LINEDENOISE"),0,1000,1,0)); + lineDenoise->setAdjusterListener (this); + lineDenoise->show(); + + greenEqThreshold = Gtk::manage(new Adjuster (M("PREFERENCES_GREENEQUIL"),0,100,1,0)); + greenEqThreshold->setAdjusterListener (this); + greenEqThreshold->show(); + + pack_start( *hbdf, Gtk::PACK_SHRINK, 4); + pack_start( *dfAuto, Gtk::PACK_SHRINK, 4); + pack_start( *Gtk::manage (new Gtk::HSeparator())); + pack_start( *hotDeadPixel, Gtk::PACK_SHRINK, 4); + pack_start( *Gtk::manage (new Gtk::HSeparator())); + pack_start( *caAutocorrect, Gtk::PACK_SHRINK, 4); + pack_start( *caRed, Gtk::PACK_SHRINK, 4); + pack_start( *caBlue, Gtk::PACK_SHRINK, 4); + pack_start( *Gtk::manage (new Gtk::HSeparator())); + pack_start( *lineDenoise, Gtk::PACK_SHRINK, 4); + pack_start( *Gtk::manage (new Gtk::HSeparator())); + pack_start( *greenEqThreshold, Gtk::PACK_SHRINK, 4); + + caacsconn = caAutocorrect->signal_toggled().connect ( sigc::mem_fun(*this, &PreProcess::caCorrectionChanged), true); + dfautoconn = dfAuto->signal_toggled().connect ( sigc::mem_fun(*this, &PreProcess::dfAutoChanged), true); + hdpixelconn = hotDeadPixel->signal_toggled().connect ( sigc::mem_fun(*this, &PreProcess::hotDeadPixelChanged), true); + dfFile = darkFrameFile->signal_file_set().connect ( sigc::mem_fun(*this, &PreProcess::darkFrameChanged), true); + btnReset->signal_clicked().connect( sigc::mem_fun(*this, &PreProcess::darkFrameReset), true ); +} + + +void PreProcess::read(const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited) +{ + disableListener (); + caacsconn.block (true); + dfautoconn.block(true); + hdpixelconn.block (true); + + if(pedited ){ + dfAuto->set_inconsistent(!pedited->raw.dfAuto ); + caAutocorrect->set_inconsistent(!pedited->raw.caCorrection); + caRed->setEditedState( pedited->raw.caRed ? Edited : UnEdited ); + caBlue->setEditedState( pedited->raw.caBlue ? Edited : UnEdited ); + hotDeadPixel->set_inconsistent (!pedited->raw.hotDeadPixel); + lineDenoise->setEditedState( pedited->raw.linenoise ? Edited : UnEdited ); + greenEqThreshold->setEditedState( pedited->raw.greenEq ? Edited : UnEdited ); + } + + if (Glib::file_test (pp->raw.dark_frame, Glib::FILE_TEST_EXISTS)) + darkFrameFile->set_filename (pp->raw.dark_frame); + else if( !options.rtSettings.darkFramesPath.empty() ) + darkFrameFile->set_current_folder( options.rtSettings.darkFramesPath ); + + lastCA = pp->raw.ca_autocorrect; + lastHot = pp->raw.hotdeadpix_filt; + lastDFauto = pp->raw.df_autoselect; + + dfAuto->set_active( pp->raw.df_autoselect ); + caAutocorrect->set_active(pp->raw.ca_autocorrect); + caRed->setValue (pp->raw.cared); + caBlue->setValue (pp->raw.cablue); + hotDeadPixel->set_active (pp->raw.hotdeadpix_filt); + lineDenoise->setValue (pp->raw.linenoise); + greenEqThreshold->setValue (pp->raw.greenthresh); + + dfChanged = false; + + + caacsconn.block (false); + dfautoconn.block(false); + hdpixelconn.block (false); + + enableListener (); +} + +void PreProcess::write( rtengine::procparams::ProcParams* pp, ParamsEdited* pedited) +{ + pp->raw.dark_frame = darkFrameFile->get_filename(); + pp->raw.df_autoselect = dfAuto->get_active(); + pp->raw.ca_autocorrect = caAutocorrect->get_active(); + pp->raw.cared = (double)caRed->getValue(); + pp->raw.cablue = (double)caBlue->getValue(); + pp->raw.hotdeadpix_filt = hotDeadPixel->get_active(); + pp->raw.linenoise = (int)lineDenoise->getValue(); + pp->raw.greenthresh = (int)greenEqThreshold->getValue(); + + if (pedited) { + pedited->raw.darkFrame = dfChanged; + pedited->raw.dfAuto = !dfAuto->get_inconsistent(); + pedited->raw.linenoise = lineDenoise->getEditedState (); + pedited->raw.greenEq= greenEqThreshold->getEditedState (); + pedited->raw.caCorrection = !caAutocorrect->get_inconsistent(); + pedited->raw.caRed = caRed->getEditedState (); + pedited->raw.caBlue = caBlue->getEditedState (); + pedited->raw.hotDeadPixel = !hotDeadPixel->get_inconsistent(); + } +} + +void PreProcess::adjusterChanged (Adjuster* a, double newval) +{ + if (listener) + listener->panelChanged (EvPreProcess, Glib::ustring("params") ); +} + +void PreProcess::setBatchMode(bool batchMode) +{ + ToolPanel::setBatchMode (batchMode); + caRed->showEditedCB (); + caBlue->showEditedCB (); + lineDenoise->showEditedCB (); + greenEqThreshold->showEditedCB (); +} + +void PreProcess::setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited) +{ + lineDenoise->setDefault( defParams->raw.linenoise); + caRed->setDefault( defParams->raw.cared); + caBlue->setDefault( defParams->raw.cablue); + greenEqThreshold->setDefault (defParams->raw.greenthresh); + if (pedited) { + lineDenoise->setDefaultEditedState( pedited->raw.linenoise ? Edited : UnEdited); + caRed->setDefaultEditedState( pedited->raw.caRed ? Edited : UnEdited); + caBlue->setDefaultEditedState( pedited->raw.caBlue ? Edited : UnEdited); + greenEqThreshold->setDefaultEditedState(pedited->raw.greenEq ? Edited : UnEdited); + }else{ + lineDenoise->setDefaultEditedState( Irrelevant ); + caRed->setDefaultEditedState( Irrelevant ); + caBlue->setDefaultEditedState( Irrelevant ); + greenEqThreshold->setDefaultEditedState(Irrelevant ); + } +} + +void PreProcess::caCorrectionChanged() +{ + if (batchMode) { + if (caAutocorrect->get_inconsistent()) { + caAutocorrect->set_inconsistent (false); + caacsconn.block (true); + caAutocorrect->set_active (false); + caacsconn.block (false); + } + else if (lastCA) + caAutocorrect->set_inconsistent (true); + + lastCA = caAutocorrect->get_active (); + } + if (listener) + listener->panelChanged (EvPreProcess, Glib::ustring(M("PREFERENCES_CACORRECTION"))+"="+(caAutocorrect->get_active()?"ON":"OFF") ); +} + +void PreProcess::dfAutoChanged() +{ + if (batchMode) { + if (dfAuto->get_inconsistent()) { + dfAuto->set_inconsistent (false); + dfautoconn.block (true); + dfAuto->set_active (false); + dfautoconn.block (false); + } + else if (lastDFauto) + dfAuto->set_inconsistent (true); + + lastDFauto = dfAuto->get_active (); + } + hbdf->set_sensitive( !dfAuto->get_active() ); + if (listener) + listener->panelChanged (EvPreProcess, Glib::ustring(M("TP_PREPROCESS_DFAUTOSELECT"))+"="+(dfAuto->get_active()?"ON":"OFF") ); +} + +void PreProcess::hotDeadPixelChanged () +{ + if (batchMode) { + if (hotDeadPixel->get_inconsistent()) { + hotDeadPixel->set_inconsistent (false); + hdpixelconn.block (true); + hotDeadPixel->set_active (false); + hdpixelconn.block (false); + } + else if (lastHot) + hotDeadPixel->set_inconsistent (true); + + lastHot = hotDeadPixel->get_active (); + } + if (listener) + listener->panelChanged (EvPreProcess, Glib::ustring(M("PREFERENCES_HOTDEADPIXFILT"))+"="+(hotDeadPixel->get_active()?"ON":"OFF") ); +} +void PreProcess::darkFrameChanged() +{ + dfChanged=true; + if (listener) + listener->panelChanged (EvPreProcess, Glib::ustring(M("TP_PREPROCESS_DARKFRAME"))+"="+darkFrameFile->get_filename()); +} + +void PreProcess::darkFrameReset() +{ + dfChanged=true; + darkFrameFile->set_current_name(""); + darkFrameFile->set_filename (""); + if (listener) + listener->panelChanged (EvPreProcess, Glib::ustring(M("TP_PREPROCESS_DARKFRAME"))+"=0" ); + +} diff --git a/rtgui/preprocess.h b/rtgui/preprocess.h index edf6fbdad..ec699e91f 100644 --- a/rtgui/preprocess.h +++ b/rtgui/preprocess.h @@ -35,6 +35,8 @@ class PreProcess : public Gtk::VBox, public AdjusterListener, public ToolPanel{ Gtk::Label *dfLabel; bool dfChanged; + Adjuster* caRed; + Adjuster* caBlue; Adjuster* lineDenoise; Adjuster* greenEqThreshold; Gtk::CheckButton* caAutocorrect;