diff --git a/AboutThisBuild.cmake b/AboutThisBuild.cmake
index 68dea478d..2163ed0cb 100644
--- a/AboutThisBuild.cmake
+++ b/AboutThisBuild.cmake
@@ -5,13 +5,13 @@ find_file(REL_INFO_FILE ReleaseInfo.cmake PATHS "${PROJECT_SOURCE_DIR}" NO_DEFAU
if (REL_INFO_FILE STREQUAL REL_INFO_FILE-NOTFOUND)
# we look for the git command in this paths by order of preference
if (WIN32)
- find_file(GIT_CMD git.exe HINTS ENV Path PATH_SUFFIXES ../)
+ find_program(GIT_CMD git.exe HINTS ENV Path PATH_SUFFIXES ../)
elseif (APPLE)
- find_file(GIT_CMD git PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin")
- find_file(GIT_CMD git)
+ find_program(GIT_CMD git PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin")
+ find_program(GIT_CMD git)
set (SHELL "/bin/bash")
else (WIN32) # Linux
- find_file(GIT_CMD git)
+ find_program(GIT_CMD git)
set (SHELL "/bin/bash")
endif (WIN32)
diff --git a/rtdata/languages/default b/rtdata/languages/default
index 5491a5d54..b3e603294 100644
--- a/rtdata/languages/default
+++ b/rtdata/languages/default
@@ -672,6 +672,8 @@ HISTORY_MSG_437;Retinex - M - Method
HISTORY_MSG_438;Retinex - M - Equalizer
HISTORY_MSG_439;Retinex - Preview
HISTORY_MSG_440;CbDL - Method
+HISTORY_MSG_441;Retinex - Gain transmission
+HISTORY_MSG_442;Retinex - Scale
HISTORY_NEWSNAPSHOT;Add
HISTORY_NEWSNAPSHOT_TOOLTIP;Shortcut: Alt-s
HISTORY_SNAPSHOT;Snapshot
@@ -1670,9 +1672,11 @@ TP_RETINEX_CURVEEDITOR_LH;Strength=f(H)
TP_RETINEX_CURVEEDITOR_LH_TOOLTIP;Strength according to hue Strength=f(H)\nThis curve also acts on chroma when using the "Highlight" retinex method.
TP_RETINEX_CURVEEDITOR_MAP;L=f(L)
TP_RETINEX_CURVEEDITOR_MAP_TOOLTIP;This curve can be applied alone or with a Gaussian mask or wavelet mask.\nBeware of artifacts!
+TP_RETINEX_EQUAL;Equalizer
TP_RETINEX_FREEGAMMA;Free gamma
TP_RETINEX_GAIN;Gain
TP_RETINEX_GAIN_TOOLTIP;Acts on the restored image.\n\nThis is very different from the others settings. Used for black or white pixels, and to help balance the histogram.
+TP_RETINEX_GAINOFFS;Gain and Offset (brightness)
TP_RETINEX_GAMMA;Gamma
TP_RETINEX_GAMMA_FREE;Free
TP_RETINEX_GAMMA_HIGH;High
@@ -1690,6 +1694,7 @@ TP_RETINEX_HIGHLIGHT;Highlight threshold
TP_RETINEX_HIGHLIGHT_TOOLTIP;Increase action of High algorithm.\nMay require you to re-adjust "Neighboring pixels" and to increase the "White-point correction" in the Raw tab -> Raw White Points tool.
TP_RETINEX_HSLSPACE_LIN;HSL-Linear
TP_RETINEX_HSLSPACE_LOG;HSL-Logarithmic
+TP_RETINEX_ITERF;Tone mapping
TP_RETINEX_ITER;Iterations (Tone-mapping)
TP_RETINEX_ITER_TOOLTIP;Simulate a tone-mapping operator.\nHigh values increase the processing time.
TP_RETINEX_LABEL;Retinex
@@ -1710,18 +1715,22 @@ TP_RETINEX_MLABEL_TOOLTIP;Should be near min=0 max=32768\nRestored image with no
TP_RETINEX_NEIGHBOR;Radius
TP_RETINEX_NEUTRAL;Reset
TP_RETINEX_NEUTRAL_TIP;Reset all sliders and curves to their default values.
-TP_RETINEX_OFFSET;Brightness
+TP_RETINEX_OFFSET;Offset (brightness)
TP_RETINEX_SCALES;Gaussian gradient
TP_RETINEX_SCALES_TOOLTIP;If slider at 0, all iterations are identical.\nIf > 0 Scale and radius are reduced when iterations increase, and conversely.
TP_RETINEX_SETTINGS;Settings
TP_RETINEX_SLOPE;Free gamma slope
+TP_RETINEX_SKAL;Scale
TP_RETINEX_STRENGTH;Strength
TP_RETINEX_THRESHOLD;Threshold
TP_RETINEX_THRESHOLD_TOOLTIP;Limits in/out.\nIn = image source,\nOut = image gauss.
TP_RETINEX_TLABEL;TM Min=%1 Max=%2 Mean=%3 Sigma=%4
TP_RETINEX_TLABEL2;TM Tm=%1 TM=%2
TP_RETINEX_TLABEL_TOOLTIP;Transmission map result.\nMin and Max are used by Variance.\nMean and Sigma.\nTm=Min TM=Max of transmission map.
+TP_RETINEX_TRANF;Transmission
TP_RETINEX_TRANSMISSION;Transmission map
+TP_RETINEX_GAINTRANSMISSION;Gain transmission
+TP_RETINEX_GAINTRANSMISSION_TOOLTIP;Amplfy or reduce transmission-map to achieve luminance.\nAbscissa: transmission -min from 0, mean, and values (max).\nOrdinate : gain
TP_RETINEX_TRANSMISSION_TOOLTIP;Transmission according to transmission.\nAbscissa: transmission from negative values (min), mean, and positives values (max).\nOrdinate: amplification or reduction.
TP_RETINEX_UNIFORM;Uniform
TP_RETINEX_VARIANCE;Contrast
diff --git a/rtengine/clutstore.cc b/rtengine/clutstore.cc
index 5d859f90c..f3ef27a79 100644
--- a/rtengine/clutstore.cc
+++ b/rtengine/clutstore.cc
@@ -56,7 +56,7 @@ bool loadFile(
img_src.convertColorSpace(img_float.get(), icm, curr_wb);
}
- AlignedBuffer image(fw * fh * 4 + 8); // + 8 because of SSE4_1 version of getClutValue
+ AlignedBuffer image(fw * fh * 4 + 4); // getClutValues() loads one pixel in advance
std::size_t index = 0;
@@ -78,12 +78,30 @@ bool loadFile(
}
#ifdef __SSE2__
-vfloat getClutValue(const AlignedBuffer& clut_image, size_t index)
+vfloat2 getClutValues(const AlignedBuffer& clut_image, size_t index)
{
+ const vint v_values = _mm_loadu_si128(reinterpret_cast(clut_image.data + index));
#ifdef __SSE4_1__
- return _mm_cvtepi32_ps(_mm_cvtepu16_epi32(_mm_loadu_si128(reinterpret_cast(clut_image.data + index))));
+ return {
+ _mm_cvtepi32_ps(_mm_cvtepu16_epi32(v_values)),
+ _mm_cvtepi32_ps(_mm_cvtepu16_epi32(_mm_srli_si128(v_values, 8)))
+ };
#else
- return _mm_set_ps(clut_image.data[index + 3], clut_image.data[index + 2], clut_image.data[index + 1], clut_image.data[index]);
+ const vint v_mask = _mm_set1_epi32(0x0000FFFF);
+
+ vint v_low = _mm_shuffle_epi32(v_values, _MM_SHUFFLE(1, 0, 1, 0));
+ vint v_high = _mm_shuffle_epi32(v_values, _MM_SHUFFLE(3, 2, 3, 2));
+ v_low = _mm_shufflelo_epi16(v_low, _MM_SHUFFLE(1, 1, 0, 0));
+ v_high = _mm_shufflelo_epi16(v_high, _MM_SHUFFLE(1, 1, 0, 0));
+ v_low = _mm_shufflehi_epi16(v_low, _MM_SHUFFLE(3, 3, 2, 2));
+ v_high = _mm_shufflehi_epi16(v_high, _MM_SHUFFLE(3, 3, 2, 2));
+ v_low = vandm(v_low, v_mask);
+ v_high = vandm(v_high, v_mask);
+
+ return {
+ _mm_cvtepi32_ps(v_low),
+ _mm_cvtepi32_ps(v_high)
+ };
#endif
}
#endif
@@ -212,11 +230,13 @@ void rtengine::HaldCLUT::getRGB(
const vfloat v_r = PERMUTEPS(v_rgb, _MM_SHUFFLE(0, 0, 0, 0));
- vfloat v_tmp1 = vintpf(v_r, getClutValue(clut_image, index + 4), getClutValue(clut_image, index));
+ vfloat2 v_clut_values = getClutValues(clut_image, index);
+ vfloat v_tmp1 = vintpf(v_r, v_clut_values.y, v_clut_values.x);
index = (color + level) * 4;
- vfloat v_tmp2 = vintpf(v_r, getClutValue(clut_image, index + 4), getClutValue(clut_image, index));
+ v_clut_values = getClutValues(clut_image, index);
+ vfloat v_tmp2 = vintpf(v_r, v_clut_values.y, v_clut_values.x);
const vfloat v_g = PERMUTEPS(v_rgb, _MM_SHUFFLE(1, 1, 1, 1));
@@ -224,11 +244,13 @@ void rtengine::HaldCLUT::getRGB(
index = (color + level_square) * 4;
- v_tmp1 = vintpf(v_r, getClutValue(clut_image, index + 4), getClutValue(clut_image, index));
+ v_clut_values = getClutValues(clut_image, index);
+ v_tmp1 = vintpf(v_r, v_clut_values.y, v_clut_values.x);
index = (color + level + level_square) * 4;
- v_tmp2 = vintpf(v_r, getClutValue(clut_image, index + 4), getClutValue(clut_image, index));
+ v_clut_values = getClutValues(clut_image, index);
+ v_tmp2 = vintpf(v_r, v_clut_values.y, v_clut_values.x);
v_tmp1 = vintpf(v_g, v_tmp2, v_tmp1);
@@ -250,12 +272,6 @@ void rtengine::HaldCLUT::splitClutFilename(
{
Glib::ustring basename = Glib::path_get_basename(filename);
- Glib::ustring::size_type last_slash_pos = basename.rfind('/');
-
- if (last_slash_pos == Glib::ustring::npos) {
- last_slash_pos = basename.rfind('\\');
- }
-
const Glib::ustring::size_type last_dot_pos = basename.rfind('.');
if (last_dot_pos != Glib::ustring::npos) {
@@ -267,11 +283,16 @@ void rtengine::HaldCLUT::splitClutFilename(
profile_name = "sRGB";
- for (const auto& working_profile : rtengine::getWorkingProfiles()) {
- if (std::search(name.rbegin(), name.rend(), working_profile.rbegin(), working_profile.rend()) == name.rbegin()) {
- profile_name = working_profile;
- name.erase(name.size() - working_profile.size());
- break;
+ if (!name.empty()) {
+ for (const auto& working_profile : rtengine::getWorkingProfiles()) {
+ if (
+ !working_profile.empty() // This isn't strictly needed, but an empty wp name should be skipped anyway
+ && std::search(name.rbegin(), name.rend(), working_profile.rbegin(), working_profile.rend()) == name.rbegin()
+ ) {
+ profile_name = working_profile;
+ name.erase(name.size() - working_profile.size());
+ break;
+ }
}
}
}
diff --git a/rtengine/color.cc b/rtengine/color.cc
index dc0710a2f..3684891df 100644
--- a/rtengine/color.cc
+++ b/rtengine/color.cc
@@ -1844,21 +1844,13 @@ void Color::transitred (const float HH, float const Chprov1, const float dred, c
if(HH >= 0.15f && HH < 1.3f) {
if (Chprov1 < dred) {
factor = factorskin;
- } else if(Chprov1 < (dred + protect_red))
- // factor = (factorsat-factorskin)/protect_red*Chprov1+factorsat-(dred+protect_red)*(factorsat-factorskin)/protect_red;
- // optimized formula
- {
+ } else if(Chprov1 < (dred + protect_red)) {
factor = ((factorsat - factorskin) * Chprov1 + factorsat * protect_red - (dred + protect_red) * (factorsat - factorskin)) / protect_red;
}
- }
- // then test if chroma is in the extanded range
- else if ( HH > (0.15f - deltaHH) || HH < (1.3f + deltaHH) ) {
+ } else if ( HH > (0.15f - deltaHH) && HH < (1.3f + deltaHH) ) { // test if chroma is in the extended range
if (Chprov1 < dred) {
factor = factorskinext; // C=dred=55 => real max of skin tones
- } else if (Chprov1 < (dred + protect_red)) // transition
- // factor = (factorsat-factorskinext)/protect_red*Chprov1+factorsat-(dred+protect_red)*(factorsat-factorskinext)/protect_red;
- // optimized formula
- {
+ } else if (Chprov1 < (dred + protect_red)) {// transition
factor = ((factorsat - factorskinext) * Chprov1 + factorsat * protect_red - (dred + protect_red) * (factorsat - factorskinext)) / protect_red;
}
}
diff --git a/rtengine/curves.cc b/rtengine/curves.cc
index 6792df50d..158086cfd 100644
--- a/rtengine/curves.cc
+++ b/rtengine/curves.cc
@@ -1430,6 +1430,39 @@ void RetinextransmissionCurve::Set(const std::vector &curvePoints)
}
}
+
+RetinexgaintransmissionCurve::RetinexgaintransmissionCurve() {};
+
+void RetinexgaintransmissionCurve::Reset()
+{
+ lutgaintransmission.reset();
+}
+
+void RetinexgaintransmissionCurve::Set(const Curve &pCurve)
+{
+ if (pCurve.isIdentity()) {
+ lutgaintransmission.reset(); // raise this value if the quality suffers from this number of samples
+ return;
+ }
+
+ lutgaintransmission(501); // raise this value if the quality suffers from this number of samples
+
+ for (int i = 0; i < 501; i++) {
+ lutgaintransmission[i] = pCurve.getVal(double(i) / 500.);
+ }
+}
+
+void RetinexgaintransmissionCurve::Set(const std::vector &curvePoints)
+{
+ if (!curvePoints.empty() && curvePoints[0] > FCT_Linear && curvePoints[0] < FCT_Unchanged) {
+ FlatCurve tcurve(curvePoints, false, CURVES_MIN_POLY_POINTS / 2);
+ tcurve.setIdentityValue(0.);
+ Set(tcurve);
+ } else {
+ Reset();
+ }
+}
+
void ToneCurve::Reset()
{
lutToneCurve.reset();
diff --git a/rtengine/curves.h b/rtengine/curves.h
index b0e9d691f..0adc735be 100644
--- a/rtengine/curves.h
+++ b/rtengine/curves.h
@@ -454,6 +454,30 @@ public:
}
};
+class RetinexgaintransmissionCurve
+{
+private:
+ LUTf lutgaintransmission; // 0xffff range
+ void Set(const Curve &pCurve);
+
+public:
+ virtual ~RetinexgaintransmissionCurve() {};
+ RetinexgaintransmissionCurve();
+
+ void Reset();
+ void Set(const Curve *pCurve);
+ void Set(const std::vector &curvePoints);
+ float operator[](float index) const
+ {
+ return lutgaintransmission[index];
+ }
+
+ operator bool (void) const
+ {
+ return lutgaintransmission;
+ }
+};
+
class ToneCurve
diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc
index 530207876..43285825d 100644
--- a/rtengine/iccstore.cc
+++ b/rtengine/iccstore.cc
@@ -263,7 +263,7 @@ cmsHPROFILE ICCStore::makeStdGammaProfile (cmsHPROFILE iprof)
tags[i].sig == 0x6B545243) { // kTRC
if (gamma_offset == 0) {
gamma_offset = offset;
- uint32_t pcurve[] = { htonl (0x63757276), htonl (0), htonl (gamma_size == 12 ? 0 : 1) };
+ uint32_t pcurve[] = { htonl(0x63757276), htonl(0), htonl(gamma_size == 12 ? 0U : 1U) };
memcpy (&nd[offset], pcurve, 12);
if (gamma_size == 14) {
diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc
index c0da10761..bbfc303fc 100644
--- a/rtengine/imagedata.cc
+++ b/rtengine/imagedata.cc
@@ -44,7 +44,7 @@ ImageMetaData* ImageMetaData::fromFile (const Glib::ustring& fname, RawMetaDataL
return new ImageData (fname, rml);
}
-ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri)
+ImageData::ImageData (Glib::ustring fname, RawMetaDataLocation* ri) : iso_speed(0), aperture(0.), shutter(0.)
{
size_t dotpos = fname.find_last_of ('.');
diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h
index 80fc53f23..905c8c50e 100644
--- a/rtengine/imagesource.h
+++ b/rtengine/imagesource.h
@@ -69,14 +69,14 @@ 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 retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) {};
- virtual void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI) {};
+ virtual void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI) {};
+ virtual void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI) {};
virtual void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI) {};
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, LUTf & mapcurve, bool &mapcontlutili, int width, int height, int skip, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) {};
+ virtual void MSR(LabImage* lab, LUTf & mapcurve, bool &mapcontlutili, int width, int height, int skip, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax) {};
virtual bool IsrgbSourceModified() = 0; // tracks whether cached rgb output of demosaic has been modified
diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc
index 2f14c1ded..7434776d5 100644
--- a/rtengine/improccoordinator.cc
+++ b/rtengine/improccoordinator.cc
@@ -55,7 +55,7 @@ ImProcCoordinator::ImProcCoordinator ()
lhist16(65536), lhist16Cropped(65536),
lhist16CAM(65536), lhist16CroppedCAM(65536),
lhist16CCAM(65536),
- lhist16RETI(65536),
+ lhist16RETI(),
histCropped(65536),
lhist16Clad(65536), lhist16CLlad(65536),
lhist16LClad(65536), lhist16LLClad(65536),
@@ -236,6 +236,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
}
if (params.retinex.enabled) {
+ lhist16RETI(32768);
lhist16RETI.clear();
imgsrc->retinexPrepareBuffers(params.icm, params.retinex, conversionBuffer, lhist16RETI);
@@ -249,9 +250,9 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
LUTf cdcurve (65536, 0);
LUTf mapcurve (65536, 0);
- imgsrc->retinexPrepareCurves(params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehacontlutili, mapcontlutili, useHsl, lhist16RETI, histLRETI);
+ imgsrc->retinexPrepareCurves(params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, dehacontlutili, mapcontlutili, useHsl, lhist16RETI, histLRETI);
float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax;
- imgsrc->retinex( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, histLRETI);//enabled Retinex
+ imgsrc->retinex( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, histLRETI);//enabled Retinex
if(dehaListener) {
dehaListener->minmaxChanged(maxCD, minCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax);
diff --git a/rtengine/improccoordinator.h b/rtengine/improccoordinator.h
index 4d442482e..6a6c203d2 100644
--- a/rtengine/improccoordinator.h
+++ b/rtengine/improccoordinator.h
@@ -136,6 +136,7 @@ protected:
WavOpacityCurveW waOpacityCurveW;
WavOpacityCurveWL waOpacityCurveWL;
RetinextransmissionCurve dehatransmissionCurve;
+ RetinexgaintransmissionCurve dehagaintransmissionCurve;
ColorAppearance customColCurve1;
ColorAppearance customColCurve2;
diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc
index e9ae98e2a..bc70bf5e5 100644
--- a/rtengine/improcfun.cc
+++ b/rtengine/improcfun.cc
@@ -3226,8 +3226,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
xyz2clut = iccStore->workingSpaceInverseMatrix( hald_clut->getProfile() );
xyz2work = iccStore->workingSpaceInverseMatrix( params->icm.working );
clut2xyz = iccStore->workingSpaceMatrix( hald_clut->getProfile() );
-#ifdef __SSE2__
+#ifdef __SSE2__
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
v_work2xyz[i][j] = F2V(work2xyz[i][j]);
@@ -3236,8 +3236,8 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
v_clut2xyz[i][j] = F2V(clut2xyz[i][j]);
}
}
-
#endif
+
}
}
}
@@ -4361,12 +4361,12 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
// Convert from working to clut profile
int j = jstart;
int tj = 0;
-#ifdef __SSE2__
+#ifdef __SSE2__
for (; j < tW - 3; j += 4, tj += 4) {
- vfloat sourceR = LVFU(rtemp[ti * TS + tj]);
- vfloat sourceG = LVFU(gtemp[ti * TS + tj]);
- vfloat sourceB = LVFU(btemp[ti * TS + tj]);
+ vfloat sourceR = LVF(rtemp[ti * TS + tj]);
+ vfloat sourceG = LVF(gtemp[ti * TS + tj]);
+ vfloat sourceB = LVF(btemp[ti * TS + tj]);
vfloat x;
vfloat y;
@@ -4374,11 +4374,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_work2xyz);
Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2clut);
- STVFU(rtemp[ti * TS + tj], sourceR);
- STVFU(gtemp[ti * TS + tj], sourceG);
- STVFU(btemp[ti * TS + tj], sourceB);
+ STVF(rtemp[ti * TS + tj], sourceR);
+ STVF(gtemp[ti * TS + tj], sourceG);
+ STVF(btemp[ti * TS + tj], sourceB);
}
-
#endif
for (; j < tW; j++, tj++) {
@@ -4428,12 +4427,12 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
// Convert from clut to working profile
int j = jstart;
int tj = 0;
-#ifdef __SSE2__
+#ifdef __SSE2__
for (; j < tW - 3; j += 4, tj += 4) {
- vfloat sourceR = LVFU(rtemp[ti * TS + tj]);
- vfloat sourceG = LVFU(gtemp[ti * TS + tj]);
- vfloat sourceB = LVFU(btemp[ti * TS + tj]);
+ vfloat sourceR = LVF(rtemp[ti * TS + tj]);
+ vfloat sourceG = LVF(gtemp[ti * TS + tj]);
+ vfloat sourceB = LVF(btemp[ti * TS + tj]);
vfloat x;
vfloat y;
@@ -4441,11 +4440,10 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
Color::rgbxyz(sourceR, sourceG, sourceB, x, y, z, v_clut2xyz);
Color::xyz2rgb(x, y, z, sourceR, sourceG, sourceB, v_xyz2work);
- STVFU(rtemp[ti * TS + tj], sourceR);
- STVFU(gtemp[ti * TS + tj], sourceG);
- STVFU(btemp[ti * TS + tj], sourceB);
+ STVF(rtemp[ti * TS + tj], sourceR);
+ STVF(gtemp[ti * TS + tj], sourceG);
+ STVF(btemp[ti * TS + tj], sourceB);
}
-
#endif
for (; j < tW; j++, tj++) {
diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc
index 4f17c6fbe..66e630d0f 100644
--- a/rtengine/iplab2rgb.cc
+++ b/rtengine/iplab2rgb.cc
@@ -202,7 +202,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
}
} else {
- const auto rgb_xyz = iccStore->workingSpaceMatrix (profile);
+ const auto xyz_rgb = iccStore->workingSpaceInverseMatrix (profile);
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,16) if (multiThread)
@@ -227,7 +227,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
float z_ = 65535.0 * Color::f2xyz (fz) * Color::D50z;
float y_ = (LL > Color::epskap) ? 65535.0 * fy * fy * fy : 65535.0 * LL / Color::kappa;
- Color::xyz2rgb (x_, y_, z_, R, G, B, rgb_xyz);
+ Color::xyz2rgb(x_, y_, z_, R, G, B, xyz_rgb);
image->data[ix++] = (int)Color::gamma2curve[CLIP (R)] >> 8;
image->data[ix++] = (int)Color::gamma2curve[CLIP (G)] >> 8;
diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc
index 60ac6df0a..6773e7a12 100644
--- a/rtengine/ipretinex.cc
+++ b/rtengine/ipretinex.cc
@@ -45,10 +45,8 @@
#include "rawimagesource.h"
#include "improcfun.h"
#include "opthelper.h"
-//#define BENCHMARK
#include "StopWatch.h"
-#define MAX_RETINEX_SCALES 8
#define clipretinex( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val )
#define med3(a0,a1,a2,a3,a4,a5,a6,a7,a8,median) { \
@@ -61,14 +59,10 @@ PIX_SORT(pp[3],pp[6]); PIX_SORT(pp[1],pp[4]); PIX_SORT(pp[2],pp[5]); \
PIX_SORT(pp[4],pp[7]); PIX_SORT(pp[4],pp[2]); PIX_SORT(pp[6],pp[4]); \
PIX_SORT(pp[4],pp[2]); median=pp[4];} //pp4 = median
-namespace rtengine
+
+namespace
{
-
-extern const Settings* settings;
-
-static float RetinexScales[MAX_RETINEX_SCALES];
-
-void retinex_scales ( float* scales, int nscales, int mode, int s, float high)
+void retinex_scales( float* scales, int nscales, int mode, int s, float high)
{
if ( nscales == 1 ) {
scales[0] = (float)s / 2.f;
@@ -83,19 +77,19 @@ void retinex_scales ( float* scales, int nscales, int mode, int s, float high)
scales[nscales - i - 1] = 2.0f + (float)i * size_step;
}
} else if (mode == 1) {
- size_step = (float)log (s - 2.0f) / (float) nscales;
+ size_step = (float)log(s - 2.0f) / (float) nscales;
for (int i = 0; i < nscales; ++i ) {
scales[nscales - i - 1] = 2.0f + (float)pow (10.f, (i * size_step) / log (10.f));
}
} else if (mode == 2) {
- size_step = (float) log (s - 2.0f) / (float) nscales;
+ size_step = (float) log(s - 2.0f) / (float) nscales;
for ( int i = 0; i < nscales; ++i ) {
scales[i] = s - (float)pow (10.f, (i * size_step) / log (10.f));
}
} else if (mode == 3) {
- size_step = (float) log (s - 2.0f) / (float) nscales;
+ size_step = (float) log(s - 2.0f) / (float) nscales;
for ( int i = 0; i < nscales; ++i ) {
scales[i] = high * s - (float)pow (10.f, (i * size_step) / log (10.f));
@@ -103,7 +97,8 @@ void retinex_scales ( float* scales, int nscales, int mode, int s, float high)
}
}
}
-void mean_stddv2 ( float **dst, float &mean, float &stddv, int W_L, int H_L, float &maxtr, float &mintr)
+
+void mean_stddv2( float **dst, float &mean, float &stddv, int W_L, int H_L, float &maxtr, float &mintr)
{
// summation using double precision to avoid too large summation error for large pictures
double vsquared = 0.f;
@@ -124,14 +119,8 @@ void mean_stddv2 ( float **dst, float &mean, float &stddv, int W_L, int H_L, flo
sum += dst[i][j];
vsquared += (dst[i][j] * dst[i][j]);
- if ( dst[i][j] > lmax) {
- lmax = dst[i][j] ;
- }
-
- if ( dst[i][j] < lmin) {
- lmin = dst[i][j] ;
- }
-
+ lmax = dst[i][j] > lmax ? dst[i][j] : lmax;
+ lmin = dst[i][j] < lmin ? dst[i][j] : lmin;
}
#ifdef _OPENMP
@@ -146,101 +135,48 @@ void mean_stddv2 ( float **dst, float &mean, float &stddv, int W_L, int H_L, flo
mean = sum / (double) (W_L * H_L);
vsquared /= (double) W_L * H_L;
stddv = ( vsquared - (mean * mean) );
- stddv = (float)sqrt (stddv);
+ stddv = (float)sqrt(stddv);
+}
+
}
-
-
-
-
-void mean_stddv ( float **dst, float &mean, float &stddv, int W_L, int H_L, const float factor, float &maxtr, float &mintr)
-
+namespace rtengine
{
- // summation using double precision to avoid too large summation error for large pictures
- double vsquared = 0.f;
- double sum = 0.f;
- maxtr = 0.f;
- mintr = 0.f;
-#ifdef _OPENMP
- #pragma omp parallel
-#endif
- {
- float lmax = 0.f, lmin = 0.f;
-#ifdef _OPENMP
- #pragma omp for reduction(+:sum,vsquared) // this can lead to differences, but parallel summation is more accurate
-#endif
+extern const Settings* settings;
- for (int i = 0; i < H_L; i++ )
- for (int j = 0; j < W_L; j++) {
- sum += dst[i][j];
- vsquared += (dst[i][j] * dst[i][j]);
-
- if ( dst[i][j] > lmax) {
- lmax = dst[i][j] ;
- }
-
- if ( dst[i][j] < lmin) {
- lmin = dst[i][j] ;
- }
-
- }
-
-#ifdef _OPENMP
- #pragma omp critical
-#endif
- {
- maxtr = maxtr > lmax ? maxtr : lmax;
- mintr = mintr < lmin ? mintr : lmin;
- }
-
- }
-
- sum *= factor;
- maxtr *= factor;
- mintr *= factor;
- vsquared *= (factor * factor);
- mean = sum / (float) (W_L * H_L);
- vsquared /= (float) W_L * H_L;
- stddv = ( vsquared - (mean * mean) );
- stddv = (float)sqrt (stddv);
-}
-
-void RawImageSource::MSR (float** luminance, float** originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax)
+void RawImageSource::MSR(float** luminance, float** originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax)
{
- BENCHFUN
if (deh.enabled) {//enabled
float mean, stddv, maxtr, mintr;
- //float mini, delta, maxi;
float delta;
- float eps = 2.f;
+ constexpr float eps = 2.f;
bool useHsl = deh.retinexcolorspace == "HSLLOG";
bool useHslLin = deh.retinexcolorspace == "HSLLIN";
float gain2 = (float) deh.gain / 100.f; //def =1 not use
gain2 = useHslLin ? gain2 * 0.5f : gain2;
float offse = (float) deh.offs; //def = 0 not use
int iter = deh.iter;
- int gradient = deh.scal;
+ int gradient = deh.scal;
int scal = 3;//disabled scal
- int nei = (int) 2.8f * deh.neigh; //def = 220
+ int nei = (int) (2.8f * deh.neigh); //def = 220
float vart = (float)deh.vart / 100.f;//variance
float gradvart = (float)deh.grad;
float gradstr = (float)deh.grads;
float strength = (float) deh.str / 100.f; // Blend with original L channel data
float limD = (float) deh.limd;
- limD = pow (limD, 1.7f); //about 2500 enough
+ limD = pow(limD, 1.7f);//about 2500 enough
limD *= useHslLin ? 10.f : 1.f;
float ilimD = 1.f / limD;
- int moderetinex = 2; // default to 2 ( deh.retinexMethod == "high" )
float hig = ((float) deh.highl) / 100.f;
- bool higplus = false ;
float elogt;
float hl = deh.baselog;
+ scal = deh.skal;
- if (hl >= 2.71828f) {
- elogt = 2.71828f + SQR (SQR (hl - 2.71828f));
+ if(hl >= 2.71828f) {
+ elogt = 2.71828f + SQR(SQR(hl - 2.71828f));
} else {
elogt = hl;
}
@@ -249,70 +185,63 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
int W_L = width;
float *tran[H_L] ALIGNED16;
- float *tranBuffer;
- int viewmet = 0;
+ float *tranBuffer = nullptr;
elogt = 2.71828f;//disabled baselog
- FlatCurve* shcurve = NULL;//curve L=f(H)
bool lhutili = false;
- if (deh.enabled) {
- shcurve = new FlatCurve (deh.lhcurve);
+ FlatCurve* shcurve = new FlatCurve(deh.lhcurve); //curve L=f(H)
- if (!shcurve || shcurve->isIdentity()) {
- if (shcurve) {
- delete shcurve;
- shcurve = NULL;
- }
- } else {
- lhutili = true;
+ if (!shcurve || shcurve->isIdentity()) {
+ if (shcurve) {
+ delete shcurve;
+ shcurve = nullptr;
}
+ } else {
+ lhutili = true;
}
- if (deh.retinexMethod == "highliplus") {
+ bool higplus = false ;
+ int moderetinex = 2; // default to 2 ( deh.retinexMethod == "high" )
+
+ if(deh.retinexMethod == "highliplus") {
higplus = true;
- }
-
- if (deh.retinexMethod == "uni") {
+ moderetinex = 3;
+ } else if (deh.retinexMethod == "uni") {
moderetinex = 0;
- }
-
- if (deh.retinexMethod == "low") {
+ } else if (deh.retinexMethod == "low") {
moderetinex = 1;
- }
-
- if (deh.retinexMethod == "highli" || deh.retinexMethod == "highliplus") {
+ } else { /*if (deh.retinexMethod == "highli") */
moderetinex = 3;
}
- for (int it = 1; it < iter + 1; it++) { //iter nb max of iterations
- float aahi = 49.f / 99.f; ////reduce sensibility 50%
- float bbhi = 1.f - aahi;
- float high;
- high = bbhi + aahi * (float) deh.highl;
+ constexpr float aahi = 49.f / 99.f; ////reduce sensibility 50%
+ constexpr float bbhi = 1.f - aahi;
+
+ for(int it = 1; it < iter + 1; it++) { //iter nb max of iterations
+ float high = bbhi + aahi * (float) deh.highl;
- float grads;
float grad = 1.f;
- float sc = 3.f;
+ float sc = scal;
- if (gradient == 0) {
+ if(gradient == 0) {
grad = 1.f;
sc = 3.f;
- } else if (gradient == 1) {
+ } else if(gradient == 1) {
grad = 0.25f * it + 0.75f;
sc = -0.5f * it + 4.5f;
- } else if (gradient == 2) {
+ } else if(gradient == 2) {
grad = 0.5f * it + 0.5f;
sc = -0.75f * it + 5.75f;
- } else if (gradient == 3) {
+ } else if(gradient == 3) {
grad = 0.666f * it + 0.333f;
sc = -0.75f * it + 5.75f;
- } else if (gradient == 4) {
+ } else if(gradient == 4) {
grad = 0.8f * it + 0.2f;
sc = -0.75f * it + 5.75f;
- } else if (gradient == 5) {
- if (moderetinex != 3) {
+ } else if(gradient == 5) {
+ if(moderetinex != 3) {
grad = 2.5f * it - 1.5f;
} else {
float aa = (11.f * high - 1.f) / 4.f;
@@ -321,8 +250,8 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
}
sc = -0.75f * it + 5.75f;
- } else if (gradient == 6) {
- if (moderetinex != 3) {
+ } else if(gradient == 6) {
+ if(moderetinex != 3) {
grad = 5.f * it - 4.f;
} else {
float aa = (21.f * high - 1.f) / 4.f;
@@ -333,28 +262,45 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
sc = -0.75f * it + 5.75f;
}
- else if (gradient == -1) {
+ else if(gradient == -1) {
grad = -0.125f * it + 1.125f;
sc = 3.f;
}
+ if(iter == 1) {
+ sc = scal;
+ } else {
+ //adjust sc in function of choice of scale by user if iterations
+ if(scal < 3) {
+ sc -= 1;
+
+ if(sc < 1.f) {//avoid 0
+ sc = 1.f;
+ }
+ }
+
+ if(scal > 4) {
+ sc += 1;
+ }
+ }
+
float varx;
float limdx, ilimdx;
- if (gradvart != 0) {
- if (gradvart == 1) {
+ if(gradvart != 0) {
+ if(gradvart == 1) {
varx = vart * (-0.125f * it + 1.125f);
limdx = limD * (-0.125f * it + 1.125f);
ilimdx = 1.f / limdx;
- } else if (gradvart == 2) {
+ } else if(gradvart == 2) {
varx = vart * (-0.2f * it + 1.2f);
limdx = limD * (-0.2f * it + 1.2f);
ilimdx = 1.f / limdx;
- } else if (gradvart == -1) {
+ } else if(gradvart == -1) {
varx = vart * (0.125f * it + 0.875f);
limdx = limD * (0.125f * it + 0.875f);
ilimdx = 1.f / limdx;
- } else if (gradvart == -2) {
+ } else if(gradvart == -2) {
varx = vart * (0.4f * it + 0.6f);
limdx = limD * (0.4f * it + 0.6f);
ilimdx = 1.f / limdx;
@@ -365,31 +311,30 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
ilimdx = ilimD;
}
- scal = round (sc);
- float strengthx;
+ scal = round(sc);
float ks = 1.f;
- if (gradstr != 0) {
- if (gradstr == 1) {
- if (it <= 3) {
+ if(gradstr != 0) {
+ if(gradstr == 1) {
+ if(it <= 3) {
ks = -0.3f * it + 1.6f;
} else {
ks = 0.5f;
}
- } else if (gradstr == 2) {
- if (it <= 3) {
+ } else if(gradstr == 2) {
+ if(it <= 3) {
ks = -0.6f * it + 2.2f;
} else {
ks = 0.3f;
}
- } else if (gradstr == -1) {
- if (it <= 3) {
+ } else if(gradstr == -1) {
+ if(it <= 3) {
ks = 0.2f * it + 0.6f;
} else {
ks = 1.2f;
}
- } else if (gradstr == -2) {
- if (it <= 3) {
+ } else if(gradstr == -2) {
+ if(it <= 3) {
ks = 0.4f * it + 0.2f;
} else {
ks = 1.5f;
@@ -397,9 +342,12 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
}
}
- strengthx = ks * strength;
+ float strengthx = ks * strength;
- retinex_scales ( RetinexScales, scal, moderetinex, nei / grad, high );
+ constexpr auto maxRetinexScales = 8;
+ float RetinexScales[maxRetinexScales];
+
+ retinex_scales( RetinexScales, scal, moderetinex, nei / grad, high );
float *src[H_L] ALIGNED16;
float *srcBuffer = new float[H_L * W_L];
@@ -412,39 +360,28 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
int shHighlights = deh.highlights;
int shShadows = deh.shadows;
+
int mapmet = 0;
- if (deh.mapMethod == "map") {
+ if(deh.mapMethod == "map") {
mapmet = 2;
- }
-
- if (deh.mapMethod == "mapT") {
+ } else if(deh.mapMethod == "mapT") {
mapmet = 3;
- }
-
- /*if(deh.mapMethod == "curv") {
- mapmet = 1;
- }*/
-
- if (deh.mapMethod == "gaus") {
+ } else if(deh.mapMethod == "gaus") {
mapmet = 4;
}
const double shradius = mapmet == 4 ? (double) deh.radius : 40.;
- if (deh.viewMethod == "mask") {
+ int viewmet = 0;
+
+ if(deh.viewMethod == "mask") {
viewmet = 1;
- }
-
- if (deh.viewMethod == "tran") {
+ } else if(deh.viewMethod == "tran") {
viewmet = 2;
- }
-
- if (deh.viewMethod == "tran2") {
+ } else if(deh.viewMethod == "tran2") {
viewmet = 3;
- }
-
- if (deh.viewMethod == "unsharp") {
+ } else if(deh.viewMethod == "unsharp") {
viewmet = 4;
}
@@ -465,7 +402,7 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
out[i] = &outBuffer[i * W_L];
}
- if (viewmet == 3 || viewmet == 2) {
+ if(viewmet == 3 || viewmet == 2) {
tranBuffer = new float[H_L * W_L];
for (int i = 0; i < H_L; i++) {
@@ -473,11 +410,11 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
}
}
- const float logBetaGain = xlogf (16384.f);
+ const float logBetaGain = xlogf(16384.f);
float pond = logBetaGain / (float) scal;
- if (!useHslLin) {
- pond /= log (elogt);
+ if(!useHslLin) {
+ pond /= log(elogt);
}
auto shmap = ((mapmet == 2 || mapmet == 3 || mapmet == 4) && it == 1) ? new SHMap (W_L, H_L, true) : nullptr;
@@ -538,6 +475,12 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
#endif
if(mapmet > 0 && mapcontlutili && it == 1) {
+ // TODO: When rgbcurvespeedup branch is merged into master we can simplify the code by
+ // 1) in rawimagesource.retinexPrepareCurves() insert
+ // mapcurve *= 0.5f;
+ // after
+ // CurveFactory::mapcurve (mapcontlutili, retinexParams.mapcurve, mapcurve, 1, lhist16RETI, histLRETI);
+ // 2) remove the division by 2.f from the code 7 lines below this line
#ifdef _OPENMP
#pragma omp parallel for
#endif
@@ -551,21 +494,21 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
}
if(((mapmet == 2 && scale > 2) || mapmet == 3 || mapmet == 4) && it == 1) {
-
-
+ float hWeight = (100.f - shHighlights) / 100.f;
+ float sWeight = (100.f - shShadows) / 100.f;
#ifdef _OPENMP
- #pragma omp parallel for
+ #pragma omp parallel for schedule(dynamic,16)
#endif
for (int i = 0; i < H_L; i++) {
for (int j = 0; j < W_L; j++) {
- double mapval = 1.0 + shmap->map[i][j];
- double factor = 1.0;
+ float mapval = 1.f + shmap->map[i][j];
+ float factor = 1.f;
if (mapval > h_th) {
- factor = (h_th + (100.0 - shHighlights) * (mapval - h_th) / 100.0) / mapval;
+ factor = (h_th + hWeight * (mapval - h_th)) / mapval;
} else if (mapval < s_th) {
- factor = (s_th - (100.0 - shShadows) * (s_th - mapval) / 100.0) / mapval;
+ factor = (s_th - sWeight * (s_th - mapval)) / mapval;
}
out[i][j] *= factor;
@@ -607,23 +550,22 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
}
}
- if (mapmet > 1) {
- if (shmap) {
+ if(mapmet > 1) {
+ if(shmap) {
delete shmap;
}
}
- shmap = NULL;
+ shmap = nullptr;
delete [] buffer;
- //delete [] outBuffer;
delete [] srcBuffer;
mean = 0.f;
stddv = 0.f;
// I call mean_stddv2 instead of mean_stddv ==> logBetaGain
- mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr);
+ mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr);
//printf("mean=%f std=%f delta=%f maxtr=%f mintr=%f\n", mean, stddv, delta, maxtr, mintr);
//mean_stddv( luminance, mean, stddv, W_L, H_L, logBetaGain, maxtr, mintr);
@@ -641,6 +583,7 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
bmax *= 500.f;
amin *= 500.f;
bmin *= 500.f;
+
#ifdef _OPENMP
#pragma omp parallel
#endif
@@ -652,7 +595,7 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
for (int i = 0; i < H_L; i++ )
for (int j = 0; j < W_L; j++) { //for mintr to maxtr evalate absciss in function of original transmission
- if (LIKELY (fabsf (luminance[i][j] - mean) < stddv)) {
+ if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) {
absciss = asig * luminance[i][j] + bsig;
} else if (luminance[i][j] >= mean) {
absciss = amax * luminance[i][j] + bmax;
@@ -660,9 +603,10 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
absciss = amin * luminance[i][j] + bmin;
}
+ //TODO : move multiplication by 4.f and subtraction of 1.f inside the curve
luminance[i][j] *= (-1.f + 4.f * dehatransmissionCurve[absciss]); //new transmission
- if (viewmet == 3 || viewmet == 2) {
+ if(viewmet == 3 || viewmet == 2) {
tran[i][j] = luminance[i][j];
}
}
@@ -688,7 +632,7 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
float pp[9], temp;
for (int j = borderL; j < wid - borderL; j++) {
- med3 (luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1], tmL[i][j]); //3x3
+ med3(luminance[i][j], luminance[i - 1][j], luminance[i + 1][j], luminance[i][j + 1], luminance[i][j - 1], luminance[i - 1][j - 1], luminance[i - 1][j + 1], luminance[i + 1][j - 1], luminance[i + 1][j + 1], tmL[i][j]); //3x3
}
}
@@ -708,7 +652,7 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
// I call mean_stddv2 instead of mean_stddv ==> logBetaGain
//mean_stddv( luminance, mean, stddv, W_L, H_L, 1.f, maxtr, mintr);
- mean_stddv2 ( luminance, mean, stddv, W_L, H_L, maxtr, mintr);
+ mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr);
}
@@ -733,7 +677,8 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
delta = 1.0f;
}
- float cdfactor = gain2 * 32768.f / delta;
+ // float cdfactor = gain2 * 32768.f / delta;
+ float cdfactor = 32768.f / delta;
maxCD = -9999999.f;
minCD = 9999999.f;
// coeff for auto "transmission" with 2 sigma #95% datas
@@ -742,73 +687,111 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
float bza = 16300.f / (2.f * stddv);
float bzb = 16300.f - bza * (mean);
+//prepare work for curve gain
+#ifdef _OPENMP
+ #pragma omp parallel for
+#endif
+ for (int i = 0; i < H_L; i++) {
+ for (int j = 0; j < W_L; j++) {
+ luminance[i][j] = luminance[i][j] - mini;
+ }
+ }
+
+ mean = 0.f;
+ stddv = 0.f;
+ // I call mean_stddv2 instead of mean_stddv ==> logBetaGain
+
+ mean_stddv2( luminance, mean, stddv, W_L, H_L, maxtr, mintr);
+ float asig, bsig, amax, bmax, amin, bmin;
+
+ if (dehagaintransmissionCurve && mean != 0.f && stddv != 0.f) { //if curve
+ asig = 0.166666f / stddv;
+ bsig = 0.5f - asig * mean;
+ amax = 0.333333f / (maxtr - mean - stddv);
+ bmax = 1.f - amax * maxtr;
+ amin = 0.333333f / (mean - stddv - mintr);
+ bmin = -amin * mintr;
+
+ asig *= 500.f;
+ bsig *= 500.f;
+ amax *= 500.f;
+ bmax *= 500.f;
+ amin *= 500.f;
+ bmin *= 500.f;
+ }
#ifdef _OPENMP
#pragma omp parallel
#endif
{
float cdmax = -999999.f, cdmin = 999999.f;
-
#ifdef _OPENMP
- #pragma omp for
+ #pragma omp for schedule(dynamic,16) nowait
#endif
for ( int i = 0; i < H_L; i ++ )
for (int j = 0; j < W_L; j++) {
- //float cd = cdfactor * ( luminance[i][j] * logBetaGain - mini ) + offse;
- float cd = cdfactor * ( luminance[i][j] - mini ) + offse;
+ float gan;
- if (cd > cdmax) {
- cdmax = cd;
+ if (dehagaintransmissionCurve && mean != 0.f && stddv != 0.f) {
+ float absciss;
+
+ if (LIKELY(fabsf(luminance[i][j] - mean) < stddv)) {
+ absciss = asig * luminance[i][j] + bsig;
+ } else if (luminance[i][j] >= mean) {
+ absciss = amax * luminance[i][j] + bmax;
+ } else { /*if(luminance[i][j] <= mean - stddv)*/
+ absciss = amin * luminance[i][j] + bmin;
+ }
+
+
+ // float cd = cdfactor * ( luminance[i][j] - mini ) + offse;
+ // TODO : move multiplication by 2.f inside the curve
+ gan = 2.f * (dehagaintransmissionCurve[absciss]); //new gain function transmission
+ } else {
+ gan = 0.5f;
}
- if (cd < cdmin) {
- cdmin = cd;
- }
+ float cd = gan * cdfactor * ( luminance[i][j] ) + offse;
+
+ cdmax = cd > cdmax ? cd : cdmax;
+ cdmin = cd < cdmin ? cd : cdmin;
float str = strengthx;
- if (lhutili && it == 1) { // S=f(H)
+ if(lhutili && it == 1) { // S=f(H)
{
float HH = exLuminance[i][j];
float valparam;
- if (useHsl || useHslLin) {
- valparam = float ((shcurve->getVal (HH) - 0.5f));
+ if(useHsl || useHslLin) {
+ valparam = float((shcurve->getVal(HH) - 0.5f));
} else {
- valparam = float ((shcurve->getVal (Color::huelab_to_huehsv2 (HH)) - 0.5f));
+ valparam = float((shcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f));
}
str *= (1.f + 2.f * valparam);
}
}
- if (exLuminance[i][j] > 65535.f * hig && higplus) {
+ if(higplus && exLuminance[i][j] > 65535.f * hig) {
str *= hig;
}
- if (viewmet == 0) {
- luminance[i][j] = clipretinex ( cd, 0.f, 32768.f ) * str + (1.f - str) * originalLuminance[i][j];
- }
-
- if (viewmet == 1) {
+ if(viewmet == 0) {
+ luminance[i][j] = intp(str, clipretinex( cd, 0.f, 32768.f ), originalLuminance[i][j]);
+ } else if(viewmet == 1) {
luminance[i][j] = out[i][j];
- }
-
- if (viewmet == 4) {
- luminance[i][j] = (1.f + str) * originalLuminance[i][j] - str * out[i][j]; //unsharp
- }
-
- if (viewmet == 2) {
- if (tran[i][j] <= mean) {
+ } else if(viewmet == 4) {
+ luminance[i][j] = originalLuminance[i][j] + str * (originalLuminance[i][j] - out[i][j]);//unsharp
+ } else if(viewmet == 2) {
+ if(tran[i][j] <= mean) {
luminance[i][j] = azb + aza * tran[i][j]; //auto values
} else {
luminance[i][j] = bzb + bza * tran[i][j];
}
- }
-
- if (viewmet == 3) {
+ } else { /*if(viewmet == 3) */
luminance[i][j] = 1000.f + tran[i][j] * 700.f; //arbitrary values to help display log values which are between -20 to + 30 - usage values -4 + 5
}
@@ -823,23 +806,23 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float **
}
}
+
delete [] outBuffer;
- outBuffer = NULL;
+ outBuffer = nullptr;
//printf("cdmin=%f cdmax=%f\n",minCD, maxCD);
Tmean = mean;
Tsigma = stddv;
Tmin = mintr;
Tmax = maxtr;
-
- if (shcurve && it == 1) {
+ if (shcurve) {
delete shcurve;
+ shcurve = nullptr;
}
}
- if (viewmet == 3 || viewmet == 2) {
+ if(tranBuffer) {
delete [] tranBuffer;
- tranBuffer = NULL;
}
}
diff --git a/rtengine/jdatasrc.cc b/rtengine/jdatasrc.cc
index c8567387b..ff509301d 100644
--- a/rtengine/jdatasrc.cc
+++ b/rtengine/jdatasrc.cc
@@ -32,6 +32,8 @@
/* Expanded data source object for stdio input */
+namespace
+{
typedef struct {
struct jpeg_source_mgr pub; /* public fields */
@@ -44,6 +46,8 @@ typedef struct {
typedef my_source_mgr * my_src_ptr;
+}
+
#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
diff --git a/rtengine/jpeg_memsrc.cc b/rtengine/jpeg_memsrc.cc
index 75a0b25bc..ab4ecf7d6 100644
--- a/rtengine/jpeg_memsrc.cc
+++ b/rtengine/jpeg_memsrc.cc
@@ -26,6 +26,8 @@
/* Expanded data source object for memory input */
+namespace
+{
typedef struct {
struct jpeg_source_mgr pub; /* public fields */
@@ -36,6 +38,7 @@ typedef struct {
typedef my_source_mgr * my_src_ptr;
+}
/*
* Initialize source --- called by jpeg_read_header
diff --git a/rtengine/procevents.h b/rtengine/procevents.h
index 3d4f90af1..62d2a4ac1 100644
--- a/rtengine/procevents.h
+++ b/rtengine/procevents.h
@@ -467,6 +467,8 @@ enum ProcEvent {
EvRetinexmapcurve = 437,
EvviewMethod = 438,
EvcbdlMethod = 439,
+ EvRetinexgaintransmission = 440,
+ EvLskal = 441,
NUMOFEVENTS
};
diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc
index d3b12adcd..67b02a650 100644
--- a/rtengine/procparams.cc
+++ b/rtengine/procparams.cc
@@ -121,7 +121,7 @@ RetinexParams::RetinexParams ()
void RetinexParams::getDefaulttransmissionCurve(std::vector &curve)
{
- double v[12] = { 0.00, 0.34, 0.35, 0.35,
+ double v[12] = { 0.00, 0.50, 0.35, 0.35,
0.60, 0.75, 0.35, 0.35,
1.00, 0.50, 0.35, 0.35,
};
@@ -134,6 +134,23 @@ void RetinexParams::getDefaulttransmissionCurve(std::vector &curve)
curve.at(i) = v[i - 1];
}
}
+void RetinexParams::getDefaultgaintransmissionCurve(std::vector &curve)
+{
+ double v[16] = { 0.00, 0.1, 0.35, 0.00,
+ 0.25, 0.25, 0.35, 0.35,
+ 0.70, 0.25, 0.35, 0.35,
+ 1.00, 0.1, 0.00, 0.00
+ };
+
+
+ curve.resize(17);
+ curve.at(0 ) = double(FCT_MinMaxCPoints);
+
+ for (size_t i = 1; i < curve.size(); ++i) {
+ curve.at(i) = v[i - 1];
+ }
+}
+
void RetinexParams::setDefaults()
{
@@ -158,7 +175,7 @@ void RetinexParams::setDefaults()
radius = 40;
baselog = 2.71828;
-// grbl = 50;
+ skal = 3;
retinexMethod = "high";
mapMethod = "none";
viewMethod = "none";
@@ -173,13 +190,16 @@ void RetinexParams::setDefaults()
lhcurve.push_back(DCT_Linear);
mapcurve.clear();
mapcurve.push_back(DCT_Linear);
+ getDefaultgaintransmissionCurve(gaintransmissionCurve);
getDefaulttransmissionCurve(transmissionCurve);
}
-void RetinexParams::getCurves(RetinextransmissionCurve &transmissionCurveLUT) const
+void RetinexParams::getCurves(RetinextransmissionCurve &transmissionCurveLUT, RetinexgaintransmissionCurve &gaintransmissionCurveLUT) const
{
transmissionCurveLUT.Set(this->transmissionCurve);
+ gaintransmissionCurveLUT.Set(this->gaintransmissionCurve);
+
}
@@ -1521,9 +1541,9 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol
keyFile.set_double ("Retinex", "baselog", retinex.baselog);
}
-// if (!pedited || pedited->retinex.grbl) {
-// keyFile.set_integer ("Retinex", "grbl", retinex.grbl);
-// }
+ if (!pedited || pedited->retinex.skal) {
+ keyFile.set_integer ("Retinex", "skal", retinex.skal);
+ }
if (!pedited || pedited->retinex.retinexMethod) {
keyFile.set_string ("Retinex", "RetinexMethod", retinex.retinexMethod);
@@ -1590,6 +1610,11 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol
keyFile.set_double_list("Retinex", "TransmissionCurve", transmissionCurve);
}
+ if (!pedited || pedited->retinex.gaintransmissionCurve) {
+ Glib::ArrayHandle gaintransmissionCurve = retinex.gaintransmissionCurve;
+ keyFile.set_double_list("Retinex", "GainTransmissionCurve", gaintransmissionCurve);
+ }
+
// save channel mixer
if (!pedited || pedited->chmixer.red[0] || pedited->chmixer.red[1] || pedited->chmixer.red[2]) {
Glib::ArrayHandle rmix (chmixer.red, 3, Glib::OWNERSHIP_NONE);
@@ -4057,14 +4082,14 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
}
}
- /* if (keyFile.has_key ("Retinex", "grbl")) {
- retinex.grbl = keyFile.get_integer ("Retinex", "grbl");
+ if (keyFile.has_key ("Retinex", "skal")) {
+ retinex.skal = keyFile.get_integer ("Retinex", "skal");
+
+ if (pedited) {
+ pedited->retinex.skal = true;
+ }
+ }
- if (pedited) {
- pedited->retinex.grbl = true;
- }
- }
- */
if (keyFile.has_key ("Retinex", "CDCurve")) {
retinex.cdcurve = keyFile.get_double_list ("Retinex", "CDCurve");
@@ -4146,6 +4171,16 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
pedited->retinex.transmissionCurve = true;
}
}
+
+
+ if (keyFile.has_key ("Retinex", "GainTransmissionCurve")) {
+ retinex.gaintransmissionCurve = keyFile.get_double_list ("Retinex", "GainTransmissionCurve");
+
+ if (pedited) {
+ pedited->retinex.gaintransmissionCurve = true;
+ }
+ }
+
}
@@ -7551,6 +7586,7 @@ bool ProcParams::operator== (const ProcParams& other)
&& retinex.cdHcurve == other.retinex.cdHcurve
&& retinex.lhcurve == other.retinex.lhcurve
&& retinex.transmissionCurve == other.retinex.transmissionCurve
+ && retinex.gaintransmissionCurve == other.retinex.gaintransmissionCurve
&& retinex.str == other.retinex.str
&& retinex.scal == other.retinex.scal
&& retinex.iter == other.retinex.iter
@@ -7569,7 +7605,7 @@ bool ProcParams::operator== (const ProcParams& other)
&& retinex.radius == other.retinex.radius
&& retinex.baselog == other.retinex.baselog
-// && retinex.grbl == other.retinex.grbl
+ && retinex.skal == other.retinex.skal
&& retinex.offs == other.retinex.offs
&& retinex.retinexMethod == other.retinex.retinexMethod
&& retinex.mapMethod == other.retinex.mapMethod
diff --git a/rtengine/procparams.h b/rtengine/procparams.h
index 7946ce4d9..7f30f0cc9 100644
--- a/rtengine/procparams.h
+++ b/rtengine/procparams.h
@@ -41,6 +41,7 @@ class WavOpacityCurveBY;
class WavOpacityCurveW;
class WavOpacityCurveWL;
class RetinextransmissionCurve;
+class RetinexgaintransmissionCurve;
enum RenderingIntent {
RI_PERCEPTUAL = INTENT_PERCEPTUAL,
@@ -282,6 +283,7 @@ public:
std::vector cdHcurve;
std::vector lhcurve;
std::vector transmissionCurve;
+ std::vector gaintransmissionCurve;
std::vector mapcurve;
int str;
int scal;
@@ -308,11 +310,13 @@ public:
int limd;
int highl;
double baselog;
-// int grbl;
+ int skal;
bool medianmap;
RetinexParams ();
void setDefaults();
- void getCurves(RetinextransmissionCurve &transmissionCurveLUT) const;
+ void getCurves(RetinextransmissionCurve &transmissionCurveLUT, RetinexgaintransmissionCurve &gaintransmissionCurveLUT) const;
+
+ static void getDefaultgaintransmissionCurve(std::vector &curve);
static void getDefaulttransmissionCurve(std::vector &curve);
};
diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc
index 1a4e0dbb5..2780c033f 100644
--- a/rtengine/rawimagesource.cc
+++ b/rtengine/rawimagesource.cc
@@ -1764,7 +1764,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
LCPProfile *pLCPProf = lcpStore->getProfile(lensProf.lcpFile);
if (pLCPProf) { // don't check focal length to allow distortion correction for lenses without chip, also pass dummy focal length 1 in case of 0
- LCPMapper map(pLCPProf, max(idata->getFocalLen(),1.0), idata->getFocalLen35mm(), idata->getFocusDist(), idata->getFNumber(), true, false, W, H, coarse, -1);
+ LCPMapper map(pLCPProf, max(idata->getFocalLen(), 1.0), idata->getFocalLen35mm(), idata->getFocusDist(), idata->getFNumber(), true, false, W, H, coarse, -1);
#ifdef _OPENMP
#pragma omp parallel for
@@ -1970,7 +1970,6 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
LUTf *retinexgamtab;//gamma before and after Retinex to restore tones
LUTf lutTonereti;
- lutTonereti(65536);
if(retinexParams.gammaretinex == "low") {
retinexgamtab = &(Color::gammatab_115_2);
@@ -1986,24 +1985,33 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
double gamm2 = retinexParams.gam;
if(gamm2 < 1.) {
- pwr = 1. / pwr;
- gamm = 1. / gamm;
+ std::swap(pwr, gamm);
}
int mode = 0, imax = 0;
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope
// printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4);
+ double start;
+ double add;
+
+ if(gamm2 < 1.) {
+ start = g_a2;
+ add = g_a4;
+ } else {
+ start = g_a3;
+ add = g_a4;
+ }
+
+ double mul = 1. + g_a4;
+
+ lutTonereti(65536);
+
for (int i = 0; i < 65536; i++) {
double val = (i) / 65535.;
- double start = g_a3;
- double add = g_a4;
- double mul = 1. + g_a4;
double x;
if(gamm2 < 1.) {
- start = g_a2;
- add = g_a4;
x = Color::igammareti (val, gamm, start, ts, mul , add);
} else {
x = Color::gammareti (val, gamm, start, ts, mul , add);
@@ -2055,6 +2063,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
}
*/
if(retinexParams.gammaretinex != "none" && retinexParams.str != 0) {//gamma
+
#ifdef _OPENMP
#pragma omp parallel for
#endif
@@ -2083,7 +2092,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
if(lhist16RETI)
{
- lhist16RETIThr(32769, 0);
+ lhist16RETIThr(lhist16RETI.getSize());
lhist16RETIThr.clear();
}
@@ -2101,7 +2110,6 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
for (; j < W - border - 3; j += 4) {
vfloat H, S, L;
- int pos;
Color::rgb2hsl(LVFU(red[i][j]), LVFU(green[i][j]), LVFU(blue[i][j]), H, S, L);
STVFU(conversionBuffer[0][i - border][j - border], H);
STVFU(conversionBuffer[1][i - border][j - border], S);
@@ -2111,7 +2119,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
if(lhist16RETI) {
for(int p = 0; p < 4; p++) {
- pos = (int) clipretinex( conversionBuffer[2][i - border][j - border + p], 0.f, 32768.f);//histogram in curve HSL
+ int pos = ( conversionBuffer[2][i - border][j - border + p]);//histogram in curve HSL
lhist16RETIThr[pos]++;
}
}
@@ -2121,14 +2129,13 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
for (; j < W - border; j++) {
float H, S, L;
- int pos;
//rgb=>lab
Color::rgb2hslfloat(red[i][j], green[i][j], blue[i][j], conversionBuffer[0][i - border][j - border], conversionBuffer[1][i - border][j - border], L);
L *= 32768.f;
conversionBuffer[2][i - border][j - border] = L;
if(lhist16RETI) {
- pos = (int) clipretinex(L, 0, 32768);
+ int pos = L;
lhist16RETIThr[pos]++;
}
}
@@ -2139,10 +2146,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
{
if(lhist16RETI)
{
- // Add per Thread LUT to global LUT
- for(int i = 0; i < 32769; i++) {
- lhist16RETI[i] += lhist16RETIThr[i];
- }
+ lhist16RETI += lhist16RETIThr; // Add per Thread LUT to global LUT
}
}
#endif
@@ -2150,10 +2154,10 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
}
} else {
TMatrix wprof = iccStore->workingSpaceMatrix (cmp.working);
- 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]}
+ float wp[3][3] = {
+ {static_cast(wprof[0][0]), static_cast(wprof[0][1]), static_cast(wprof[0][2])},
+ {static_cast(wprof[1][0]), static_cast(wprof[1][1]), static_cast(wprof[1][2])},
+ {static_cast(wprof[2][0]), static_cast(wprof[2][1]), static_cast(wprof[2][2])}
};
// Conversion rgb -> lab is hard to vectorize because it uses a lut (that's not the main problem)
@@ -2166,25 +2170,19 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
LUTu lhist16RETIThr;
if(lhist16RETI) {
- lhist16RETIThr(32769, 0);
+ lhist16RETIThr(lhist16RETI.getSize());
lhist16RETIThr.clear();
}
#ifdef _OPENMP
- #pragma omp for
+ #pragma omp for schedule(dynamic,16)
#endif
for (int i = border; i < H - border; i++ )
for (int j = border; j < W - border; j++) {
float X, Y, Z, L, aa, bb;
- int pos;
- float R_, G_, B_;
- R_ = red[i][j];
- G_ = green[i][j];
- B_ = blue[i][j];
- float k;
//rgb=>lab
- Color::rgbxyz(R_, G_, B_, X, Y, Z, wp);
+ 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);
conversionBuffer[0][i - border][j - border] = aa;
@@ -2195,7 +2193,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
// if(R_>40000.f && G_ > 30000.f && B_ > 30000.f) conversionBuffer[3][i - border][j - border] = R_;
// else conversionBuffer[3][i - border][j - border] = 0.f;
if(lhist16RETI) {
- pos = (int) clipretinex(L, 0, 32768);
+ int pos = L;
lhist16RETIThr[pos]++;//histogram in Curve Lab
}
}
@@ -2204,10 +2202,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
#pragma omp critical
{
if(lhist16RETI) {
- // Add per Thread LUT to global LUT
- for(int i = 0; i < 32769; i++) {
- lhist16RETI[i] += lhist16RETIThr[i];
- }
+ lhist16RETI += lhist16RETIThr; // Add per Thread LUT to global LUT
}
}
#endif
@@ -2219,7 +2214,7 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, RetinexPar
}
-void RawImageSource::retinexPrepareCurves(RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI)
+void RawImageSource::retinexPrepareCurves(RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI)
{
useHsl = (retinexParams.retinexcolorspace == "HSLLOG" || retinexParams.retinexcolorspace == "HSLLIN");
@@ -2231,13 +2226,11 @@ void RawImageSource::retinexPrepareCurves(RetinexParams retinexParams, LUTf &cdc
CurveFactory::mapcurve (mapcontlutili, retinexParams.mapcurve, mapcurve, 1, lhist16RETI, histLRETI);
- retinexParams.getCurves(retinextransmissionCurve);
+ retinexParams.getCurves(retinextransmissionCurve, retinexgaintransmissionCurve);
}
-//void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI)
-void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI)
+void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI)
{
-
MyTime t4, t5;
t4.set();
@@ -2265,23 +2258,29 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
int mode = 0, imax = 0;
if(gamm2 < 1.) {
- pwr = 1. / pwr;
- gamm = 1. / gamm;
+ std::swap(pwr, gamm);
}
Color::calcGamma(pwr, ts, mode, imax, g_a0, g_a1, g_a2, g_a3, g_a4, g_a5); // call to calcGamma with selected gamma and slope
+ double mul = 1. + g_a4;
+ double add;
+ double start;
+
+ if(gamm2 < 1.) {
+ start = g_a3;
+ add = g_a3;
+ } else {
+ add = g_a4;
+ start = g_a2;
+ }
+
// printf("g_a0=%f g_a1=%f g_a2=%f g_a3=%f g_a4=%f\n", g_a0,g_a1,g_a2,g_a3,g_a4);
for (int i = 0; i < 65536; i++) {
double val = (i) / 65535.;
double x;
- double mul = 1. + g_a4;
- double add = g_a4;
- double start = g_a2;
if(gamm2 < 1.) {
- start = g_a3;
- add = g_a3;
x = Color::gammareti (val, gamm, start, ts, mul , add);
} else {
x = Color::igammareti (val, gamm, start, ts, mul , add);
@@ -2305,11 +2304,10 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
float val;
if(dehacontlutili && histLRETI) {
- hist16RET(32769, 0);
+ hist16RET(32768);
hist16RET.clear();
histLRETI.clear();
- dLcurve(32769, 0);
- dLcurve.clear();
+ dLcurve(32768);
}
FlatCurve* chcurve = NULL;//curve c=f(H)
@@ -2337,8 +2335,8 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
// one LUT per thread
LUTu hist16RETThr;
- if(dehacontlutili && histLRETI) {
- hist16RETThr(32769, 0);
+ if(hist16RET) {
+ hist16RETThr(hist16RET.getSize());
hist16RETThr.clear();
}
@@ -2352,7 +2350,7 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
LBuffer[i][j] = cdcurve[2.f * temp[i][j]] / 2.f;
if(histLRETI) {
- int pos = (int) clipretinex(LBuffer[i][j], 0.f, 32768.f);
+ int pos = LBuffer[i][j];
hist16RETThr[pos]++; //histogram in Curve
}
}
@@ -2365,29 +2363,29 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
#pragma omp critical
#endif
{
- if(dehacontlutili && histLRETI) {
- // Add per Thread LUT to global LUT
- for(int i = 0; i < 32769; i++) {
- hist16RET[i] += hist16RETThr[i];
- }
+ if(hist16RET) {
+ hist16RET += hist16RETThr; // Add per Thread LUT to global LUT
}
}
}
- if(dehacontlutili && histLRETI) {//update histogram
+ if(hist16RET) {//update histogram
+ // TODO : When rgbcurvesspeedup branch is merged into master, replace this by the following 1-liner
+ // hist16RET.compressTo(histLRETI);
+ // also remove declaration and init of dLcurve some lines above then and finally remove this comment :)
for (int i = 0; i < 32768; i++) {
val = (double)i / 32767.0;
- dLcurve[i] = CLIPD(val);
+ dLcurve[i] = val;
}
for (int i = 0; i < 32768; i++) {
float hval = dLcurve[i];
- int hi = (int)(255.0f * CLIPD(hval));
+ int hi = (int)(255.0f * hval);
histLRETI[hi] += hist16RET[i];
}
}
- MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], mapcurve, mapcontlutili, WNew, HNew, deh, dehatransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax);
+ MSR(LBuffer, conversionBuffer[2], conversionBuffer[3], mapcurve, mapcontlutili, WNew, HNew, deh, dehatransmissionCurve, dehagaintransmissionCurve, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax);
if(useHsl) {
if(chutili) {
@@ -2401,7 +2399,6 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
for (; j < W - border; j++) {
float valp;
- float chr;
// if(chutili) { // c=f(H)
{
valp = float((chcurve->getVal(conversionBuffer[3][i - border][j - border]) - 0.5f));
@@ -2450,46 +2447,113 @@ void RawImageSource::retinex(ColorManagementParams cmp, RetinexParams deh, ToneC
// gamut control only in Lab mode
const bool highlight = Tc.hrenabled;
#ifdef _OPENMP
- #pragma omp parallel for
+ #pragma omp parallel
+#endif
+ {
+#ifdef __SSE2__
+ // we need some line buffers to precalculate some expensive stuff using SSE
+ float atan2Buffer[W] ALIGNED16;
+ float sqrtBuffer[W] ALIGNED16;
+ float sincosxBuffer[W] ALIGNED16;
+ float sincosyBuffer[W] ALIGNED16;
+ const vfloat c327d68v = F2V(327.68);
+ const vfloat onev = F2V(1.f);
+#endif // __SSE2__
+#ifdef _OPENMP
+ #pragma omp for
#endif
- for (int i = border; i < H - border; i++ ) {
- for (int j = border; j < W - border; j++) {
+ for (int i = border; i < H - border; i++ ) {
+#ifdef __SSE2__
+ // vectorized precalculation
+ {
+ int j = border;
- float Lprov1 = (LBuffer[i - border][j - border]) / 327.68f;
- float Chprov1 = sqrt(SQR(conversionBuffer[0][i - border][j - border]) + SQR(conversionBuffer[1][i - border][j - border])) / 327.68f;
- float HH = xatan2f(conversionBuffer[1][i - border][j - border], conversionBuffer[0][i - border][j - border]);
- float2 sincosval;
- float valp;
- float chr;
-
- if(chutili) { // c=f(H)
+ for (; j < W - border - 3; j += 4)
{
- valp = float((chcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f));
- Chprov1 *= (1.f + 2.f * valp);
+ vfloat av = LVFU(conversionBuffer[0][i - border][j - border]);
+ vfloat bv = LVFU(conversionBuffer[1][i - border][j - border]);
+ vfloat chprovv = vsqrtf(SQRV(av) + SQRV(bv));
+ STVF(sqrtBuffer[j - border], chprovv / c327d68v);
+ vfloat HHv = xatan2f(bv, av);
+ STVF(atan2Buffer[j - border], HHv);
+ av /= chprovv;
+ bv /= chprovv;
+ vmask selMask = vmaskf_eq(chprovv, ZEROV);
+ STVF(sincosyBuffer[j - border], vself(selMask, onev, av));
+ STVF(sincosxBuffer[j - border], vselfnotzero(selMask, bv));
+ }
+
+ for (; j < W - border; j++)
+ {
+ float aa = conversionBuffer[0][i - border][j - border];
+ float bb = conversionBuffer[1][i - border][j - border];
+ float Chprov1 = sqrt(SQR(aa) + SQR(bb)) / 327.68f;
+ sqrtBuffer[j - border] = Chprov1;
+ float HH = xatan2f(bb, aa);
+ atan2Buffer[j - border] = HH;
+
+ if(Chprov1 == 0.0f) {
+ sincosyBuffer[j - border] = 1.f;
+ sincosxBuffer[j - border] = 0.0f;
+ } else {
+ sincosyBuffer[j - border] = aa / (Chprov1 * 327.68f);
+ sincosxBuffer[j - border] = bb / (Chprov1 * 327.68f);
+ }
}
}
+#endif // __SSE2__
+
+ for (int j = border; j < W - border; j++) {
+ float Lprov1 = (LBuffer[i - border][j - border]) / 327.68f;
+#ifdef __SSE2__
+ float Chprov1 = sqrtBuffer[j - border];
+ float HH = atan2Buffer[j - border];
+ float2 sincosval;
+ sincosval.x = sincosxBuffer[j - border];
+ sincosval.y = sincosyBuffer[j - border];
- sincosval = xsincosf(HH);
- float R, G, B;
-#ifdef _DEBUG
- bool neg = false;
- bool more_rgb = false;
- //gamut control : Lab values are in gamut
- Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb);
#else
- //gamut control : Lab values are in gamut
- Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f);
+ float aa = conversionBuffer[0][i - border][j - border];
+ float bb = conversionBuffer[1][i - border][j - border];
+ float Chprov1 = sqrt(SQR(aa) + SQR(bb)) / 327.68f;
+ float HH = xatan2f(bb, aa);
+ float2 sincosval;// = xsincosf(HH);
+
+ if(Chprov1 == 0.0f) {
+ sincosval.y = 1.f;
+ sincosval.x = 0.0f;
+ } else {
+ sincosval.y = aa / (Chprov1 * 327.68f);
+ sincosval.x = bb / (Chprov1 * 327.68f);
+ }
+
+#endif
+
+ if(chutili) { // c=f(H)
+ float valp = float((chcurve->getVal(Color::huelab_to_huehsv2(HH)) - 0.5f));
+ Chprov1 *= (1.f + 2.f * valp);
+ }
+
+ float R, G, B;
+#ifdef _DEBUG
+ bool neg = false;
+ bool more_rgb = false;
+ //gamut control : Lab values are in gamut
+ Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f, neg, more_rgb);
+#else
+ //gamut control : Lab values are in gamut
+ Color::gamutLchonly(HH, sincosval, Lprov1, Chprov1, R, G, B, wip, highlight, 0.15f, 0.96f);
#endif
- conversionBuffer[0][i - border][j - border] = 327.68f * Chprov1 * sincosval.y;
- conversionBuffer[1][i - border][j - border] = 327.68f * Chprov1 * sincosval.x;
- LBuffer[i - border][j - border] = Lprov1 * 327.68f;
+ conversionBuffer[0][i - border][j - border] = 327.68f * Chprov1 * sincosval.y;
+ conversionBuffer[1][i - border][j - border] = 327.68f * Chprov1 * sincosval.x;
+ LBuffer[i - border][j - border] = Lprov1 * 327.68f;
+ }
}
}
-
//end gamut control
#ifdef __SSE2__
vfloat wipv[3][3];
@@ -4300,12 +4364,12 @@ void RawImageSource::hlRecovery (std::string method, float* red, float* green, f
void RawImageSource::getAutoExpHistogram (LUTu & histogram, int& histcompr)
{
-BENCHFUN
+ BENCHFUN
histcompr = 3;
histogram(65536 >> histcompr);
histogram.clear();
- const float refwb[3] = {static_cast(refwb_red),static_cast(refwb_green),static_cast(refwb_blue)};
+ const float refwb[3] = {static_cast(refwb_red), static_cast(refwb_green), static_cast(refwb_blue)};
#ifdef _OPENMP
#pragma omp parallel
@@ -4323,11 +4387,11 @@ BENCHFUN
if (ri->getSensorType() == ST_BAYER) {
for (int j = start; j < end; j++) {
- tmphistogram[(int)(refwb[ri->FC(i,j)] * rawData[i][j]) >> histcompr] += 4;
+ tmphistogram[(int)(refwb[ri->FC(i, j)] * rawData[i][j]) >> histcompr] += 4;
}
} else if (ri->getSensorType() == ST_FUJI_XTRANS) {
for (int j = start; j < end; j++) {
- tmphistogram[(int)(refwb[ri->XTRANSFC(i,j)] * rawData[i][j]) >> histcompr] += 4;
+ tmphistogram[(int)(refwb[ri->XTRANSFC(i, j)] * rawData[i][j]) >> histcompr] += 4;
}
} else if (ri->get_colors() == 1) {
for (int j = start; j < end; j++) {
@@ -4354,7 +4418,7 @@ BENCHFUN
// Histogram MUST be 256 in size; gamma is applied, blackpoint and gain also
void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw)
{
-BENCHFUN
+ BENCHFUN
histRedRaw.clear();
histGreenRaw.clear();
histBlueRaw.clear();
@@ -4364,17 +4428,19 @@ BENCHFUN
65535.0f / ri->get_white(3)
};
- const bool fourColours = ri->getSensorType() == ST_BAYER && ((mult[1] != mult[3] || cblacksom[1] != cblacksom[3]) || FC(0,0) == 3 || FC(0,1) == 3 || FC(1,0) == 3 || FC(1,1) == 3);
+ const bool fourColours = ri->getSensorType() == ST_BAYER && ((mult[1] != mult[3] || cblacksom[1] != cblacksom[3]) || FC(0, 0) == 3 || FC(0, 1) == 3 || FC(1, 0) == 3 || FC(1, 1) == 3);
LUTu hist[4];
hist[0](65536);
hist[0].clear();
+
if (ri->get_colors() > 1) {
hist[1](65536);
hist[1].clear();
hist[2](65536);
hist[2].clear();
}
+
if (fourColours) {
hist[3](65536);
hist[3].clear();
@@ -4393,16 +4459,19 @@ BENCHFUN
LUTu tmphist[4];
tmphist[0](65536);
tmphist[0].clear();
+
if (ri->get_colors() > 1) {
tmphist[1](65536);
tmphist[1].clear();
tmphist[2](65536);
tmphist[2].clear();
+
if (fourColours) {
tmphist[3](65536);
tmphist[3].clear();
}
}
+
#ifdef _OPENMP
#pragma omp for nowait
#endif
@@ -4449,9 +4518,11 @@ BENCHFUN
#endif
{
hist[0] += tmphist[0];
+
if (ri->get_colors() > 1) {
hist[1] += tmphist[1];
hist[2] += tmphist[2];
+
if (fourColours) {
hist[3] += tmphist[3];
}
@@ -4463,13 +4534,16 @@ BENCHFUN
int idx;
idx = CLIP((int)Color::gamma(mult[0] * (i - (cblacksom[0]/*+black_lev[0]*/))));
histRedRaw[idx >> 8] += hist[0][i];
+
if (ri->get_colors() > 1) {
idx = CLIP((int)Color::gamma(mult[1] * (i - (cblacksom[1]/*+black_lev[1]*/))));
histGreenRaw[idx >> 8] += hist[1][i];
+
if (fourColours) {
idx = CLIP((int)Color::gamma(mult[3] * (i - (cblacksom[3]/*+black_lev[3]*/))));
histGreenRaw[idx >> 8] += hist[3][i];
}
+
idx = CLIP((int)Color::gamma(mult[2] * (i - (cblacksom[2]/*+black_lev[2]*/))));
histBlueRaw[idx >> 8] += hist[2][i];
}
@@ -4509,6 +4583,7 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm)
{
BENCHFUN
constexpr double clipHigh = 64000.0;
+
if (ri->get_colors() == 1) {
rm = gm = bm = 1;
return;
@@ -4588,6 +4663,7 @@ void RawImageSource::getAutoWBMultipliers (double &rm, double &gm, double &bm)
#ifdef _OPENMP
#pragma omp for schedule(dynamic,16) nowait
#endif
+
for (int i = 32; i < H - 32; i++) {
for (int j = 32; j < W - 32; j++) {
// each loop read 1 rgb triplet value
diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h
index 0dd6c9098..222735432 100644
--- a/rtengine/rawimagesource.h
+++ b/rtengine/rawimagesource.h
@@ -118,8 +118,8 @@ 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 retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI);
- void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI);
+ void retinex (ColorManagementParams cmp, RetinexParams deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D &conversionBuffer, bool dehacontlutili, bool mapcontlutili, bool useHsl, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax, LUTu &histLRETI);
+ void retinexPrepareCurves (RetinexParams retinexParams, LUTf &cdcurve, LUTf &mapcurve, RetinextransmissionCurve &retinextransmissionCurve, RetinexgaintransmissionCurve &retinexgaintransmissionCurve, bool &retinexcontlutili, bool &mapcontlutili, bool &useHsl, LUTu & lhist16RETI, LUTu & histLRETI);
void retinexPrepareBuffers (ColorManagementParams cmp, RetinexParams retinexParams, multi_array2D &conversionBuffer, LUTu &lhist16RETI);
void flushRawData ();
void flushRGB ();
@@ -196,7 +196,7 @@ public:
void boxblur2(float** src, float** dst, float** temp, int H, int W, int box );
void boxblur_resamp(float **src, float **dst, float** temp, int H, int W, int box, int samp );
- void MSR(float** luminance, float **originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax);
+ void MSR(float** luminance, float **originalLuminance, float **exLuminance, LUTf & mapcurve, bool &mapcontlutili, int width, int height, RetinexParams deh, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, float &minCD, float &maxCD, float &mini, float &maxi, float &Tmean, float &Tsigma, float &Tmin, float &Tmax);
void HLRecovery_inpaint (float** red, float** green, float** blue);
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]);
diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc
index 26e8f53d4..5175836e4 100644
--- a/rtengine/refreshmap.cc
+++ b/rtengine/refreshmap.cc
@@ -466,6 +466,9 @@ int refreshmap[rtengine::NUMOFEVENTS] = {
RETINEX, // EvmapMethod
DEMOSAIC, // EvRetinexmapcurve
DEMOSAIC, // EvviewMethod
- ALLNORAW // EvcbdlMethod
+ ALLNORAW, // EvcbdlMethod
+ RETINEX, // EvRetinexgaintransmission
+ RETINEX //EvLskal
+
};
diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc
index 1ec878c66..1f64a5ff4 100644
--- a/rtengine/simpleprocess.cc
+++ b/rtengine/simpleprocess.cc
@@ -40,7 +40,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
errorCode = 0;
- ProcessingJobImpl* job = static_cast (pjob);
+ ProcessingJobImpl* job = static_cast(pjob);
if (pl) {
pl->setProgressStr ("PROGRESSBAR_PROCESSING");
@@ -63,7 +63,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// acquire image from imagesource
ImageSource* imgsrc = ii->getImageSource ();
- int tr = getCoarseBitMask (params.coarse);
+ int tr = getCoarseBitMask(params.coarse);
int fw, fh;
imgsrc->getFullSize (fw, fh, tr);
@@ -102,13 +102,13 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
ImProcFunctions ipf (¶ms, true);
PreviewProps pp (0, 0, fw, fh, 1);
- imgsrc->preprocess ( params.raw, params.lensProf, params.coarse);
+ imgsrc->preprocess( params.raw, params.lensProf, params.coarse);
if (params.toneCurve.autoexp) {// this enabled HLRecovery
- LUTu histRedRaw (256), histGreenRaw (256), histBlueRaw (256);
- imgsrc->getRAWHistogram (histRedRaw, histGreenRaw, histBlueRaw);
+ LUTu histRedRaw(256), histGreenRaw(256), histBlueRaw(256);
+ imgsrc->getRAWHistogram(histRedRaw, histGreenRaw, histBlueRaw);
- if (ToneCurveParams::HLReconstructionNecessary (histRedRaw, histGreenRaw, histBlueRaw) && !params.toneCurve.hrenabled) {
+ if (ToneCurveParams::HLReconstructionNecessary(histRedRaw, histGreenRaw, histBlueRaw) && !params.toneCurve.hrenabled) {
params.toneCurve.hrenabled = true;
// WARNING: Highlight Reconstruction is being forced 'on', should we force a method here too?
}
@@ -118,33 +118,34 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
pl->setProgress (0.20);
}
- imgsrc->demosaic ( params.raw);
+ imgsrc->demosaic( params.raw);
if (pl) {
pl->setProgress (0.30);
}
- if (params.retinex.enabled) { //enabled Retinex
+ if(params.retinex.enabled) { //enabled Retinex
LUTf cdcurve (65536, 0);
LUTf mapcurve (65536, 0);
LUTu dummy;
RetinextransmissionCurve dehatransmissionCurve;
+ RetinexgaintransmissionCurve dehagaintransmissionCurve;
bool dehacontlutili = false;
bool mapcontlutili = false;
bool useHsl = false;
// multi_array2D conversionBuffer(1, 1);
- multi_array2D conversionBuffer (1, 1);
- imgsrc->retinexPrepareBuffers (params.icm, params.retinex, conversionBuffer, dummy);
- imgsrc->retinexPrepareCurves (params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehacontlutili, mapcontlutili, useHsl, dummy, dummy );
+ multi_array2D conversionBuffer(1, 1);
+ imgsrc->retinexPrepareBuffers(params.icm, params.retinex, conversionBuffer, dummy);
+ imgsrc->retinexPrepareCurves(params.retinex, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, dehacontlutili, mapcontlutili, useHsl, dummy, dummy );
float minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax;
- imgsrc->retinex ( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, dummy);
+ imgsrc->retinex( params.icm, params.retinex, params.toneCurve, cdcurve, mapcurve, dehatransmissionCurve, dehagaintransmissionCurve, conversionBuffer, dehacontlutili, mapcontlutili, useHsl, minCD, maxCD, mini, maxi, Tmean, Tsigma, Tmin, Tmax, dummy);
}
if (pl) {
pl->setProgress (0.40);
}
- imgsrc->HLRecovery_Global ( params.toneCurve );
+ imgsrc->HLRecovery_Global( params.toneCurve );
if (pl) {
@@ -158,25 +159,25 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
currWB = imgsrc->getWB ();
} else if (params.wb.method == "Auto") {
double rm, gm, bm;
- imgsrc->getAutoWBMultipliers (rm, gm, bm);
- currWB.update (rm, gm, bm, params.wb.equal);
+ imgsrc->getAutoWBMultipliers(rm, gm, bm);
+ currWB.update(rm, gm, bm, params.wb.equal);
}
NoiseCurve noiseLCurve;
NoiseCurve noiseCCurve;
Imagefloat *calclum = NULL ;
- params.dirpyrDenoise.getCurves (noiseLCurve, noiseCCurve);
+ params.dirpyrDenoise.getCurves(noiseLCurve, noiseCCurve);
float autoNR = (float) settings->nrauto;//
float autoNRmax = (float) settings->nrautomax;//
int tilesize;
int overlap;
- if (settings->leveldnti == 0) {
+ if(settings->leveldnti == 0) {
tilesize = 1024;
overlap = 128;
}
- if (settings->leveldnti == 1) {
+ if(settings->leveldnti == 1) {
tilesize = 768;
overlap = 96;
}
@@ -187,7 +188,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
ipf.Tile_calc (tilesize, overlap, 2, fw, fh, numtiles_W, numtiles_H, tilewidth, tileheight, tileWskip, tileHskip);
int nbtl = numtiles_W * numtiles_H;
- if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) {
+ if((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) {
nbtl = 9;
}
@@ -203,28 +204,28 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
float *pcsk = new float [nbtl];
// printf("expert=%d\n",settings->leveldnautsimpl);
- if (settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") {
+ if(settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") {
MyTime t1pone, t2pone;
t1pone.set();
int crW, crH;
- if (settings->leveldnv == 0) {
+ if(settings->leveldnv == 0) {
crW = 100;
crH = 100;
}
- if (settings->leveldnv == 1) {
+ if(settings->leveldnv == 1) {
crW = 250;
crH = 250;
}
- if (settings->leveldnv == 2) {
- crW = int (tileWskip / 2);
- crH = int (tileHskip / 2);
+ if(settings->leveldnv == 2) {
+ crW = int(tileWskip / 2);
+ crH = int(tileHskip / 2);
}
// if(settings->leveldnv ==2) {crW=int(tileWskip/2);crH=int(1.15f*(tileWskip/2));}//adapted to scale of preview
- if (settings->leveldnv == 3) {
+ if(settings->leveldnv == 3) {
crW = tileWskip - 10;
crH = tileHskip - 10;
}
@@ -232,7 +233,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
float lowdenoise = 1.f;
int levaut = settings->leveldnaut;
- if (levaut == 1) { //Standard
+ if(levaut == 1) { //Standard
lowdenoise = 0.7f;
}
@@ -241,9 +242,9 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// Imagefloat *origCropPart;//init auto noise
// origCropPart = new Imagefloat (crW, crH);//allocate memory
if (params.dirpyrDenoise.enabled) {//evaluate Noise
- LUTf gamcurve (65536, 0);
+ LUTf gamcurve(65536, 0);
float gam, gamthresh, gamslope;
- ipf.RGB_denoise_infoGamCurve (params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
+ ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
#pragma omp parallel
{
Imagefloat *origCropPart;//init auto noise
@@ -252,23 +253,23 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
int skipP = 1;
#pragma omp for schedule(dynamic) collapse(2) nowait
- for (int wcr = 0; wcr < numtiles_W; wcr++) {
- for (int hcr = 0; hcr < numtiles_H; hcr++) {
+ for(int wcr = 0; wcr < numtiles_W; wcr++) {
+ for(int hcr = 0; hcr < numtiles_H; hcr++) {
int beg_tileW = wcr * tileWskip + tileWskip / 2.f - crW / 2.f;
int beg_tileH = hcr * tileHskip + tileHskip / 2.f - crH / 2.f;
PreviewProps ppP (beg_tileW , beg_tileH, crW, crH, skipP);
imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw );
// we only need image reduced to 1/4 here
- for (int ii = 0; ii < crH; ii += 2) {
- for (int jj = 0; jj < crW; jj += 2) {
- provicalc->r (ii >> 1, jj >> 1) = origCropPart->r (ii, jj);
- provicalc->g (ii >> 1, jj >> 1) = origCropPart->g (ii, jj);
- provicalc->b (ii >> 1, jj >> 1) = origCropPart->b (ii, jj);
+ for(int ii = 0; ii < crH; ii += 2) {
+ for(int jj = 0; jj < crW; jj += 2) {
+ provicalc->r(ii >> 1, jj >> 1) = origCropPart->r(ii, jj);
+ provicalc->g(ii >> 1, jj >> 1) = origCropPart->g(ii, jj);
+ provicalc->b(ii >> 1, jj >> 1) = origCropPart->b(ii, jj);
}
}
- imgsrc->convertColorSpace (provicalc, params.icm, currWB); //for denoise luminance curve
+ imgsrc->convertColorSpace(provicalc, params.icm, currWB);//for denoise luminance curve
float maxr = 0.f;
float maxb = 0.f;
float pondcorrec = 1.0f;
@@ -281,7 +282,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
maxblueaut = 0.f;
chromina = 0.f;
sigma = 0.f;
- ipf.RGB_denoise_info (origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc);
+ ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc);
float multip = 1.f;
float adjustr = 1.f;
@@ -303,27 +304,27 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
adjustr = 1.f / 1.2f;
}
- if (!imgsrc->isRAW()) {
+ if(!imgsrc->isRAW()) {
multip = 2.f; //take into account gamma for TIF / JPG approximate value...not good fot gamma=1
}
- float maxmax = max (maxredaut, maxblueaut);
+ float maxmax = max(maxredaut, maxblueaut);
float delta;
int mode = 2;
int lissage = settings->leveldnliss;
ipf.calcautodn_info (chaut, delta, Nb, levaut, maxmax, lumema, chromina, mode, lissage, redyel, skinc, nsknc);
// printf("PROCESS cha=%f red=%f bl=%f redM=%f bluM=%f chrom=%f sigm=%f lum=%f sigL=%f\n",chaut,redaut,blueaut, maxredaut, maxblueaut, chromina, sigma, lumema, sigma_L);
- if (maxredaut > maxblueaut) {
+ if(maxredaut > maxblueaut) {
maxr = (delta) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f);
- if (minblueaut <= minredaut && minblueaut < chaut) {
+ if(minblueaut <= minredaut && minblueaut < chaut) {
maxb = (-chaut + minblueaut) / (autoNRmax * multip * adjustr * lowdenoise);
}
} else {
maxb = (delta) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f);
- if (minredaut <= minblueaut && minredaut < chaut) {
+ if(minredaut <= minblueaut && minredaut < chaut) {
maxr = (-chaut + minredaut) / (autoNRmax * multip * adjustr * lowdenoise);
}
}//maxb mxr - empirical evaluation red / blue
@@ -346,45 +347,45 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
int liss = settings->leveldnliss; //smooth result around mean
- if (liss == 2 || liss == 3) {
+ if(liss == 2 || liss == 3) {
// I smooth only mean and not delta (max)
float nchm = 0.f;
float koef = 0.4f; //between 0.1 to 0.9
- if (liss == 3) {
+ if(liss == 3) {
koef = 0.0f; //quasi auto for mean Ch
}
- for (int wcr = 0; wcr < numtiles_W; wcr++) {
- for (int hcr = 0; hcr < numtiles_H; hcr++) {
+ for(int wcr = 0; wcr < numtiles_W; wcr++) {
+ for(int hcr = 0; hcr < numtiles_H; hcr++) {
nchm += ch_M[hcr * numtiles_W + wcr];
}
}
nchm /= (numtiles_H * numtiles_W);
- for (int wcr = 0; wcr < numtiles_W; wcr++) {
- for (int hcr = 0; hcr < numtiles_H; hcr++) {
+ for(int wcr = 0; wcr < numtiles_W; wcr++) {
+ for(int hcr = 0; hcr < numtiles_H; hcr++) {
ch_M[hcr * numtiles_W + wcr] = nchm + (ch_M[hcr * numtiles_W + wcr] - nchm) * koef;
}
}
}
- if (liss == 3) { //same as auto but with much cells
+ if(liss == 3) { //same as auto but with much cells
float MaxR = 0.f;
float MaxB = 0.f;
float MaxRMoy = 0.f;
float MaxBMoy = 0.f;
- for (int k = 0; k < nbtl; k++) {
+ for(int k = 0; k < nbtl; k++) {
MaxBMoy += max_b[k];
MaxRMoy += max_r[k];
- if (max_r[k] > MaxR) {
+ if(max_r[k] > MaxR) {
MaxR = max_r[k];
}
- if (max_b[k] > MaxB) {
+ if(max_b[k] > MaxB) {
MaxB = max_b[k];
}
@@ -393,8 +394,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
MaxBMoy /= nbtl;
MaxRMoy /= nbtl;
- for (int k = 0; k < nbtl; k++) {
- if (MaxR > MaxB) {
+ for(int k = 0; k < nbtl; k++) {
+ if(MaxR > MaxB) {
max_r[k] = MaxRMoy + (MaxR - MaxRMoy) * 0.66f; //#std Dev
//max_b[k]=MinB;
max_b[k] = MaxBMoy + (MaxB - MaxBMoy) * 0.66f;
@@ -410,35 +411,35 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
if (settings->verbose) {
t2pone.set();
- printf ("Info denoise ponderated performed in %d usec:\n", t2pone.etime (t1pone));
+ printf("Info denoise ponderated performed in %d usec:\n", t2pone.etime(t1pone));
}
}
}
- if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) {
+ if((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) {
MyTime t1aue, t2aue;
t1aue.set();
int crW, crH;
- if (settings->leveldnv == 0) {
+ if(settings->leveldnv == 0) {
crW = 100;
crH = 100;
}
- if (settings->leveldnv == 1) {
+ if(settings->leveldnv == 1) {
crW = 250;
crH = 250;
}
- if (settings->leveldnv == 2) {
- crW = int (tileWskip / 2);
- crH = int (tileHskip / 2);
+ if(settings->leveldnv == 2) {
+ crW = int(tileWskip / 2);
+ crH = int(tileHskip / 2);
}
// if(settings->leveldnv ==2) {crW=int(tileWskip/2);crH=int(1.15f*(tileWskip/2));}//adapted to scale of preview
- if (settings->leveldnv == 3) {
+ if(settings->leveldnv == 3) {
crW = tileWskip - 10;
crH = tileHskip - 10;
}
@@ -446,14 +447,14 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
float lowdenoise = 1.f;
int levaut = settings->leveldnaut;
- if (levaut == 1) { //Standard
+ if(levaut == 1) { //Standard
lowdenoise = 0.7f;
}
if (params.dirpyrDenoise.enabled) {//evaluate Noise
- LUTf gamcurve (65536, 0);
+ LUTf gamcurve(65536, 0);
float gam, gamthresh, gamslope;
- ipf.RGB_denoise_infoGamCurve (params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
+ ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
int Nb[9];
int coordW[3];//coordonate of part of image to mesure noise
int coordH[3];
@@ -473,24 +474,24 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
#pragma omp for schedule(dynamic) collapse(2) nowait
- for (int wcr = 0; wcr <= 2; wcr++) {
- for (int hcr = 0; hcr <= 2; hcr++) {
+ for(int wcr = 0; wcr <= 2; wcr++) {
+ for(int hcr = 0; hcr <= 2; hcr++) {
PreviewProps ppP (coordW[wcr] , coordH[hcr], crW, crH, 1);
imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw);
// we only need image reduced to 1/4 here
- for (int ii = 0; ii < crH; ii += 2) {
- for (int jj = 0; jj < crW; jj += 2) {
- provicalc->r (ii >> 1, jj >> 1) = origCropPart->r (ii, jj);
- provicalc->g (ii >> 1, jj >> 1) = origCropPart->g (ii, jj);
- provicalc->b (ii >> 1, jj >> 1) = origCropPart->b (ii, jj);
+ for(int ii = 0; ii < crH; ii += 2) {
+ for(int jj = 0; jj < crW; jj += 2) {
+ provicalc->r(ii >> 1, jj >> 1) = origCropPart->r(ii, jj);
+ provicalc->g(ii >> 1, jj >> 1) = origCropPart->g(ii, jj);
+ provicalc->b(ii >> 1, jj >> 1) = origCropPart->b(ii, jj);
}
}
- imgsrc->convertColorSpace (provicalc, params.icm, currWB); //for denoise luminance curve
+ imgsrc->convertColorSpace(provicalc, params.icm, currWB);//for denoise luminance curve
int nb = 0;
float chaut = 0.f, redaut = 0.f, blueaut = 0.f, maxredaut = 0.f, maxblueaut = 0.f, minredaut = 0.f, minblueaut = 0.f, nresi = 0.f, highresi = 0.f, chromina = 0.f, sigma = 0.f, lumema = 0.f, sigma_L = 0.f, redyel = 0.f, skinc = 0.f, nsknc = 0.f;
- ipf.RGB_denoise_info (origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc);
+ ipf.RGB_denoise_info(origCropPart, provicalc, imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc);
Nb[hcr * 3 + wcr] = nb;
ch_M[hcr * 3 + wcr] = chaut;
max_r[hcr * 3 + wcr] = maxredaut;
@@ -544,7 +545,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
adjustr = 1.f / 1.2f;
}
- if (!imgsrc->isRAW()) {
+ if(!imgsrc->isRAW()) {
multip = 2.f; //take into account gamma for TIF / JPG approximate value...not good fot gamma=1
}
@@ -552,17 +553,17 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
int mode = 1;
int lissage = settings->leveldnliss;
- for (int k = 0; k < 9; k++) {
- float maxmax = max (max_r[k], max_b[k]);
+ for(int k = 0; k < 9; k++) {
+ float maxmax = max(max_r[k], max_b[k]);
ipf.calcautodn_info (ch_M[k], delta[k], Nb[k], levaut, maxmax, lumL[k], chromC[k], mode, lissage, ry[k], sk[k], pcsk[k] );
// printf("ch_M=%f delta=%f\n",ch_M[k], delta[k]);
}
- for (int k = 0; k < 9; k++) {
- if (max_r[k] > max_b[k]) {
+ for(int k = 0; k < 9; k++) {
+ if(max_r[k] > max_b[k]) {
//printf("R delta=%f koef=%f\n",delta[k],autoNRmax*multip*adjustr*lowdenoise);
Max_R[k] = (delta[k]) / ((autoNRmax * multip * adjustr * lowdenoise) / 2.f);
- Min_B[k] = - (ch_M[k] - min_b[k]) / (autoNRmax * multip * adjustr * lowdenoise);
+ Min_B[k] = -(ch_M[k] - min_b[k]) / (autoNRmax * multip * adjustr * lowdenoise);
Max_B[k] = 0.f;
Min_R[k] = 0.f;
} else {
@@ -574,7 +575,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
}
}
- for (int k = 0; k < 9; k++) {
+ for(int k = 0; k < 9; k++) {
// printf("ch_M= %f Max_R=%f Max_B=%f min_r=%f min_b=%f\n",ch_M[k],Max_R[k], Max_B[k],Min_R[k], Min_B[k]);
chM += ch_M[k];
MaxBMoy += Max_B[k];
@@ -582,19 +583,19 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
MinRMoy += Min_R[k];
MinBMoy += Min_B[k];
- if (Max_R[k] > MaxR) {
+ if(Max_R[k] > MaxR) {
MaxR = Max_R[k];
}
- if (Max_B[k] > MaxB) {
+ if(Max_B[k] > MaxB) {
MaxB = Max_B[k];
}
- if (Min_R[k] < MinR) {
+ if(Min_R[k] < MinR) {
MinR = Min_R[k];
}
- if (Min_B[k] < MinB) {
+ if(Min_B[k] < MinB) {
MinB = Min_B[k];
}
@@ -606,7 +607,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
MinBMoy /= 9;
MinRMoy /= 9;
- if (MaxR > MaxB) {
+ if(MaxR > MaxB) {
maxr = MaxRMoy + (MaxR - MaxRMoy) * 0.66f; //#std Dev
// maxb=MinB;
maxb = MinBMoy + (MinB - MinBMoy) * 0.66f;
@@ -627,7 +628,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
if (settings->verbose) {
t2aue.set();
- printf ("Info denoise auto performed in %d usec:\n", t2aue.etime (t1aue));
+ printf("Info denoise auto performed in %d usec:\n", t2aue.etime(t1aue));
}
//end evaluate noise
@@ -663,7 +664,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// at this stage, we can flush the raw data to free up quite an important amount of memory
// commented out because it makes the application crash when batch processing...
// TODO: find a better place to flush rawData and rawRGB
- if (flush) {
+ if(flush) {
imgsrc->flushRawData();
imgsrc->flushRGB();
}
@@ -678,13 +679,13 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise; // make a copy because we cheat here
- if (denoiseParams.Lmethod == "CUR") {
- if (noiseLCurve) {
+ if(denoiseParams.Lmethod == "CUR") {
+ if(noiseLCurve) {
denoiseParams.luma = 0.5f;
} else {
denoiseParams.luma = 0.0f;
}
- } else if (denoiseParams.Lmethod == "SLI") {
+ } else if(denoiseParams.Lmethod == "SLI") {
noiseLCurve.Reset();
}
@@ -693,15 +694,15 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
calclum = new Imagefloat ((fw + 1) / 2, (fh + 1) / 2); //for luminance denoise curve
#pragma omp parallel for
- for (int ii = 0; ii < fh; ii += 2) {
- for (int jj = 0; jj < fw; jj += 2) {
- calclum->r (ii >> 1, jj >> 1) = baseImg->r (ii, jj);
- calclum->g (ii >> 1, jj >> 1) = baseImg->g (ii, jj);
- calclum->b (ii >> 1, jj >> 1) = baseImg->b (ii, jj);
+ for(int ii = 0; ii < fh; ii += 2) {
+ for(int jj = 0; jj < fw; jj += 2) {
+ calclum->r(ii >> 1, jj >> 1) = baseImg->r(ii, jj);
+ calclum->g(ii >> 1, jj >> 1) = baseImg->g(ii, jj);
+ calclum->b(ii >> 1, jj >> 1) = baseImg->b(ii, jj);
}
}
- imgsrc->convertColorSpace (calclum, params.icm, currWB);
+ imgsrc->convertColorSpace(calclum, params.icm, currWB);
}
if (denoiseParams.enabled) {
@@ -710,7 +711,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// ipf.RGB_denoise(baseImg, baseImg, calclum, imgsrc->isRAW(), denoiseParams, params.defringe, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, lldenoiseutili);
float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi;
int kall = 2;
- ipf.RGB_denoise (kall, baseImg, baseImg, calclum, ch_M, max_r, max_b, imgsrc->isRAW(), denoiseParams, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi);
+ ipf.RGB_denoise(kall, baseImg, baseImg, calclum, ch_M, max_r, max_b, imgsrc->isRAW(), denoiseParams, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi);
}
@@ -726,7 +727,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
delete [] sk;
delete [] pcsk;
- imgsrc->convertColorSpace (baseImg, params.icm, currWB);
+ imgsrc->convertColorSpace(baseImg, params.icm, currWB);
// perform first analysis
LUTu hist16 (65536);
@@ -747,10 +748,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) {
const int W = baseImg->getWidth();
const int H = baseImg->getHeight();
- LabImage labcbdl (W, H);
- ipf.rgb2lab (*baseImg, labcbdl, params.icm.working);
+ LabImage labcbdl(W, H);
+ ipf.rgb2lab(*baseImg, labcbdl, params.icm.working);
ipf.dirpyrequalizer (&labcbdl, 1);
- ipf.lab2rgb (labcbdl, *baseImg, params.icm.working);
+ ipf.lab2rgb(labcbdl, *baseImg, params.icm.working);
}
// update blurmap
@@ -758,7 +759,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
if (params.sh.enabled) {
shmap = new SHMap (fw, fh, true);
- double radius = sqrt (double (fw * fw + fh * fh)) / 2.0;
+ double radius = sqrt (double(fw * fw + fh * fh)) / 2.0;
double shradius = params.sh.radius;
if (!params.sh.hq) {
@@ -775,7 +776,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
LUTf curve (65536, 0);
LUTf satcurve (65536, 0);
LUTf lhskcurve (65536, 0);
- LUTf lumacurve (65536, 0);
+ LUTf lumacurve(65536, 0);
LUTf clcurve (65536, 0);
LUTf clToningcurve (65536, 0);
LUTf cl2Toningcurve (65536, 0);
@@ -816,12 +817,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
{wiprof[2][0], wiprof[2][1], wiprof[2][2]}
};
bool opautili = false;
- params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili);
+ params.colorToning.getCurves(ctColorCurve, ctOpacityCurve, wp, wip, opautili);
bool clctoningutili = false;
- CurveFactory::curveToningCL (clctoningutili, params.colorToning.clcurve, clToningcurve, 1);
+ CurveFactory::curveToningCL(clctoningutili, params.colorToning.clcurve, clToningcurve, 1);
bool llctoningutili = false;
- CurveFactory::curveToningLL (llctoningutili, params.colorToning.cl2curve, cl2Toningcurve, 1);
+ CurveFactory::curveToningLL(llctoningutili, params.colorToning.cl2curve, cl2Toningcurve, 1);
LabImage* labView = new LabImage (fw, fh);
@@ -829,20 +830,20 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
CurveFactory::curveBW (params.blackwhite.beforeCurve, params.blackwhite.afterCurve, hist16, dummy, customToneCurvebw1, customToneCurvebw2, 1);
double rrm, ggm, bbm;
float autor, autog, autob;
- float satLimit = float (params.colorToning.satProtectionThreshold) / 100.f * 0.7f + 0.3f;
- float satLimitOpacity = 1.f - (float (params.colorToning.saturatedOpacity) / 100.f);
+ float satLimit = float(params.colorToning.satProtectionThreshold) / 100.f * 0.7f + 0.3f;
+ float satLimitOpacity = 1.f - (float(params.colorToning.saturatedOpacity) / 100.f);
- if (params.colorToning.enabled && params.colorToning.autosat) { //for colortoning evaluation of saturation settings
+ if(params.colorToning.enabled && params.colorToning.autosat) { //for colortoning evaluation of saturation settings
float moyS = 0.f;
float eqty = 0.f;
ipf.moyeqt (baseImg, moyS, eqty);//return image : mean saturation and standard dev of saturation
float satp = ((moyS + 1.5f * eqty) - 0.3f) / 0.7f; //1.5 sigma ==> 93% pixels with high saturation -0.3 / 0.7 convert to Hombre scale
- if (satp >= 0.92f) {
+ if(satp >= 0.92f) {
satp = 0.92f; //avoid values too high (out of gamut)
}
- if (satp <= 0.15f) {
+ if(satp <= 0.15f) {
satp = 0.15f; //avoid too low values
}
@@ -852,11 +853,11 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
}
autor = -9000.f; // This will ask to compute the "auto" values for the B&W tool (have to be inferior to -5000)
- DCPProfile *dcpProf = imgsrc->getDCP (params.icm, currWB);
+ DCPProfile *dcpProf = imgsrc->getDCP(params.icm, currWB);
ipf.rgbProc (baseImg, labView, NULL, curve1, curve2, curve, shmap, params.toneCurve.saturation, rCurve, gCurve, bCurve, satLimit , satLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, customToneCurvebw1, customToneCurvebw2, rrm, ggm, bbm, autor, autog, autob, expcomp, hlcompr, hlcomprthresh, dcpProf);
if (settings->verbose) {
- printf ("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", autor, autog, autob);
+ printf("Output image / Auto B&W coefs: R=%.2f G=%.2f B=%.2f\n", autor, autog, autob);
}
// if clut was used and size of clut cache == 1 we free the memory used by the clutstore (default clut cache size = 1 for 32 bit OS)
@@ -895,7 +896,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
hist16.clear();
hist16C.clear();
- if (params.labCurve.contrast != 0) { //only use hist16 for contrast
+ if(params.labCurve.contrast != 0) { //only use hist16 for contrast
#ifdef _OPENMP
#pragma omp parallel shared(hist16,labView, fh, fw)
@@ -910,12 +911,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
for (int i = 0; i < fh; i++)
for (int j = 0; j < fw; j++)
{
- hist16thr[CLIP ((int) ((labView->L[i][j])))]++;
+ hist16thr[CLIP((int)((labView->L[i][j])))]++;
}
#pragma omp critical
{
- for (int i = 0; i < 65536; i++)
+ for(int i = 0; i < 65536; i++)
{
hist16[i] += hist16thr[i];
}
@@ -933,7 +934,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
bool clcutili = false;
CurveFactory::complexLCurve (params.labCurve.brightness, params.labCurve.contrast, params.labCurve.lcurve, hist16, hist16, lumacurve, dummy, 1, utili);
- CurveFactory::curveCL (clcutili, params.labCurve.clcurve, clcurve, hist16C, dummy, 1);
+ CurveFactory::curveCL(clcutili, params.labCurve.clcurve, clcurve, hist16C, dummy, 1);
CurveFactory::complexsgnCurve (1.f, autili, butili, ccutili, cclutili, params.labCurve.chromaticity, params.labCurve.rstprotection,
params.labCurve.acurve, params.labCurve.bcurve, params.labCurve.cccurve, params.labCurve.lccurve, curve1, curve2, satcurve, lhskcurve,
@@ -943,34 +944,34 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
ipf.chromiLuminanceCurve (NULL, 1, labView, labView, curve1, curve2, satcurve, lhskcurve, clcurve, lumacurve, utili, autili, butili, ccutili, cclutili, clcutili, dummy, dummy, dummy, dummy);
- if ((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) {
- ipf.EPDToneMap (labView, 5, 1);
+ if((params.colorappearance.enabled && !params.colorappearance.tonecie) || (!params.colorappearance.enabled)) {
+ ipf.EPDToneMap(labView, 5, 1);
}
- ipf.vibrance (labView);
+ ipf.vibrance(labView);
- if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
+ if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
ipf.impulsedenoise (labView);
}
// for all treatments Defringe, Sharpening, Contrast detail ,Microcontrast they are activated if "CIECAM" function are disabled
- if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
+ if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
ipf.defringe (labView);
}
if (params.sharpenEdge.enabled) {
- ipf.MLsharpen (labView);
+ ipf.MLsharpen(labView);
}
if (params.sharpenMicro.enabled) {
- if ((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
+ if((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) {
ipf.MLmicrocontrast (labView); //!params.colorappearance.sharpcie
}
}
- if (((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) && params.sharpening.enabled) {
+ if(((params.colorappearance.enabled && !settings->autocielab) || (!params.colorappearance.enabled)) && params.sharpening.enabled) {
float **buffer = new float*[fh];
@@ -994,12 +995,12 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
WavOpacityCurveW waOpacityCurveW;
WavOpacityCurveWL waOpacityCurveWL;
- params.wavelet.getCurves (wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL );
+ params.wavelet.getCurves(wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL );
// directional pyramid wavelet
- if (params.dirpyrequalizer.cbdlMethod == "aft") {
- if ((params.colorappearance.enabled && !settings->autocielab) || !params.colorappearance.enabled) {
+ if(params.dirpyrequalizer.cbdlMethod == "aft") {
+ if((params.colorappearance.enabled && !settings->autocielab) || !params.colorappearance.enabled) {
ipf.dirpyrequalizer (labView, 1); //TODO: this is the luminance tonecurve, not the RGB one
}
}
@@ -1007,10 +1008,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
int kall = 2;
bool wavcontlutili = false;
- CurveFactory::curveWavContL (wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1);
+ CurveFactory::curveWavContL(wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1);
- if ((params.wavelet.enabled)) {
- ipf.ip_wavelet (labView, labView, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1);
+ if((params.wavelet.enabled)) {
+ ipf.ip_wavelet(labView, labView, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1);
}
wavCLVCurve.Reset();
@@ -1020,7 +1021,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
int f_w = 1, f_h = 1;
int begh = 0, endh = fh;
- if (params.colorappearance.tonecie || params.colorappearance.enabled) {
+ if(params.colorappearance.tonecie || params.colorappearance.enabled) {
f_w = fw;
f_h = fh;
}
@@ -1039,21 +1040,21 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
customColCurve3,
1);
- if (params.colorappearance.enabled) {
+ if(params.colorappearance.enabled) {
double adap;
float fnum = imgsrc->getMetaData()->getFNumber ();// F number
float fiso = imgsrc->getMetaData()->getISOSpeed () ;// ISO
float fspeed = imgsrc->getMetaData()->getShutterSpeed () ;//speed
float fcomp = imgsrc->getMetaData()->getExpComp ();//compensation + -
- if (fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) {
+ if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) {
adap = 2000.;
}//if no exif data or wrong
else {
float E_V = fcomp + log2 ((fnum * fnum) / fspeed / (fiso / 100.f));
E_V += params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV
- E_V += log2 (params.raw.expos); // exposure raw white point ; log2 ==> linear to EV
- adap = powf (2.f, E_V - 3.f); //cd / m2
+ E_V += log2(params.raw.expos);// exposure raw white point ; log2 ==> linear to EV
+ adap = powf(2.f, E_V - 3.f); //cd / m2
}
LUTf CAMBrightCurveJ;
@@ -1066,8 +1067,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
int sk = 1;
- if (settings->ciecamfloat) {
- ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, sk, 1);
+ if(settings->ciecamfloat) {
+ ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, sk, 1);
} else {
ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, 1, 1);
}
@@ -1077,8 +1078,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
double dd;
int sk = 1;
- if (settings->ciecamfloat) {
- ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, sk, 1);
+ if(settings->ciecamfloat) {
+ ipf.ciecam_02float (cieView, float(adap), begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, sk, 1);
} else {
ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, ¶ms, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, 1, 1);
}
@@ -1100,7 +1101,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
}
int imw, imh;
- double tmpScale = ipf.resizeScale (¶ms, fw, fh, imw, imh);
+ double tmpScale = ipf.resizeScale(¶ms, fw, fh, imw, imh);
bool labResize = params.resize.enabled && params.resize.method != "Nearest" && tmpScale != 1.0;
LabImage *tmplab;
@@ -1113,11 +1114,11 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
cw = params.crop.w;
ch = params.crop.h;
- if (labResize) { // crop lab data
- tmplab = new LabImage (cw, ch);
+ if(labResize) { // crop lab data
+ tmplab = new LabImage(cw, ch);
- for (int row = 0; row < ch; row++) {
- for (int col = 0; col < cw; col++) {
+ for(int row = 0; row < ch; row++) {
+ for(int col = 0; col < cw; col++) {
tmplab->L[row][col] = labView->L[row + cy][col + cx];
tmplab->a[row][col] = labView->a[row + cy][col + cx];
tmplab->b[row][col] = labView->b[row + cy][col + cx];
@@ -1133,16 +1134,16 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
if (labResize) { // resize lab data
// resize image
- tmplab = new LabImage (imw, imh);
+ tmplab = new LabImage(imw, imh);
ipf.Lanczos (labView, tmplab, tmpScale);
delete labView;
labView = tmplab;
cw = labView->W;
ch = labView->H;
- if (params.prsharpening.enabled) {
- for (int i = 0; i < ch; i++)
- for (int j = 0; j < cw; j++) {
+ if(params.prsharpening.enabled) {
+ for(int i = 0; i < ch; i++)
+ for(int j = 0; j < cw; j++) {
labView->L[i][j] = labView->L[i][j] < 0.f ? 0.f : labView->L[i][j];
}
@@ -1167,7 +1168,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
bool customGamma = false;
bool useLCMS = false;
- if (params.icm.gamma != "default" || params.icm.freegamma) { // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8
+ if(params.icm.gamma != "default" || params.icm.freegamma) { // if select gamma output between BT709, sRGB, linear, low, high, 2.2 , 1.8
cmsMLU *DescriptionMLU, *CopyrightMLU, *DmndMLU, *DmddMLU;// for modification TAG
cmsToneCurve* GammaTRC[3] = { NULL, NULL, NULL };
@@ -1190,34 +1191,34 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// some of them are actually provided by RT, thanks to Jacques Desmis
if (j == 0) {
chpro = options.rtSettings.prophoto;
- } else if (j == 1) {
+ } else if(j == 1) {
chpro = options.rtSettings.adobe;
- } else if (j == 2) {
+ } else if(j == 2) {
chpro = options.rtSettings.widegamut;
- } else if (j == 3) {
+ } else if(j == 3) {
chpro = options.rtSettings.beta;
- } else if (j == 4) {
+ } else if(j == 4) {
chpro = options.rtSettings.best;
- } else if (j == 5) {
+ } else if(j == 5) {
chpro = options.rtSettings.bruce;
- } else if (j == 6) {
+ } else if(j == 6) {
chpro = options.rtSettings.srgb;
- } else if (j == 7) {
+ } else if(j == 7) {
chpro = options.rtSettings.srgb10; //gamma 1.0
- } else if (j == 8) {
+ } else if(j == 8) {
chpro = options.rtSettings.prophoto10; //gamma 1.0
- } else if (j == 9) {
+ } else if(j == 9) {
chpro = options.rtSettings.rec2020;
}
for (unsigned int i = 0; i < opnames.size(); i++) {
- if (chpro.compare (opnames[i]) == 0) {
+ if(chpro.compare(opnames[i]) == 0) {
present_space[j] = true;
}
}
if (!present_space[j] && settings->verbose) {
- printf ("Missing file: %s\n", chpro.c_str());
+ printf("Missing file: %s\n", chpro.c_str());
}
}
@@ -1252,7 +1253,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
} else {
// Should not occurs
if (settings->verbose) {
- printf ("\"%s\": unknown working profile! - use LCMS2 substitution\n", params.icm.working.c_str() );
+ printf("\"%s\": unknown working profile! - use LCMS2 substitution\n", params.icm.working.c_str() );
}
useLCMS = true;
@@ -1262,16 +1263,16 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
//"jprof" profile has the same characteristics than RGB values, but TRC are adapted... for applying profile
if (!useLCMS) {
if (settings->verbose) {
- printf ("Output Gamma - profile: \"%s\"\n", outProfile.c_str() ); //c_str()
+ printf("Output Gamma - profile: \"%s\"\n", outProfile.c_str() ); //c_str()
}
- jprof = iccStore->getProfile (outProfile); //get output profile
+ jprof = iccStore->getProfile(outProfile); //get output profile
if (jprof == NULL) {
useLCMS = true;
if (settings->verbose) {
- printf ("\"%s\" ICC output profile not found!\n", outProfile.c_str());
+ printf("\"%s\" ICC output profile not found!\n", outProfile.c_str());
}
} else {
Parameters[0] = ga0;
@@ -1283,43 +1284,43 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
Parameters[6] = ga6;
// 7 parameters for smoother curves
//change desc Tag , to "free gamma", or "BT709", etc.
- cmsContext ContextID = cmsGetProfileContextID (jprof); //modification TAG
- DescriptionMLU = cmsMLUalloc (ContextID, 1);
- CopyrightMLU = cmsMLUalloc (ContextID, 1); //for ICC
- DmndMLU = cmsMLUalloc (ContextID, 1); //for ICC
- DmddMLU = cmsMLUalloc (ContextID, 1); // for ICC
+ cmsContext ContextID = cmsGetProfileContextID(jprof);//modification TAG
+ DescriptionMLU = cmsMLUalloc(ContextID, 1);
+ CopyrightMLU = cmsMLUalloc(ContextID, 1);//for ICC
+ DmndMLU = cmsMLUalloc(ContextID, 1); //for ICC
+ DmddMLU = cmsMLUalloc(ContextID, 1); // for ICC
// instruction with //ICC are used for generate icc profile
if (DescriptionMLU == NULL) {
- printf ("Description error\n");
+ printf("Description error\n");
}
- cmsMLUsetWide (CopyrightMLU, "en", "US", L"General Public License - AdobeRGB compatible") ; //adapt to profil
- cmsMLUsetWide (DmndMLU, "en", "US", L"RawTherapee") ;
- cmsMLUsetWide (DmddMLU, "en", "US", L"RTMedium") ; //adapt to profil
+ cmsMLUsetWide(CopyrightMLU, "en", "US", L"General Public License - AdobeRGB compatible") ;//adapt to profil
+ cmsMLUsetWide(DmndMLU, "en", "US", L"RawTherapee") ;
+ cmsMLUsetWide(DmddMLU, "en", "US", L"RTMedium") ; //adapt to profil
//display Tag desc with : selection of gamma and Primaries
if (!params.icm.freegamma) {
std::wstring gammaStr;
- if (params.icm.gamma == "High_g1.3_s3.35") {
- gammaStr = std::wstring (L"GammaTRC: High g=1.3 s=3.35");
+ if(params.icm.gamma == "High_g1.3_s3.35") {
+ gammaStr = std::wstring(L"GammaTRC: High g=1.3 s=3.35");
} else if (params.icm.gamma == "Low_g2.6_s6.9") {
- gammaStr = std::wstring (L"GammaTRC: Low g=2.6 s=6.9");
+ gammaStr = std::wstring(L"GammaTRC: Low g=2.6 s=6.9");
} else if (params.icm.gamma == "sRGB_g2.4_s12.92") {
- gammaStr = std::wstring (L"GammaTRC: sRGB g=2.4 s=12.92");
+ gammaStr = std::wstring(L"GammaTRC: sRGB g=2.4 s=12.92");
} else if (params.icm.gamma == "BT709_g2.2_s4.5") {
- gammaStr = std::wstring (L"GammaTRC: BT709 g=2.2 s=4.5");
+ gammaStr = std::wstring(L"GammaTRC: BT709 g=2.2 s=4.5");
} else if (params.icm.gamma == "linear_g1.0") {
- gammaStr = std::wstring (L"GammaTRC: Linear g=1.0");
+ gammaStr = std::wstring(L"GammaTRC: Linear g=1.0");
} else if (params.icm.gamma == "standard_g2.2") {
- gammaStr = std::wstring (L"GammaTRC: g=2.2");
+ gammaStr = std::wstring(L"GammaTRC: g=2.2");
} else if (params.icm.gamma == "standard_g1.8") {
- gammaStr = std::wstring (L"GammaTRC: g=1.8");
+ gammaStr = std::wstring(L"GammaTRC: g=1.8");
}
- cmsMLUsetWide (DescriptionMLU, "en", "US", gammaStr.c_str());
+ cmsMLUsetWide(DescriptionMLU, "en", "US", gammaStr.c_str());
//for elaboration ICC profiles
// else if (params.icm.gamma== "sRGB_g2.4_s12.92" && !params.icm.freegamma) cmsMLUsetWide(DescriptionMLU, "en", "US", L"RT_Medium gamma sRGB(AdobeRGB compatible)");
@@ -1332,21 +1333,21 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
} else {
// create description with gamma + slope + primaries
std::wostringstream gammaWs;
- gammaWs.precision (2);
+ gammaWs.precision(2);
gammaWs << "Manual GammaTRC: g=" << (float)params.icm.gampos << " s=" << (float)params.icm.slpos;
- cmsMLUsetWide (DescriptionMLU, "en", "US", gammaWs.str().c_str());
+ cmsMLUsetWide(DescriptionMLU, "en", "US", gammaWs.str().c_str());
}
- cmsWriteTag (jprof, cmsSigProfileDescriptionTag, DescriptionMLU); //desc changed
+ cmsWriteTag(jprof, cmsSigProfileDescriptionTag, DescriptionMLU);//desc changed
// cmsWriteTag(jprof, cmsSigCopyrightTag, CopyrightMLU);
// cmsWriteTag(jprof, cmsSigDeviceMfgDescTag, DmndMLU);
// cmsWriteTag(jprof, cmsSigDeviceModelDescTag, DmddMLU);
// Calculate output profile's rTRC bTRC gTRC
- GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve (NULL, 5, Parameters);
- cmsWriteTag (jprof, cmsSigGreenTRCTag, (void*)GammaTRC[1] );
- cmsWriteTag (jprof, cmsSigRedTRCTag, (void*)GammaTRC[0] );
- cmsWriteTag (jprof, cmsSigBlueTRCTag, (void*)GammaTRC[2] );
+ GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(NULL, 5, Parameters);
+ cmsWriteTag(jprof, cmsSigGreenTRCTag, (void*)GammaTRC[1] );
+ cmsWriteTag(jprof, cmsSigRedTRCTag, (void*)GammaTRC[0] );
+ cmsWriteTag(jprof, cmsSigBlueTRCTag, (void*)GammaTRC[2] );
//for generation ICC profiles : here Prophoto ==> Large
// if(params.icm.gamma== "BT709_g2.2_s4.5") cmsSaveProfileToFile(jprof, "RT_sRGB_gBT709.icm");
// else if (params.icm.gamma== "sRGB_g2.4_s12.92") cmsSaveProfileToFile(jprof, "RT_Medium_gsRGB.icc");
@@ -1357,7 +1358,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
}
if (GammaTRC[0]) {
- cmsFreeToneCurve (GammaTRC[0]);
+ cmsFreeToneCurve(GammaTRC[0]);
}
} else {
// if Default gamma mode: we use the profile selected in the "Output profile" combobox;
@@ -1366,14 +1367,14 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm.output, params.blackwhite.enabled);
bool bwonly = params.blackwhite.enabled && !params.colorToning.enabled ;
- if (autili || butili ) {
+ if(autili || butili ) {
bwonly = false;
}
readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm.output, params.icm.outputIntent, bwonly);
if (settings->verbose) {
- printf ("Output profile_: \"%s\"\n", params.icm.output.c_str());
+ printf("Output profile_: \"%s\"\n", params.icm.output.c_str());
}
}
@@ -1382,16 +1383,16 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
- if (!autili && !butili ) {
- if (params.blackwhite.enabled && !params.colorToning.enabled ) { //force BW r=g=b
+ if(!autili && !butili ) {
+ if(params.blackwhite.enabled && !params.colorToning.enabled ) {//force BW r=g=b
if (settings->verbose) {
- printf ("Force BW\n");
+ printf("Force BW\n");
}
for (int ccw = 0; ccw < cw; ccw++) {
for (int cch = 0; cch < ch; cch++) {
- readyImg->r (cch, ccw) = readyImg->g (cch, ccw);
- readyImg->b (cch, ccw) = readyImg->g (cch, ccw);
+ readyImg->r(cch, ccw) = readyImg->g(cch, ccw);
+ readyImg->b(cch, ccw) = readyImg->g(cch, ccw);
}
}
}
@@ -1419,7 +1420,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
if (customGamma) {
if (!useLCMS) {
// use corrected sRGB profile in order to apply a good TRC if present, otherwise use LCMS2 profile generated by lab2rgb16b
- ProfileContent pc (jprof);
+ ProfileContent pc(jprof);
readyImg->setOutputProfile (pc.data, pc.length);
}
} else {
@@ -1437,15 +1438,15 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
}*/
// if iccStore->getProfile send back an object, then iccStore->getContent will do too
- cmsHPROFILE jprof = iccStore->getProfile (outputProfile); //get outProfile
+ cmsHPROFILE jprof = iccStore->getProfile(outputProfile); //get outProfile
if (jprof == NULL) {
if (settings->verbose) {
- printf ("\"%s\" ICC output profile not found!\n - use LCMS2 substitution\n", outputProfile.c_str());
+ printf("\"%s\" ICC output profile not found!\n - use LCMS2 substitution\n", outputProfile.c_str());
}
} else {
if (settings->verbose) {
- printf ("Using \"%s\" output profile\n", outputProfile.c_str());
+ printf("Using \"%s\" output profile\n", outputProfile.c_str());
}
ProfileContent pc = iccStore->getContent (outputProfile);
@@ -1495,7 +1496,7 @@ void batchProcessingThread (ProcessingJob* job, BatchProcessingListener* bpl, bo
IImage16* img = processImage (currentJob, errorCode, bpl, tunnelMetaData, true);
if (errorCode) {
- bpl->error (M ("MAIN_MSG_CANNOTLOAD"));
+ bpl->error (M("MAIN_MSG_CANNOTLOAD"));
currentJob = NULL;
} else {
try {
@@ -1514,10 +1515,10 @@ void startBatchProcessing (ProcessingJob* job, BatchProcessingListener* bpl, boo
if (bpl)
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && defined( WIN32 ) && defined(__x86_64__)
// See Issue 2384 "Very bad response time on win7/64 using gcc 4.8 when queue is running"
- Glib::Thread::create (sigc::bind (sigc::ptr_fun (batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_NORMAL);
+ Glib::Thread::create(sigc::bind(sigc::ptr_fun(batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_NORMAL);
#else
- Glib::Thread::create (sigc::bind (sigc::ptr_fun (batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_LOW);
+ Glib::Thread::create(sigc::bind(sigc::ptr_fun(batchProcessingThread), job, bpl, tunnelMetaData), 0, true, true, Glib::THREAD_PRIORITY_LOW);
#endif
}
diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc
index 1ae650a5f..fba2ef059 100644
--- a/rtgui/paramsedited.cc
+++ b/rtgui/paramsedited.cc
@@ -73,9 +73,10 @@ void ParamsEdited::set (bool v)
retinex.limd = v;
retinex.highl = v;
retinex.baselog = v;
-// retinex.grbl = v;
+ retinex.skal = v;
retinex.medianmap = v;
retinex.transmissionCurve = v;
+ retinex.gaintransmissionCurve = v;
retinex.highlights = v;
retinex.htonalwidth = v;
retinex.shadows = v;
@@ -547,6 +548,7 @@ void ParamsEdited::initFrom (const std::vector
retinex.cdHcurve = retinex.cdHcurve && p.retinex.cdHcurve == other.retinex.cdHcurve;
retinex.lhcurve = retinex.lhcurve && p.retinex.lhcurve == other.retinex.lhcurve;
retinex.transmissionCurve = retinex.transmissionCurve && p.retinex.transmissionCurve == other.retinex.transmissionCurve;
+ retinex.gaintransmissionCurve = retinex.gaintransmissionCurve && p.retinex.gaintransmissionCurve == other.retinex.gaintransmissionCurve;
retinex.retinexMethod = retinex.retinexMethod && p.retinex.retinexMethod == other.retinex.retinexMethod;
retinex.mapMethod = retinex.mapMethod && p.retinex.mapMethod == other.retinex.mapMethod;
retinex.viewMethod = retinex.viewMethod && p.retinex.viewMethod == other.retinex.viewMethod;
@@ -566,7 +568,7 @@ void ParamsEdited::initFrom (const std::vector
retinex.limd = retinex.limd && p.retinex.limd == other.retinex.limd;
retinex.highl = retinex.highl && p.retinex.highl == other.retinex.highl;
retinex.baselog = retinex.baselog && p.retinex.baselog == other.retinex.baselog;
-// retinex.grbl = retinex.grbl && p.retinex.grbl == other.retinex.grbl;
+ retinex.skal = retinex.skal && p.retinex.skal == other.retinex.skal;
retinex.medianmap = retinex.medianmap && p.retinex.medianmap == other.retinex.medianmap;
retinex.highlights = retinex.highlights && p.retinex.highlights == other.retinex.highlights;
retinex.htonalwidth = retinex.htonalwidth && p.retinex.htonalwidth == other.retinex.htonalwidth;
@@ -1093,6 +1095,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
toEdit.retinex.transmissionCurve = mods.retinex.transmissionCurve;
}
+ if (retinex.gaintransmissionCurve) {
+ toEdit.retinex.gaintransmissionCurve = mods.retinex.gaintransmissionCurve;
+ }
+
if (retinex.retinexMethod) {
toEdit.retinex.retinexMethod = mods.retinex.retinexMethod;
}
@@ -1165,9 +1171,9 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
toEdit.retinex.baselog = mods.retinex.baselog;
}
-// if (retinex.grbl) {
-// toEdit.retinex.grbl = mods.retinex.grbl;
-// }
+ if (retinex.skal) {
+ toEdit.retinex.skal = mods.retinex.skal;
+ }
if (retinex.gain) {
toEdit.retinex.gain = dontforceSet && options.baBehav[ADDSET_RETI_GAIN] ? toEdit.retinex.gain + mods.retinex.gain : mods.retinex.gain;
diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h
index c2654047a..9bdfa779c 100644
--- a/rtgui/paramsedited.h
+++ b/rtgui/paramsedited.h
@@ -78,9 +78,10 @@ public:
bool limd;
bool highl;
bool baselog;
-// bool grbl;
+ bool skal;
bool method;
bool transmissionCurve;
+ bool gaintransmissionCurve;
bool cdcurve;
bool mapcurve;
bool cdHcurve;
diff --git a/rtgui/retinex.cc b/rtgui/retinex.cc
index 33ddc7070..625650b79 100644
--- a/rtgui/retinex.cc
+++ b/rtgui/retinex.cc
@@ -8,9 +8,9 @@
using namespace rtengine;
using namespace rtengine::procparams;
-Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL"), false, true)
+Retinex::Retinex () : FoldableToolPanel(this, "retinex", M("TP_RETINEX_LABEL"), false, true)
{
- CurveListener::setMulti (true);
+ CurveListener::setMulti(true);
std::vector milestones;
nextmin = 0.;
nextmax = 0.;
@@ -22,117 +22,123 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
nextmaxT = 0.;
Gtk::VBox * retinexVBox = Gtk::manage ( new Gtk::VBox());
- retinexVBox->set_spacing (2);
+ retinexVBox->set_border_width(4);
+ retinexVBox->set_spacing(2);
- Gtk::VBox * settingsVBox = Gtk::manage ( new ToolParamBlock());
+ Gtk::VBox * settingsVBox = Gtk::manage ( new Gtk::VBox());
+ settingsVBox->set_border_width(4);
+ settingsVBox->set_spacing(2);
dhbox = Gtk::manage (new Gtk::HBox ());
- labmdh = Gtk::manage (new Gtk::Label (M ("TP_RETINEX_METHOD") + ":"));
+ labmdh = Gtk::manage (new Gtk::Label (M("TP_RETINEX_METHOD") + ":"));
dhbox->pack_start (*labmdh, Gtk::PACK_SHRINK, 1);
retinexMethod = Gtk::manage (new MyComboBoxText ());
- retinexMethod->append (M ("TP_RETINEX_LOW"));
- retinexMethod->append (M ("TP_RETINEX_UNIFORM"));
- retinexMethod->append (M ("TP_RETINEX_HIGH"));
- retinexMethod->append (M ("TP_RETINEX_HIGHLIG"));
+ retinexMethod->append (M("TP_RETINEX_LOW"));
+ retinexMethod->append (M("TP_RETINEX_UNIFORM"));
+ retinexMethod->append (M("TP_RETINEX_HIGH"));
+ retinexMethod->append (M("TP_RETINEX_HIGHLIG"));
// retinexMethod->append (M("TP_RETINEX_HIGHLIGPLUS"));
- retinexMethod->set_active (0);
- retinexMethodConn = retinexMethod->signal_changed().connect ( sigc::mem_fun (*this, &Retinex::retinexMethodChanged) );
- retinexMethod->set_tooltip_markup (M ("TP_RETINEX_METHOD_TOOLTIP"));
+ retinexMethod->set_active(0);
+ retinexMethodConn = retinexMethod->signal_changed().connect ( sigc::mem_fun(*this, &Retinex::retinexMethodChanged) );
+ retinexMethod->set_tooltip_markup (M("TP_RETINEX_METHOD_TOOLTIP"));
retinexcolorspace = Gtk::manage (new MyComboBoxText ());
- retinexcolorspace->append (M ("TP_RETINEX_LABSPACE"));
- retinexcolorspace->append (M ("TP_RETINEX_HSLSPACE_LOG"));
- retinexcolorspace->append (M ("TP_RETINEX_HSLSPACE_LIN"));
- retinexcolorspace->set_active (0);
- retinexColorSpaceConn = retinexcolorspace->signal_changed().connect ( sigc::mem_fun (*this, &Retinex::retinexColorSpaceChanged) );
+ retinexcolorspace->append (M("TP_RETINEX_LABSPACE"));
+ retinexcolorspace->append (M("TP_RETINEX_HSLSPACE_LOG"));
+ retinexcolorspace->append (M("TP_RETINEX_HSLSPACE_LIN"));
+ retinexcolorspace->set_active(0);
+ retinexColorSpaceConn = retinexcolorspace->signal_changed().connect ( sigc::mem_fun(*this, &Retinex::retinexColorSpaceChanged) );
- dhbox->pack_start (*retinexMethod);
- dhbox->pack_start (*retinexcolorspace);
- retinexVBox->pack_start (*dhbox);
+ dhbox->pack_start(*retinexMethod);
+ dhbox->pack_start(*retinexcolorspace);
+ retinexVBox->pack_start(*dhbox);
+ Gtk::VBox *equalVBox = Gtk::manage (new Gtk::VBox());
+
+ equalFrame = Gtk::manage (new Gtk::Frame(M("TP_RETINEX_EQUAL")));
// Histogram equalizer Lab curve
- curveEditorGD = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_CONTEDIT_LAB"));
+ curveEditorGD = new CurveEditorGroup (options.lastRetinexDir, M("TP_RETINEX_CONTEDIT_LAB"));
curveEditorGD->setCurveListener (this);
- cdshape = static_cast (curveEditorGD->addCurve (CT_Diagonal, M ("TP_RETINEX_CURVEEDITOR_CD")));
- cdshape->setTooltip (M ("TP_RETINEX_CURVEEDITOR_CD_TOOLTIP"));
+ cdshape = static_cast(curveEditorGD->addCurve(CT_Diagonal, M("TP_RETINEX_CURVEEDITOR_CD")));
+ cdshape->setTooltip(M("TP_RETINEX_CURVEEDITOR_CD_TOOLTIP"));
std::vector milestones22;
- milestones22.push_back ( GradientMilestone (0., 0., 0., 0.) );
- milestones22.push_back ( GradientMilestone (1., 1., 1., 1.) );
- cdshape->setBottomBarBgGradient (milestones22);
- cdshape->setLeftBarBgGradient (milestones22);
+ milestones22.push_back( GradientMilestone(0., 0., 0., 0.) );
+ milestones22.push_back( GradientMilestone(1., 1., 1., 1.) );
+ cdshape->setBottomBarBgGradient(milestones22);
+ cdshape->setLeftBarBgGradient(milestones22);
curveEditorGD->curveListComplete();
// Histogram equalizer HSL curve
- curveEditorGDH = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_CONTEDIT_HSL"));
+ curveEditorGDH = new CurveEditorGroup (options.lastRetinexDir, M("TP_RETINEX_CONTEDIT_HSL"));
curveEditorGDH->setCurveListener (this);
- cdshapeH = static_cast (curveEditorGDH->addCurve (CT_Diagonal, M ("TP_RETINEX_CURVEEDITOR_CD")));
- cdshapeH->setTooltip (M ("TP_RETINEX_CURVEEDITOR_CD_TOOLTIP"));
+ cdshapeH = static_cast(curveEditorGDH->addCurve(CT_Diagonal, M("TP_RETINEX_CURVEEDITOR_CD")));
+ cdshapeH->setTooltip(M("TP_RETINEX_CURVEEDITOR_CD_TOOLTIP"));
std::vector milestones22H;
- milestones22H.push_back ( GradientMilestone (0., 0., 0., 0.) );
- milestones22H.push_back ( GradientMilestone (1., 1., 1., 1.) );
- cdshapeH->setBottomBarBgGradient (milestones22H);
- cdshapeH->setLeftBarBgGradient (milestones22H);
+ milestones22H.push_back( GradientMilestone(0., 0., 0., 0.) );
+ milestones22H.push_back( GradientMilestone(1., 1., 1., 1.) );
+ cdshapeH->setBottomBarBgGradient(milestones22H);
+ cdshapeH->setLeftBarBgGradient(milestones22H);
curveEditorGDH->curveListComplete();
- curveEditormap = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_CONTEDIT_MAP"));
+ curveEditormap = new CurveEditorGroup (options.lastRetinexDir, M("TP_RETINEX_CONTEDIT_MAP"));
curveEditormap->setCurveListener (this);
- mapshape = static_cast (curveEditormap->addCurve (CT_Diagonal, M ("TP_RETINEX_CURVEEDITOR_MAP")));
- mapshape->setTooltip (M ("TP_RETINEX_CURVEEDITOR_MAP_TOOLTIP"));
+ mapshape = static_cast(curveEditormap->addCurve(CT_Diagonal, M("TP_RETINEX_CURVEEDITOR_MAP")));
+ mapshape->setTooltip(M("TP_RETINEX_CURVEEDITOR_MAP_TOOLTIP"));
std::vector milestones222;
- milestones222.push_back ( GradientMilestone (0., 0., 0., 0.) );
- milestones222.push_back ( GradientMilestone (1., 1., 1., 1.) );
- mapshape->setBottomBarBgGradient (milestones222);
- mapshape->setLeftBarBgGradient (milestones222);
+ milestones222.push_back( GradientMilestone(0., 0., 0., 0.) );
+ milestones222.push_back( GradientMilestone(1., 1., 1., 1.) );
+ mapshape->setBottomBarBgGradient(milestones222);
+ mapshape->setLeftBarBgGradient(milestones222);
curveEditormap->curveListComplete();
// Transmission map curve
- transmissionCurveEditorG = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_TRANSMISSION"));
+ transmissionCurveEditorG = new CurveEditorGroup (options.lastRetinexDir, M("TP_RETINEX_TRANSMISSION"));
transmissionCurveEditorG->setCurveListener (this);
std::vector defaultCurve;
- rtengine::RetinexParams::getDefaulttransmissionCurve (defaultCurve);
- transmissionShape = static_cast (transmissionCurveEditorG->addCurve (CT_Flat, "", NULL, false));
- transmissionShape->setIdentityValue (0.);
- transmissionShape->setResetCurve (FlatCurveType (defaultCurve.at (0)), defaultCurve);
- transmissionShape->setBottomBarBgGradient (milestones);
- transmissionCurveEditorG->set_tooltip_markup (M ("TP_RETINEX_TRANSMISSION_TOOLTIP"));
+ rtengine::RetinexParams::getDefaulttransmissionCurve(defaultCurve);
+ transmissionShape = static_cast(transmissionCurveEditorG->addCurve(CT_Flat, "", NULL, false));
+ transmissionShape->setIdentityValue(0.);
+ transmissionShape->setResetCurve(FlatCurveType(defaultCurve.at(0)), defaultCurve);
+ transmissionShape->setBottomBarBgGradient(milestones);
+ transmissionCurveEditorG->set_tooltip_markup (M("TP_RETINEX_TRANSMISSION_TOOLTIP"));
transmissionCurveEditorG->curveListComplete();
gambox = Gtk::manage (new Gtk::HBox ());
- labgam = Gtk::manage (new Gtk::Label (M ("TP_RETINEX_GAMMA") + ":"));
+ labgam = Gtk::manage (new Gtk::Label (M("TP_RETINEX_GAMMA") + ":"));
gambox->pack_start (*labgam, Gtk::PACK_SHRINK, 1);
gammaretinex = Gtk::manage (new MyComboBoxText ());
- gammaretinex->append (M ("TP_RETINEX_GAMMA_NONE"));
- gammaretinex->append (M ("TP_RETINEX_GAMMA_LOW"));
- gammaretinex->append (M ("TP_RETINEX_GAMMA_MID"));
- gammaretinex->append (M ("TP_RETINEX_GAMMA_HIGH"));
- gammaretinex->append (M ("TP_RETINEX_GAMMA_FREE"));
- gammaretinex->set_active (0);
- gammaretinexConn = gammaretinex->signal_changed().connect ( sigc::mem_fun (*this, &Retinex::gammaretinexChanged) );
- gammaretinex->set_tooltip_markup (M ("TP_RETINEX_GAMMA_TOOLTIP"));
+ gammaretinex->append (M("TP_RETINEX_GAMMA_NONE"));
+ gammaretinex->append (M("TP_RETINEX_GAMMA_LOW"));
+ gammaretinex->append (M("TP_RETINEX_GAMMA_MID"));
+ gammaretinex->append (M("TP_RETINEX_GAMMA_HIGH"));
+ gammaretinex->append (M("TP_RETINEX_GAMMA_FREE"));
+ gammaretinex->set_active(0);
+ gammaretinexConn = gammaretinex->signal_changed().connect ( sigc::mem_fun(*this, &Retinex::gammaretinexChanged) );
+ gammaretinex->set_tooltip_markup (M("TP_RETINEX_GAMMA_TOOLTIP"));
- gam = Gtk::manage (new Adjuster (M ("TP_RETINEX_FREEGAMMA"), 0.6, 3.0, 0.01, 1.30));
- slope = Gtk::manage (new Adjuster (M ("TP_RETINEX_SLOPE"), 1., 20., 0.1, 3.));
+ gam = Gtk::manage (new Adjuster (M("TP_RETINEX_FREEGAMMA"), 0.6, 3.0, 0.01, 1.30));
+ slope = Gtk::manage (new Adjuster (M("TP_RETINEX_SLOPE"), 1., 20., 0.1, 3.));
- str = Gtk::manage (new Adjuster (M ("TP_RETINEX_STRENGTH"), 0, 100., 1., 20.));
- neigh = Gtk::manage (new Adjuster (M ("TP_RETINEX_NEIGHBOR"), 6, 100., 1., 80.));
- highl = Gtk::manage (new Adjuster (M ("TP_RETINEX_HIGHLIGHT"), 1, 20, 1, 4));
- highl->set_tooltip_markup (M ("TP_RETINEX_HIGHLIGHT_TOOLTIP"));
- vart = Gtk::manage (new Adjuster (M ("TP_RETINEX_VARIANCE"), 50, 500, 1, 200));
- vart->set_tooltip_markup (M ("TP_RETINEX_VARIANCE_TOOLTIP"));
+ str = Gtk::manage (new Adjuster (M("TP_RETINEX_STRENGTH"), 0, 100., 1., 20.));
+ neigh = Gtk::manage (new Adjuster (M("TP_RETINEX_NEIGHBOR"), 6, 100., 1., 80.));
+ highl = Gtk::manage (new Adjuster (M("TP_RETINEX_HIGHLIGHT"), 1, 20, 1, 4));
+ highl->set_tooltip_markup (M("TP_RETINEX_HIGHLIGHT_TOOLTIP"));
+ vart = Gtk::manage (new Adjuster (M("TP_RETINEX_VARIANCE"), 50, 500, 1, 200));
+ vart->set_tooltip_markup (M("TP_RETINEX_VARIANCE_TOOLTIP"));
- expsettings = new MyExpander (false, M ("TP_RETINEX_SETTINGS"));
- expsettings->signal_button_release_event().connect_notify ( sigc::bind ( sigc::mem_fun (this, &Retinex::foldAllButMe), expsettings) );
+ expsettings = new MyExpander (false, M("TP_RETINEX_SETTINGS"));
+ expsettings->signal_button_release_event().connect_notify( sigc::bind( sigc::mem_fun(this, &Retinex::foldAllButMe), expsettings) );
retinexVBox->pack_start (*str);
str->show ();
@@ -146,96 +152,113 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
retinexVBox->pack_start (*highl);
highl->show ();
- mMLabels = Gtk::manage (new Gtk::Label ("---", Gtk::ALIGN_CENTER));
- mMLabels->set_tooltip_markup (M ("TP_RETINEX_MLABEL_TOOLTIP"));
+ mMLabels = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER));
+ mMLabels->set_tooltip_markup (M("TP_RETINEX_MLABEL_TOOLTIP"));
- transLabels = Gtk::manage (new Gtk::Label ("---", Gtk::ALIGN_CENTER));
- transLabels->set_tooltip_markup (M ("TP_RETINEX_TLABEL_TOOLTIP"));
- transLabels2 = Gtk::manage (new Gtk::Label ("---", Gtk::ALIGN_CENTER));
+ transLabels = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER));
+ transLabels->set_tooltip_markup (M("TP_RETINEX_TLABEL_TOOLTIP"));
+ transLabels2 = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER));
- scal = Gtk::manage (new Adjuster (M ("TP_RETINEX_SCALES"), -1, 6., 1., 3.));
- iter = Gtk::manage (new Adjuster (M ("TP_RETINEX_ITER"), 1, 5., 1., 1.));
- grad = Gtk::manage (new Adjuster (M ("TP_RETINEX_GRAD"), -2., 2., 1., 1.));
- grads = Gtk::manage (new Adjuster (M ("TP_RETINEX_GRADS"), -2., 2., 1., 1.));
- gain = Gtk::manage (new Adjuster (M ("TP_RETINEX_GAIN"), 20, 200, 1, 50));
- offs = Gtk::manage (new Adjuster (M ("TP_RETINEX_OFFSET"), -10000, 10000, 1, 0));
+ scal = Gtk::manage (new Adjuster (M("TP_RETINEX_SCALES"), -1, 6., 1., 3.));
+ iter = Gtk::manage (new Adjuster (M("TP_RETINEX_ITER"), 1, 5., 1., 1.));
+ grad = Gtk::manage (new Adjuster (M("TP_RETINEX_GRAD"), -2., 2., 1., 1.));
+ grads = Gtk::manage (new Adjuster (M("TP_RETINEX_GRADS"), -2., 2., 1., 1.));
+ gain = Gtk::manage (new Adjuster (M("TP_RETINEX_GAIN"), 20, 200, 1, 50));
+ offs = Gtk::manage (new Adjuster (M("TP_RETINEX_OFFSET"), -1000, 5000, 1, 0));
// vart = Gtk::manage (new Adjuster (M("TP_RETINEX_VARIANCE"), 50, 500, 1, 125));
- limd = Gtk::manage (new Adjuster (M ("TP_RETINEX_THRESHOLD"), 2, 100, 1, 8));
- baselog = Gtk::manage (new Adjuster (M ("TP_RETINEX_BASELOG"), 1.1, 100., 0.001, 2.718));
-// grbl = Gtk::manage (new Adjuster (M("TP_RETINEX_HIGHLIGHT3"), 1, 100, 1, 50));
- gain->set_tooltip_markup (M ("TP_RETINEX_GAIN_TOOLTIP"));
- scal->set_tooltip_markup (M ("TP_RETINEX_SCALES_TOOLTIP"));
- iter->set_tooltip_markup (M ("TP_RETINEX_ITER_TOOLTIP"));
- grad->set_tooltip_markup (M ("TP_RETINEX_GRAD_TOOLTIP"));
- grads->set_tooltip_markup (M ("TP_RETINEX_GRADS_TOOLTIP"));
+ limd = Gtk::manage (new Adjuster (M("TP_RETINEX_THRESHOLD"), 2, 100, 1, 8));
+ baselog = Gtk::manage (new Adjuster (M("TP_RETINEX_BASELOG"), 1., 10., 1., 3.));
+ skal = Gtk::manage (new Adjuster (M("TP_RETINEX_SKAL"), 1, 8, 1, 3));
+ gain->set_tooltip_markup (M("TP_RETINEX_GAIN_TOOLTIP"));
+ scal->set_tooltip_markup (M("TP_RETINEX_SCALES_TOOLTIP"));
+ iter->set_tooltip_markup (M("TP_RETINEX_ITER_TOOLTIP"));
+ grad->set_tooltip_markup (M("TP_RETINEX_GRAD_TOOLTIP"));
+ grads->set_tooltip_markup (M("TP_RETINEX_GRADS_TOOLTIP"));
// vart->set_tooltip_markup (M("TP_RETINEX_VARIANCE_TOOLTIP"));
- limd->set_tooltip_markup (M ("TP_RETINEX_THRESHOLD_TOOLTIP"));
- baselog->set_tooltip_markup (M ("TP_RETINEX_BASELOG_TOOLTIP"));
+ limd->set_tooltip_markup (M("TP_RETINEX_THRESHOLD_TOOLTIP"));
+ baselog->set_tooltip_markup (M("TP_RETINEX_BASELOG_TOOLTIP"));
+
+ // Gain Transmission map curve
+ gaintransmissionCurve = new CurveEditorGroup (options.lastRetinexDir, M("TP_RETINEX_GAINTRANSMISSION"));
+ gaintransmissionCurve->setCurveListener (this);
+
+// std::vector defaultCurve;
+ rtengine::RetinexParams::getDefaultgaintransmissionCurve(defaultCurve);
+ gaintransmissionShape = static_cast(gaintransmissionCurve->addCurve(CT_Flat, "", NULL, false));
+ gaintransmissionShape->setIdentityValue(0.);
+ gaintransmissionShape->setResetCurve(FlatCurveType(defaultCurve.at(0)), defaultCurve);
+ gaintransmissionShape->setBottomBarBgGradient(milestones);
+ gaintransmissionCurve->set_tooltip_markup (M("TP_RETINEX_GAINTRANSMISSION_TOOLTIP"));
+
+ gaintransmissionCurve->curveListComplete();
+
Gtk::Frame *p1Frame;
- p1Frame = Gtk::manage (new Gtk::Frame (M ("TP_RETINEX_LABEL_MASK")) );
- p1Frame->set_label_align (0.025, 0.5);
+ p1Frame = Gtk::manage (new Gtk::Frame(M("TP_RETINEX_LABEL_MASK")) );
+ p1Frame->set_border_width(0);
+ p1Frame->set_label_align(0.025, 0.5);
Gtk::VBox *p1VBox;
p1VBox = Gtk::manage ( new Gtk::VBox());
- p1VBox->set_spacing (2);
+ p1VBox->set_border_width(4);
+ p1VBox->set_spacing(2);
mapbox = Gtk::manage (new Gtk::HBox ());
- labmap = Gtk::manage (new Gtk::Label (M ("TP_RETINEX_MAP") + ":"));
+ labmap = Gtk::manage (new Gtk::Label (M("TP_RETINEX_MAP") + ":"));
mapbox->pack_start (*labmap, Gtk::PACK_SHRINK, 1);
mapMethod = Gtk::manage (new MyComboBoxText ());
- mapMethod->append (M ("TP_RETINEX_MAP_NONE"));
- mapMethod->append (M ("TP_RETINEX_MAP_GAUS"));
- mapMethod->append (M ("TP_RETINEX_MAP_MAPP"));
- mapMethod->append (M ("TP_RETINEX_MAP_MAPT"));
- mapMethod->set_active (0);
- mapMethodConn = mapMethod->signal_changed().connect ( sigc::mem_fun (*this, &Retinex::mapMethodChanged) );
- mapMethod->set_tooltip_markup (M ("TP_RETINEX_MAP_METHOD_TOOLTIP"));
+ mapMethod->append (M("TP_RETINEX_MAP_NONE"));
+ mapMethod->append (M("TP_RETINEX_MAP_GAUS"));
+ mapMethod->append (M("TP_RETINEX_MAP_MAPP"));
+ mapMethod->append (M("TP_RETINEX_MAP_MAPT"));
+ mapMethod->set_active(0);
+ mapMethodConn = mapMethod->signal_changed().connect ( sigc::mem_fun(*this, &Retinex::mapMethodChanged) );
+ mapMethod->set_tooltip_markup (M("TP_RETINEX_MAP_METHOD_TOOLTIP"));
- highlights = Gtk::manage (new Adjuster (M ("TP_SHADOWSHLIGHTS_HIGHLIGHTS"), 0, 100, 1, 0));
- h_tonalwidth = Gtk::manage (new Adjuster (M ("TP_SHADOWSHLIGHTS_HLTONALW"), 10, 100, 1, 80));
- shadows = Gtk::manage (new Adjuster (M ("TP_SHADOWSHLIGHTS_SHADOWS"), 0, 100, 1, 0));
- s_tonalwidth = Gtk::manage (new Adjuster (M ("TP_SHADOWSHLIGHTS_SHTONALW"), 10, 100, 1, 80));
- radius = Gtk::manage (new Adjuster (M ("TP_SHADOWSHLIGHTS_RADIUS"), 5, 100, 1, 40));
+ highlights = Gtk::manage (new Adjuster (M("TP_SHADOWSHLIGHTS_HIGHLIGHTS"), 0, 100, 1, 0));
+ h_tonalwidth = Gtk::manage (new Adjuster (M("TP_SHADOWSHLIGHTS_HLTONALW"), 10, 100, 1, 80));
+ shadows = Gtk::manage (new Adjuster (M("TP_SHADOWSHLIGHTS_SHADOWS"), 0, 100, 1, 0));
+ s_tonalwidth = Gtk::manage (new Adjuster (M("TP_SHADOWSHLIGHTS_SHTONALW"), 10, 100, 1, 80));
+ radius = Gtk::manage (new Adjuster (M("TP_SHADOWSHLIGHTS_RADIUS"), 5, 100, 1, 40));
viewbox = Gtk::manage (new Gtk::HBox ());
- labview = Gtk::manage (new Gtk::Label (M ("TP_RETINEX_VIEW") + ":"));
+ labview = Gtk::manage (new Gtk::Label (M("TP_RETINEX_VIEW") + ":"));
viewbox->pack_start (*labview, Gtk::PACK_SHRINK, 1);
viewMethod = Gtk::manage (new MyComboBoxText ());
- viewMethod->append (M ("TP_RETINEX_VIEW_NONE"));
- viewMethod->append (M ("TP_RETINEX_VIEW_UNSHARP"));
- viewMethod->append (M ("TP_RETINEX_VIEW_MASK"));
- viewMethod->append (M ("TP_RETINEX_VIEW_TRAN"));
- viewMethod->append (M ("TP_RETINEX_VIEW_TRAN2"));
- viewMethod->set_active (0);
- viewMethodConn = viewMethod->signal_changed().connect ( sigc::mem_fun (*this, &Retinex::viewMethodChanged) );
- viewMethod->set_tooltip_markup (M ("TP_RETINEX_VIEW_METHOD_TOOLTIP"));
+ viewMethod->append (M("TP_RETINEX_VIEW_NONE"));
+ viewMethod->append (M("TP_RETINEX_VIEW_UNSHARP"));
+ viewMethod->append (M("TP_RETINEX_VIEW_MASK"));
+ viewMethod->append (M("TP_RETINEX_VIEW_TRAN"));
+ viewMethod->append (M("TP_RETINEX_VIEW_TRAN2"));
+ viewMethod->set_active(0);
+ viewMethodConn = viewMethod->signal_changed().connect ( sigc::mem_fun(*this, &Retinex::viewMethodChanged) );
+ viewMethod->set_tooltip_markup (M("TP_RETINEX_VIEW_METHOD_TOOLTIP"));
- curveEditorGH = new CurveEditorGroup (options.lastRetinexDir, M ("TP_RETINEX_CONTEDIT_LH"));
+ curveEditorGH = new CurveEditorGroup (options.lastRetinexDir, M("TP_RETINEX_CONTEDIT_LH"));
curveEditorGH->setCurveListener (this);
- lhshape = static_cast (curveEditorGH->addCurve (CT_Flat, M ("TP_RETINEX_CURVEEDITOR_LH")));
- lhshape->setTooltip (M ("TP_RETINEX_CURVEEDITOR_LH_TOOLTIP"));
- lhshape->setCurveColorProvider (this, 4);
+ lhshape = static_cast(curveEditorGH->addCurve(CT_Flat, M("TP_RETINEX_CURVEEDITOR_LH")));
+ lhshape->setTooltip(M("TP_RETINEX_CURVEEDITOR_LH_TOOLTIP"));
+ lhshape->setCurveColorProvider(this, 4);
milestones.clear();
for (int i = 0; i < 7; i++) {
float R, G, B;
- float x = float (i) * (1.0f / 6.0);
- Color::hsv2rgb01 (x, 0.5f, 0.5f, R, G, B);
- milestones.push_back ( GradientMilestone (double (x), double (R), double (G), double (B)) );
+ float x = float(i) * (1.0f / 6.0);
+ Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B);
+ milestones.push_back( GradientMilestone(double(x), double(R), double(G), double(B)) );
}
- lhshape->setBottomBarBgGradient (milestones);
+ lhshape->setBottomBarBgGradient(milestones);
curveEditorGH->curveListComplete();
- medianmap = Gtk::manage (new Gtk::CheckButton (M ("TP_RETINEX_MEDIAN")));
+ medianmap = Gtk::manage (new Gtk::CheckButton (M("TP_RETINEX_MEDIAN")));
medianmap->set_active (true);
- medianmapConn = medianmap->signal_toggled().connect ( sigc::mem_fun (*this, &Retinex::medianmapChanged) );
+ medianmapConn = medianmap->signal_toggled().connect( sigc::mem_fun(*this, &Retinex::medianmapChanged) );
settingsVBox->pack_start (*mMLabels);
mMLabels->show ();
@@ -246,61 +269,90 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
settingsVBox->pack_start (*transLabels2);
transLabels2->show ();
- settingsVBox->pack_start (*curveEditorGD, Gtk::PACK_SHRINK, 4);
+ equalVBox->pack_start (*curveEditorGD, Gtk::PACK_SHRINK, 4);
curveEditorGD->show();
- settingsVBox->pack_start (*curveEditorGDH, Gtk::PACK_SHRINK, 4);
+ equalVBox->pack_start (*curveEditorGDH, Gtk::PACK_SHRINK, 4);
curveEditorGDH->show();
- settingsVBox->pack_start (*curveEditorGH, Gtk::PACK_SHRINK, 4);
+ equalVBox->pack_start (*curveEditorGH, Gtk::PACK_SHRINK, 4);
curveEditorGH->show();
- gambox->pack_start (*gammaretinex);
+ gambox->pack_start(*gammaretinex);
- settingsVBox->pack_start (*gambox);
+ equalVBox->pack_start(*gambox);
gammaretinex->show();
- settingsVBox->pack_start (*gam);
+ equalVBox->pack_start (*gam);
gam->show ();
- settingsVBox->pack_start (*slope);
+ equalVBox->pack_start (*slope);
slope->show ();
+ equalFrame->add(*equalVBox);
+ settingsVBox->pack_start (*equalFrame);
- settingsVBox->pack_start (*iter);
+
+ Gtk::VBox *iterVBox = Gtk::manage (new Gtk::VBox());
+
+ iterFrame = Gtk::manage (new Gtk::Frame(M("TP_RETINEX_ITERF")));
+
+ iterVBox->pack_start (*iter);
iter->show ();
- settingsVBox->pack_start (*scal);
+ iterVBox->pack_start (*scal);
scal->show ();
- settingsVBox->pack_start (*grad);
+ iterVBox->pack_start (*grad);
grad->show ();
- settingsVBox->pack_start (*grads);
+ iterVBox->pack_start (*grads);
grads->show ();
- settingsVBox->pack_start (*gain);
- gain->show ();
+ iterFrame->add(*iterVBox);
+ settingsVBox->pack_start (*iterFrame);
- settingsVBox->pack_start (*offs);
- offs->show ();
+ Gtk::VBox *tranVBox = Gtk::manage (new Gtk::VBox());
-// settingsVBox->pack_start (*vart);
-// vart->show ();
+ tranFrame = Gtk::manage (new Gtk::Frame(M("TP_RETINEX_TRANF")));
- settingsVBox->pack_start (*limd);
+ tranVBox->pack_start( *transmissionCurveEditorG, Gtk::PACK_SHRINK, 2);
+ transmissionCurveEditorG->show();
+
+ tranVBox->pack_start (*skal);
+ skal->show ();
+
+ tranVBox->pack_start (*limd);
limd->show ();
- // settingsVBox->pack_start (*Gtk::manage (new Gtk::HSeparator()));
+ tranVBox->pack_start (*medianmap);
+ medianmap->show ();
- viewbox->pack_start (*viewMethod);
+ tranFrame->add(*tranVBox);
+ settingsVBox->pack_start (*tranFrame);
+
+ Gtk::VBox *gainBox = Gtk::manage (new Gtk::VBox());
+
+ Gtk::HSeparator *separator = Gtk::manage (new Gtk::HSeparator());
+ settingsVBox->pack_start(*separator, Gtk::PACK_SHRINK, 2);
+ gainFrame = Gtk::manage (new Gtk::Frame(M("TP_RETINEX_GAINOFFS")));
+
+ gainBox->pack_start( *gaintransmissionCurve, Gtk::PACK_SHRINK, 2);
+ gaintransmissionCurve->show();
+
+ gainBox->pack_start (*offs);
+ offs->show ();
+ gainFrame->add(*gainBox);
+ settingsVBox->pack_start (*gainFrame);
+
+ viewbox->pack_start(*viewMethod);
// settingsVBox->pack_start(*viewbox);
- retinexVBox->pack_start (*viewbox);
+ retinexVBox->pack_start(*viewbox);
//settingsVBox->pack_start (*viewMethod);
- mapbox->pack_start (*mapMethod);
+ mapbox->pack_start(*mapMethod);
// settingsVBox->pack_start(*mapbox);
- p1VBox->pack_start (*mapbox);
+ p1VBox->pack_start(*mapbox);
p1VBox->pack_start (*curveEditormap, Gtk::PACK_SHRINK, 4);
curveEditormap->show();
@@ -321,28 +373,22 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
// settingsVBox->pack_start (*highl);
// highl->show ();
-// settingsVBox->pack_start (*baselog);
-// baselog->show ();
+// settingsVBox->pack_start (*baselog);
+// baselog->show ();
-// settingsVBox->pack_start (*grbl);
-// grbl->show ();
// settingsVBox->pack_start (*Gtk::manage (new Gtk::HSeparator()));
- settingsVBox->pack_start ( *transmissionCurveEditorG, Gtk::PACK_SHRINK, 2);
- transmissionCurveEditorG->show();
- settingsVBox->pack_start (*medianmap);
- medianmap->show ();
- expsettings->add (*settingsVBox);
- expsettings->setLevel (2);
+ expsettings->add(*settingsVBox);
neutrHBox = Gtk::manage (new Gtk::HBox ());
+ neutrHBox->set_border_width (2);
- neutral = Gtk::manage (new Gtk::Button (M ("TP_RETINEX_NEUTRAL")));
+ neutral = Gtk::manage (new Gtk::Button (M("TP_RETINEX_NEUTRAL")));
RTImage *resetImg = Gtk::manage (new RTImage ("gtk-undo-ltr-small.png", "gtk-undo-rtl-small.png"));
- neutral->set_image (*resetImg);
- neutral->set_tooltip_text (M ("TP_RETINEX_NEUTRAL_TIP"));
- neutralconn = neutral->signal_pressed().connect ( sigc::mem_fun (*this, &Retinex::neutral_pressed) );
+ neutral->set_image(*resetImg);
+ neutral->set_tooltip_text (M("TP_RETINEX_NEUTRAL_TIP"));
+ neutralconn = neutral->signal_pressed().connect( sigc::mem_fun(*this, &Retinex::neutral_pressed) );
neutral->show();
neutrHBox->pack_start (*neutral);
@@ -463,14 +509,14 @@ Retinex::Retinex () : FoldableToolPanel (this, "retinex", M ("TP_RETINEX_LABEL")
s_tonalwidth->delay = 200;
}
- /* grbl->setAdjusterListener (this);
+ skal->setAdjusterListener (this);
+
+ if (skal->delay < 200) {
+ skal->delay = 200;
+ }
- if (grbl->delay < 200) {
- grbl->delay = 200;
- }
- */
pack_start (*retinexVBox);
- p1Frame->add (*p1VBox);
+ p1Frame->add(*p1VBox);
pack_start (*p1Frame, Gtk::PACK_EXPAND_WIDGET, 4);
pack_start (*expsettings);
@@ -489,37 +535,39 @@ Retinex::~Retinex()
delete curveEditorGD;
delete curveEditorGDH;
delete transmissionCurveEditorG;
+ delete gaintransmissionCurve;
delete curveEditorGH;
delete curveEditormap;
}
void Retinex::neutral_pressed ()
{
- neigh->resetValue (false);
- gain->resetValue (false);
- offs->resetValue (false);
- str->resetValue (false);
- scal->resetValue (false);
- iter->resetValue (false);
- grad->resetValue (false);
- grads->resetValue (false);
- vart->resetValue (false);
- limd->resetValue (false);
- highl->resetValue (false);
- baselog->resetValue (false);
- gam->resetValue (false);
- slope->resetValue (false);
- highlights->resetValue (false);
- h_tonalwidth->resetValue (false);
- shadows->resetValue (false);
- s_tonalwidth->resetValue (false);
- radius->resetValue (false);
- mapMethod->set_active (0);
- viewMethod->set_active (0);
- retinexMethod->set_active (2);
- retinexcolorspace->set_active (0);
- gammaretinex->set_active (0);
+ neigh->resetValue(false);
+ gain->resetValue(false);
+ offs->resetValue(false);
+ str->resetValue(false);
+ scal->resetValue(false);
+ iter->resetValue(false);
+ grad->resetValue(false);
+ grads->resetValue(false);
+ vart->resetValue(false);
+ limd->resetValue(false);
+ highl->resetValue(false);
+ baselog->resetValue(false);
+ gam->resetValue(false);
+ slope->resetValue(false);
+ highlights->resetValue(false);
+ h_tonalwidth->resetValue(false);
+ shadows->resetValue(false);
+ s_tonalwidth->resetValue(false);
+ radius->resetValue(false);
+ mapMethod->set_active(0);
+ viewMethod->set_active(0);
+ retinexMethod->set_active(2);
+ retinexcolorspace->set_active(0);
+ gammaretinex->set_active(0);
transmissionShape->reset();
+ gaintransmissionShape->reset();
cdshape->reset();
cdshapeH->reset();
lhshape->reset();
@@ -529,19 +577,19 @@ void Retinex::neutral_pressed ()
void Retinex::foldAllButMe (GdkEventButton* event, MyExpander *expander)
{
if (event->button == 3) {
- expsettings->set_expanded (expsettings == expander);
+ expsettings->set_expanded(expsettings == expander);
}
}
-void Retinex::writeOptions (std::vector &tpOpen)
+void Retinex::writeOptions(std::vector &tpOpen)
{
tpOpen.push_back (expsettings->get_expanded ());
}
-void Retinex::updateToolState (std::vector &tpOpen)
+void Retinex::updateToolState(std::vector &tpOpen)
{
- if (tpOpen.size() == 10) {
- expsettings->set_expanded (tpOpen.at (9));
+ if(tpOpen.size() == 10) {
+ expsettings->set_expanded(tpOpen.at(9));
}
}
@@ -552,7 +600,7 @@ void Retinex::updateToolState (std::vector &tpOpen)
int minmaxChangedUI (void* data)
{
GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected
- (static_cast (data))->minmaxComputed_ ();
+ (static_cast(data))->minmaxComputed_ ();
return 0;
}
@@ -587,10 +635,10 @@ void Retinex::updateLabel ()
nX = nextmin;
nY = nextmax;
{
- mMLabels->set_text (
- Glib::ustring::compose (M ("TP_RETINEX_MLABEL"),
- Glib::ustring::format (std::fixed, std::setprecision (0), nX),
- Glib::ustring::format (std::fixed, std::setprecision (0), nY))
+ mMLabels->set_text(
+ Glib::ustring::compose(M("TP_RETINEX_MLABEL"),
+ Glib::ustring::format(std::fixed, std::setprecision(0), nX),
+ Glib::ustring::format(std::fixed, std::setprecision(0), nY))
);
}
}
@@ -607,17 +655,17 @@ void Retinex::updateTrans ()
nB = nextmaxT;
nS = nextsigma;
{
- transLabels->set_text (
- Glib::ustring::compose (M ("TP_RETINEX_TLABEL"),
- Glib::ustring::format (std::fixed, std::setprecision (1), nm),
- Glib::ustring::format (std::fixed, std::setprecision (1), nM),
- Glib::ustring::format (std::fixed, std::setprecision (1), nZ),
- Glib::ustring::format (std::fixed, std::setprecision (1), nS))
+ transLabels->set_text(
+ Glib::ustring::compose(M("TP_RETINEX_TLABEL"),
+ Glib::ustring::format(std::fixed, std::setprecision(1), nm),
+ Glib::ustring::format(std::fixed, std::setprecision(1), nM),
+ Glib::ustring::format(std::fixed, std::setprecision(1), nZ),
+ Glib::ustring::format(std::fixed, std::setprecision(1), nS))
);
- transLabels2->set_text (
- Glib::ustring::compose (M ("TP_RETINEX_TLABEL2"),
- Glib::ustring::format (std::fixed, std::setprecision (1), nA),
- Glib::ustring::format (std::fixed, std::setprecision (1), nB))
+ transLabels2->set_text(
+ Glib::ustring::compose(M("TP_RETINEX_TLABEL2"),
+ Glib::ustring::format(std::fixed, std::setprecision(1), nA),
+ Glib::ustring::format(std::fixed, std::setprecision(1), nB))
);
@@ -630,11 +678,11 @@ void Retinex::updateTrans ()
void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
{
disableListener ();
- retinexMethodConn.block (true);
- retinexColorSpaceConn.block (true);
- gammaretinexConn.block (true);
- mapMethodConn.block (true);
- viewMethodConn.block (true);
+ retinexMethodConn.block(true);
+ retinexColorSpaceConn.block(true);
+ gammaretinexConn.block(true);
+ mapMethodConn.block(true);
+ viewMethodConn.block(true);
if (pedited) {
@@ -651,7 +699,7 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
limd->setEditedState (pedited->retinex.limd ? Edited : UnEdited);
highl->setEditedState (pedited->retinex.highl ? Edited : UnEdited);
baselog->setEditedState (pedited->retinex.baselog ? Edited : UnEdited);
-// grbl->setEditedState (pedited->retinex.grbl ? Edited : UnEdited);
+ skal->setEditedState (pedited->retinex.skal ? Edited : UnEdited);
set_inconsistent (multiImage && !pedited->retinex.enabled);
medianmap->set_inconsistent (!pedited->retinex.medianmap);
radius->setEditedState (pedited->retinex.radius ? Edited : UnEdited);
@@ -662,28 +710,29 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
if (!pedited->retinex.retinexMethod) {
- retinexMethod->set_active_text (M ("GENERAL_UNCHANGED"));
+ retinexMethod->set_active_text(M("GENERAL_UNCHANGED"));
}
if (!pedited->retinex.mapMethod) {
- mapMethod->set_active_text (M ("GENERAL_UNCHANGED"));
+ mapMethod->set_active_text(M("GENERAL_UNCHANGED"));
}
if (!pedited->retinex.viewMethod) {
- viewMethod->set_active_text (M ("GENERAL_UNCHANGED"));
+ viewMethod->set_active_text(M("GENERAL_UNCHANGED"));
}
if (!pedited->retinex.retinexcolorspace) {
- retinexcolorspace->set_active_text (M ("GENERAL_UNCHANGED"));
+ retinexcolorspace->set_active_text(M("GENERAL_UNCHANGED"));
}
if (!pedited->retinex.gammaretinex) {
- gammaretinex->set_active_text (M ("GENERAL_UNCHANGED"));
+ gammaretinex->set_active_text(M("GENERAL_UNCHANGED"));
}
cdshape->setUnChanged (!pedited->retinex.cdcurve);
cdshapeH->setUnChanged (!pedited->retinex.cdHcurve);
transmissionShape->setUnChanged (!pedited->retinex.transmissionCurve);
+ gaintransmissionShape->setUnChanged (!pedited->retinex.gaintransmissionCurve);
lhshape->setUnChanged (!pedited->retinex.lhcurve);
mapshape->setUnChanged (!pedited->retinex.mapcurve);
@@ -710,15 +759,16 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
shadows->setValue (pp->retinex.shadows);
s_tonalwidth->setValue (pp->retinex.stonalwidth);
-// grbl->setValue (pp->retinex.grbl);
- if (pp->retinex.iter == 1) {
- grad->set_sensitive (false);
- scal->set_sensitive (false);
- grads->set_sensitive (false);
+ skal->setValue (pp->retinex.skal);
+
+ if(pp->retinex.iter == 1) {
+ grad->set_sensitive(false);
+ scal->set_sensitive(false);
+ grads->set_sensitive(false);
} else {
- grad->set_sensitive (true);
- scal->set_sensitive (true);
- grads->set_sensitive (true);
+ grad->set_sensitive(true);
+ scal->set_sensitive(true);
+ grads->set_sensitive(true);
}
setEnabled (pp->retinex.enabled);
@@ -789,21 +839,22 @@ void Retinex::read (const ProcParams* pp, const ParamsEdited* pedited)
mapMethodChanged ();
viewMethodChanged ();
- medianmapConn.block (true);
+ medianmapConn.block(true);
medianmapChanged ();
- medianmapConn.block (false);
+ medianmapConn.block(false);
cdshape->setCurve (pp->retinex.cdcurve);
cdshapeH->setCurve (pp->retinex.cdHcurve);
lhshape->setCurve (pp->retinex.lhcurve);
mapshape->setCurve (pp->retinex.mapcurve);
- retinexMethodConn.block (false);
- retinexColorSpaceConn.block (false);
- gammaretinexConn.block (false);
- mapMethodConn.block (false);
- viewMethodConn.block (false);
+ retinexMethodConn.block(false);
+ retinexColorSpaceConn.block(false);
+ gammaretinexConn.block(false);
+ mapMethodConn.block(false);
+ viewMethodConn.block(false);
transmissionShape->setCurve (pp->retinex.transmissionCurve);
+ gaintransmissionShape->setCurve (pp->retinex.gaintransmissionCurve);
enableListener ();
@@ -828,12 +879,13 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
pp->retinex.limd = (int)limd->getValue ();
pp->retinex.highl = (int)highl->getValue ();
pp->retinex.baselog = baselog->getValue ();
-// pp->retinex.grbl = (int)grbl->getValue ();
+ pp->retinex.skal = (int)skal->getValue ();
pp->retinex.cdcurve = cdshape->getCurve ();
pp->retinex.lhcurve = lhshape->getCurve ();
pp->retinex.cdHcurve = cdshapeH->getCurve ();
pp->retinex.mapcurve = mapshape->getCurve ();
pp->retinex.transmissionCurve = transmissionShape->getCurve ();
+ pp->retinex.gaintransmissionCurve = gaintransmissionShape->getCurve ();
pp->retinex.enabled = getEnabled();
pp->retinex.medianmap = medianmap->get_active();
@@ -844,11 +896,11 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
pp->retinex.stonalwidth = (int)s_tonalwidth->getValue ();
if (pedited) {
- pedited->retinex.retinexMethod = retinexMethod->get_active_text() != M ("GENERAL_UNCHANGED");
- pedited->retinex.retinexcolorspace = retinexcolorspace->get_active_text() != M ("GENERAL_UNCHANGED");
- pedited->retinex.gammaretinex = gammaretinex->get_active_text() != M ("GENERAL_UNCHANGED");
- pedited->retinex.mapMethod = mapMethod->get_active_text() != M ("GENERAL_UNCHANGED");
- pedited->retinex.viewMethod = viewMethod->get_active_text() != M ("GENERAL_UNCHANGED");
+ pedited->retinex.retinexMethod = retinexMethod->get_active_text() != M("GENERAL_UNCHANGED");
+ pedited->retinex.retinexcolorspace = retinexcolorspace->get_active_text() != M("GENERAL_UNCHANGED");
+ pedited->retinex.gammaretinex = gammaretinex->get_active_text() != M("GENERAL_UNCHANGED");
+ pedited->retinex.mapMethod = mapMethod->get_active_text() != M("GENERAL_UNCHANGED");
+ pedited->retinex.viewMethod = viewMethod->get_active_text() != M("GENERAL_UNCHANGED");
//%%%%%%%%%%%%%%%%%%%%%%
pedited->retinex.str = str->getEditedState ();
@@ -865,10 +917,11 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
pedited->retinex.limd = limd->getEditedState ();
pedited->retinex.highl = highl->getEditedState ();
pedited->retinex.baselog = baselog->getEditedState ();
-// pedited->retinex.grbl = grbl->getEditedState ();
+ pedited->retinex.skal = skal->getEditedState ();
pedited->retinex.cdcurve = !cdshape->isUnChanged ();
pedited->retinex.cdHcurve = !cdshapeH->isUnChanged ();
pedited->retinex.transmissionCurve = !transmissionShape->isUnChanged ();
+ pedited->retinex.gaintransmissionCurve = !gaintransmissionShape->isUnChanged ();
pedited->retinex.mapcurve = !mapshape->isUnChanged ();
pedited->retinex.enabled = !get_inconsistent();
pedited->retinex.medianmap = !medianmap->get_inconsistent();
@@ -943,7 +996,7 @@ void Retinex::write (ProcParams* pp, ParamsEdited* pedited)
void Retinex::retinexMethodChanged()
{
- if (retinexMethod->get_active_row_number() == 3) {
+ if(retinexMethod->get_active_row_number() == 3) {
highl->show();
} else {
highl->hide();
@@ -959,14 +1012,14 @@ void Retinex::retinexMethodChanged()
void Retinex::mapMethodChanged()
{
- if (mapMethod->get_active_row_number() == 1 /*|| mapMethod->get_active_row_number() == 2*/) {
+ if(mapMethod->get_active_row_number() == 1 /*|| mapMethod->get_active_row_number() == 2*/) {
curveEditormap->show();
highlights->show();
h_tonalwidth->show();
shadows->show();
s_tonalwidth->show();
radius->show();
- } else if (mapMethod->get_active_row_number() == 2 || mapMethod->get_active_row_number() == 3) {
+ } else if(mapMethod->get_active_row_number() == 2 || mapMethod->get_active_row_number() == 3) {
curveEditormap->show();
highlights->show();
h_tonalwidth->show();
@@ -990,7 +1043,7 @@ void Retinex::mapMethodChanged()
void Retinex::viewMethodChanged()
{
- if (viewMethod->get_active_row_number() == 1 || viewMethod->get_active_row_number() == 2) {
+ if(viewMethod->get_active_row_number() == 1 || viewMethod->get_active_row_number() == 2) {
// vart->hide();
gain->hide();
offs->hide();
@@ -1002,7 +1055,7 @@ void Retinex::viewMethodChanged()
grad->hide();
grads->hide();
curveEditorGH->hide();
- } else if (viewMethod->get_active_row_number() == 3 || viewMethod->get_active_row_number() == 4) {
+ } else if(viewMethod->get_active_row_number() == 3 || viewMethod->get_active_row_number() == 4) {
gain->hide();
offs->hide();
transmissionCurveEditorG->show();
@@ -1036,15 +1089,15 @@ void Retinex::ColorSpaceUpdateUI ()
if (!batchMode) {
curveEditorGH->show();
- if (retinexcolorspace->get_active_row_number() == 0) {
+ if(retinexcolorspace->get_active_row_number() == 0) {
curveEditorGD->show();
curveEditorGDH->hide();
baselog->show();
- } else if (retinexcolorspace->get_active_row_number() == 1) {
+ } else if(retinexcolorspace->get_active_row_number() == 1) {
curveEditorGD->hide();
curveEditorGDH->show();
baselog->show();
- } else if (retinexcolorspace->get_active_row_number() == 2) {
+ } else if(retinexcolorspace->get_active_row_number() == 2) {
curveEditorGD->hide();
curveEditorGDH->show();
baselog->hide();
@@ -1065,10 +1118,10 @@ void Retinex::retinexColorSpaceChanged()
void Retinex::gammaretinexChanged()
{
if (!batchMode) {
- if (gammaretinex->get_active_row_number() == 4) {
+ if(gammaretinex->get_active_row_number() == 4) {
gam->show();
slope->show();
- } else if (gammaretinex->get_active_row_number() != 4) {
+ } else if(gammaretinex->get_active_row_number() != 4) {
gam->hide();
slope->hide();
}
@@ -1099,11 +1152,11 @@ void Retinex::medianmapChanged ()
if (listener) {
if (medianmap->get_active()) {
if (getEnabled()) {
- listener->panelChanged (EvRetinexmedianmap, M ("GENERAL_ENABLED"));
+ listener->panelChanged (EvRetinexmedianmap, M("GENERAL_ENABLED"));
}
} else {
if (getEnabled()) {
- listener->panelChanged (EvRetinexmedianmap, M ("GENERAL_DISABLED"));
+ listener->panelChanged (EvRetinexmedianmap, M("GENERAL_DISABLED"));
}
}
@@ -1126,7 +1179,7 @@ void Retinex::setDefaults (const ProcParams* defParams, const ParamsEdited* pedi
limd->setDefault (defParams->retinex.limd);
highl->setDefault (defParams->retinex.highl);
baselog->setDefault (defParams->retinex.baselog);
-// grbl->setDefault (defParams->retinex.grbl);
+ skal->setDefault (defParams->retinex.skal);
gam->setDefault (defParams->retinex.gam);
slope->setDefault (defParams->retinex.slope);
@@ -1149,7 +1202,7 @@ void Retinex::setDefaults (const ProcParams* defParams, const ParamsEdited* pedi
limd->setDefaultEditedState (pedited->retinex.limd ? Edited : UnEdited);
highl->setDefaultEditedState (pedited->retinex.highl ? Edited : UnEdited);
baselog->setDefaultEditedState (pedited->retinex.baselog ? Edited : UnEdited);
-// grbl->setDefaultEditedState (pedited->retinex.grbl ? Edited : UnEdited);
+ skal->setDefaultEditedState (pedited->retinex.skal ? Edited : UnEdited);
gam->setDefaultEditedState (pedited->retinex.gam ? Edited : UnEdited);
slope->setDefaultEditedState (pedited->retinex.slope ? Edited : UnEdited);
@@ -1167,7 +1220,7 @@ void Retinex::setDefaults (const ProcParams* defParams, const ParamsEdited* pedi
limd->setDefaultEditedState (Irrelevant);
highl->setDefaultEditedState (Irrelevant);
baselog->setDefaultEditedState (Irrelevant);
-// grbl->setDefaultEditedState (Irrelevant);
+ skal->setDefaultEditedState (Irrelevant);
str->setDefaultEditedState (Irrelevant);
scal->setDefaultEditedState (Irrelevant);
iter->setDefaultEditedState (Irrelevant);
@@ -1187,14 +1240,14 @@ void Retinex::setDefaults (const ProcParams* defParams, const ParamsEdited* pedi
void Retinex::setAdjusterBehavior (bool strAdd, bool neighAdd, bool limdAdd, bool gainAdd, bool offsAdd, bool vartAdd, bool gamAdd, bool slopeAdd)
{
- str->setAddMode (strAdd);
- neigh->setAddMode (neighAdd);
- limd->setAddMode (limdAdd);
- gain->setAddMode (gainAdd);
- offs->setAddMode (offsAdd);
- vart->setAddMode (vartAdd);
- gam->setAddMode (gamAdd);
- slope->setAddMode (slopeAdd);
+ str->setAddMode(strAdd);
+ neigh->setAddMode(neighAdd);
+ limd->setAddMode(limdAdd);
+ gain->setAddMode(gainAdd);
+ offs->setAddMode(offsAdd);
+ vart->setAddMode(vartAdd);
+ gam->setAddMode(gamAdd);
+ slope->setAddMode(slopeAdd);
}
@@ -1205,14 +1258,14 @@ void Retinex::adjusterChanged (Adjuster* a, double newval)
return;
}
- if (iter->getTextValue() > "1") {
- scal->set_sensitive (true);
- grad->set_sensitive (true);
- grads->set_sensitive (true);
+ if(iter->getTextValue() > "1") {
+ scal->set_sensitive(true);
+ grad->set_sensitive(true);
+ grads->set_sensitive(true);
} else {
- scal->set_sensitive (false);
- grad->set_sensitive (false);
- grads->set_sensitive (false);
+ scal->set_sensitive(false);
+ grad->set_sensitive(false);
+ grads->set_sensitive(false);
}
@@ -1240,8 +1293,8 @@ void Retinex::adjusterChanged (Adjuster* a, double newval)
listener->panelChanged (EvLhighl, highl->getTextValue());
} else if (a == baselog) {
listener->panelChanged (EvLbaselog, baselog->getTextValue());
-// } else if (a == grbl) {
-// listener->panelChanged (EvLgrbl, grbl->getTextValue());
+ } else if (a == skal) {
+ listener->panelChanged (EvLskal, skal->getTextValue());
} else if (a == gam) {
listener->panelChanged (EvLgam, gam->getTextValue());
} else if (a == slope) {
@@ -1269,6 +1322,7 @@ void Retinex::autoOpenCurve ()
cdshape->openIfNonlinear();
cdshapeH->openIfNonlinear();
transmissionShape->openIfNonlinear();
+ gaintransmissionShape->openIfNonlinear();
lhshape->openIfNonlinear();
mapshape->openIfNonlinear();
@@ -1279,15 +1333,17 @@ void Retinex::curveChanged (CurveEditor* ce)
{
if (listener && getEnabled()) {
if (ce == cdshape) {
- listener->panelChanged (EvLCDCurve, M ("HISTORY_CUSTOMCURVE"));
+ listener->panelChanged (EvLCDCurve, M("HISTORY_CUSTOMCURVE"));
} else if (ce == cdshapeH) {
- listener->panelChanged (EvLCDHCurve, M ("HISTORY_CUSTOMCURVE"));
+ listener->panelChanged (EvLCDHCurve, M("HISTORY_CUSTOMCURVE"));
} else if (ce == transmissionShape) {
- listener->panelChanged (EvRetinextransmission, M ("HISTORY_CUSTOMCURVE"));
+ listener->panelChanged (EvRetinextransmission, M("HISTORY_CUSTOMCURVE"));
+ } else if (ce == gaintransmissionShape) {
+ listener->panelChanged (EvRetinexgaintransmission, M("HISTORY_CUSTOMCURVE"));
} else if (ce == lhshape) {
- listener->panelChanged (EvRetinexlhcurve, M ("HISTORY_CUSTOMCURVE"));
+ listener->panelChanged (EvRetinexlhcurve, M("HISTORY_CUSTOMCURVE"));
} else if (ce == mapshape) {
- listener->panelChanged (EvRetinexmapcurve, M ("HISTORY_CUSTOMCURVE"));
+ listener->panelChanged (EvRetinexmapcurve, M("HISTORY_CUSTOMCURVE"));
}
}
}
@@ -1297,11 +1353,11 @@ void Retinex::enabledChanged ()
if (listener) {
if (get_inconsistent()) {
- listener->panelChanged (EvRetinexEnabled, M ("GENERAL_UNCHANGED"));
+ listener->panelChanged (EvRetinexEnabled, M("GENERAL_UNCHANGED"));
} else if (getEnabled()) {
- listener->panelChanged (EvRetinexEnabled, M ("GENERAL_ENABLED"));
+ listener->panelChanged (EvRetinexEnabled, M("GENERAL_ENABLED"));
} else {
- listener->panelChanged (EvRetinexEnabled, M ("GENERAL_DISABLED"));
+ listener->panelChanged (EvRetinexEnabled, M("GENERAL_DISABLED"));
}
}
}
@@ -1309,22 +1365,22 @@ void Retinex::enabledChanged ()
void Retinex::trimValues (rtengine::procparams::ProcParams* pp)
{
- str->trimValue (pp->retinex.str);
- scal->trimValue (pp->retinex.scal);
- iter->trimValue (pp->retinex.iter);
- grad->trimValue (pp->retinex.grad);
- grads->trimValue (pp->retinex.grads);
- neigh->trimValue (pp->retinex.neigh);
- gain->trimValue (pp->retinex.gain);
- offs->trimValue (pp->retinex.offs);
- vart->trimValue (pp->retinex.vart);
- limd->trimValue (pp->retinex.limd);
- highl->trimValue (pp->retinex.highl);
- baselog->trimValue (pp->retinex.baselog);
- gam->trimValue (pp->retinex.gam);
- slope->trimValue (pp->retinex.slope);
- highlights->trimValue (pp->retinex.highlights);
- shadows->trimValue (pp->retinex.shadows);
+ str->trimValue(pp->retinex.str);
+ scal->trimValue(pp->retinex.scal);
+ iter->trimValue(pp->retinex.iter);
+ grad->trimValue(pp->retinex.grad);
+ grads->trimValue(pp->retinex.grads);
+ neigh->trimValue(pp->retinex.neigh);
+ gain->trimValue(pp->retinex.gain);
+ offs->trimValue(pp->retinex.offs);
+ vart->trimValue(pp->retinex.vart);
+ limd->trimValue(pp->retinex.limd);
+ highl->trimValue(pp->retinex.highl);
+ baselog->trimValue(pp->retinex.baselog);
+ gam->trimValue(pp->retinex.gam);
+ slope->trimValue(pp->retinex.slope);
+ highlights->trimValue(pp->retinex.highlights);
+ shadows->trimValue(pp->retinex.shadows);
}
@@ -1346,24 +1402,24 @@ void Retinex::colorForValue (double valX, double valY, enum ColorCaller::ElemTyp
if (callerId == 1) { // ch - main curve
- Color::hsv2rgb01 (float (valX), float (valY), 0.5f, R, G, B);
+ Color::hsv2rgb01(float(valX), float(valY), 0.5f, R, G, B);
} else if (callerId == 2) { // cc - bottom bar
- float value = (1.f - 0.7f) * float (valX) + 0.7f;
+ float value = (1.f - 0.7f) * float(valX) + 0.7f;
// whole hue range
// Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before)
- Color::hsv2rgb01 (float (valY), float (valX), value, R, G, B);
+ Color::hsv2rgb01(float(valY), float(valX), value, R, G, B);
} else if (callerId == 3) { // lc - bottom bar
- float value = (1.f - 0.7f) * float (valX) + 0.7f;
+ float value = (1.f - 0.7f) * float(valX) + 0.7f;
// whole hue range
// Y axis / from 0.15 up to 0.75 (arbitrary values; was 0.45 before)
- Color::hsv2rgb01 (float (valY), float (valX), value, R, G, B);
+ Color::hsv2rgb01(float(valY), float(valX), value, R, G, B);
} else if (callerId == 4) { // LH - bottom bar
- Color::hsv2rgb01 (float (valX), 0.5f, float (valY), R, G, B);
+ Color::hsv2rgb01(float(valX), 0.5f, float(valY), R, G, B);
} else if (callerId == 5) { // HH - bottom bar
- float h = float ((valY - 0.5) * 0.3 + valX);
+ float h = float((valY - 0.5) * 0.3 + valX);
if (h > 1.0f) {
h -= 1.0f;
@@ -1371,12 +1427,12 @@ void Retinex::colorForValue (double valX, double valY, enum ColorCaller::ElemTyp
h += 1.0f;
}
- Color::hsv2rgb01 (h, 0.5f, 0.5f, R, G, B);
+ Color::hsv2rgb01(h, 0.5f, 0.5f, R, G, B);
}
- caller->ccRed = double (R);
- caller->ccGreen = double (G);
- caller->ccBlue = double (B);
+ caller->ccRed = double(R);
+ caller->ccGreen = double(G);
+ caller->ccBlue = double(B);
}
@@ -1405,10 +1461,11 @@ void Retinex::setBatchMode (bool batchMode)
shadows->showEditedCB ();
s_tonalwidth->showEditedCB ();
-// grbl->showEditedCB ();
+ skal->showEditedCB ();
curveEditorGD->setBatchMode (batchMode);
curveEditorGDH->setBatchMode (batchMode);
transmissionCurveEditorG->setBatchMode (batchMode);
+ gaintransmissionCurve->setBatchMode (batchMode);
curveEditorGH->setBatchMode (batchMode);
curveEditormap->setBatchMode (batchMode);
diff --git a/rtgui/retinex.h b/rtgui/retinex.h
index d24254757..064756a7b 100644
--- a/rtgui/retinex.h
+++ b/rtgui/retinex.h
@@ -35,7 +35,7 @@ protected:
Adjuster* limd;
Adjuster* highl;
Adjuster* baselog;
- Adjuster* grbl;
+ Adjuster* skal;
Adjuster* gam;
Adjuster* slope;
Adjuster* highlights;
@@ -76,15 +76,21 @@ protected:
Gtk::Label* mMLabels;
Gtk::Label* transLabels;
Gtk::Label* transLabels2;
+ Gtk::Frame *gainFrame;
+ Gtk::Frame *tranFrame;
+ Gtk::Frame *iterFrame;
+ Gtk::Frame *equalFrame;
DiagonalCurveEditor* cdshape;
DiagonalCurveEditor* cdshapeH;
DiagonalCurveEditor* mapshape;
CurveEditorGroup* transmissionCurveEditorG;
+ CurveEditorGroup* gaintransmissionCurve;
sigc::connection retinexMethodConn, neutralconn, mapMethodConn, viewMethodConn;
sigc::connection retinexColorSpaceConn;
sigc::connection gammaretinexConn;
FlatCurveEditor* transmissionShape;
+ FlatCurveEditor* gaintransmissionShape;
FlatCurveEditor* lhshape;
bool lastmedianmap;
sigc::connection medianmapConn;