diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index b6245fbce..6e1ddf8b4 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -29,6 +29,7 @@ #include "array2D.h" #include "boxblur.h" #include "cplx_wavelet_dec.h" +#include "color.h" #include "curves.h" #include "iccmatrices.h" #include "iccstore.h" diff --git a/rtengine/PF_correct_RT.cc b/rtengine/PF_correct_RT.cc index e1d6ef808..c851d3d09 100644 --- a/rtengine/PF_correct_RT.cc +++ b/rtengine/PF_correct_RT.cc @@ -30,6 +30,7 @@ #include "gauss.h" #include "improcfun.h" #include "cieimage.h" +#include "color.h" #include "curves.h" #include "labimage.h" #include "sleef.c" diff --git a/rtengine/ciecam02.h b/rtengine/ciecam02.h index 68252f2f6..5f5dd9bca 100644 --- a/rtengine/ciecam02.h +++ b/rtengine/ciecam02.h @@ -20,9 +20,14 @@ #include -#include "LUT.h" #include "opthelper.h" +template +class LUT; + +using LUTu = LUT; +using LUTf = LUT; + namespace rtengine { diff --git a/rtengine/curves.h b/rtengine/curves.h index 9c5a84eac..b8b72d0eb 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -25,13 +25,12 @@ #include #include "rt_math.h" -#include "color.h" #include "flatcurvetypes.h" #include "diagonalcurvetypes.h" #include "pipettebuffer.h" #include "noncopyable.h" #include "LUT.h" - +#include "sleef.c" #define CURVES_MIN_POLY_POINTS 1000 #include "rt_math.h" @@ -894,12 +893,6 @@ public: float *r, float *g, float *b) const; }; -class SatAndValueBlendingToneCurve : public ToneCurve -{ -public: - void Apply(float& r, float& g, float& b) const; -}; - class WeightedStdToneCurve : public ToneCurve { private: @@ -1269,43 +1262,6 @@ inline void WeightedStdToneCurve::BatchApply(const size_t start, const size_t en #endif } -// Tone curve modifying the value channel only, preserving hue and saturation -// values in 0xffff space -inline void SatAndValueBlendingToneCurve::Apply (float& ir, float& ig, float& ib) const -{ - - assert (lutToneCurve); - - float r = CLIP(ir); - float g = CLIP(ig); - float b = CLIP(ib); - - const float lum = (r + g + b) / 3.f; - const float newLum = lutToneCurve[lum]; - - if (newLum == lum) { - return; - } - - float h, s, v; - Color::rgb2hsvtc(r, g, b, h, s, v); - - float dV; - if (newLum > lum) { - // Linearly targeting Value = 1 and Saturation = 0 - const float coef = (newLum - lum) / (65535.f - lum); - dV = (1.f - v) * coef; - s *= 1.f - coef; - } else { - // Linearly targeting Value = 0 - const float coef = (newLum - lum) / lum ; - dV = v * coef; - } - Color::hsv2rgbdcp(h, s, v + dV, r, g, b); - - setUnlessOOG(ir, ig, ib, r, g, b); -} - } #undef CLIPI diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index d3ab1b3f1..11fe306b8 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -28,6 +28,7 @@ #include "dcp.h" #include "cJSON.h" +#include "color.h" #include "iccmatrices.h" #include "iccstore.h" #include "imagefloat.h" diff --git a/rtengine/dirpyr_equalizer.cc b/rtengine/dirpyr_equalizer.cc index 6fd4f002c..1f62badcb 100644 --- a/rtengine/dirpyr_equalizer.cc +++ b/rtengine/dirpyr_equalizer.cc @@ -24,7 +24,9 @@ #include "array2D.h" #include "cieimage.h" +#include "color.h" #include "improcfun.h" +#include "LUT.h" #include "opthelper.h" #include "rt_math.h" #include "settings.h" diff --git a/rtengine/dual_demosaic_RT.cc b/rtengine/dual_demosaic_RT.cc index 8a3564279..b5839ee8b 100644 --- a/rtengine/dual_demosaic_RT.cc +++ b/rtengine/dual_demosaic_RT.cc @@ -23,6 +23,7 @@ // //////////////////////////////////////////////////////////////// +#include "color.h" #include "jaggedarray.h" #include "procparams.h" #include "rawimagesource.h" diff --git a/rtengine/filmnegativeproc.cc b/rtengine/filmnegativeproc.cc index f373f8c14..73156d1e3 100644 --- a/rtengine/filmnegativeproc.cc +++ b/rtengine/filmnegativeproc.cc @@ -32,7 +32,7 @@ #include "procparams.h" #include "rt_algo.h" #include "rtengine.h" - +#include "sleef.c" //#define BENCHMARK #include "StopWatch.h" diff --git a/rtengine/filmnegativethumb.cc b/rtengine/filmnegativethumb.cc index 1e52300d4..fa50e93bf 100644 --- a/rtengine/filmnegativethumb.cc +++ b/rtengine/filmnegativethumb.cc @@ -18,9 +18,11 @@ */ #include +#include "LUT.h" #include "rtengine.h" #include "rtthumbnail.h" #include "opthelper.h" +#include "sleef.c" #include "rt_algo.h" #include "settings.h" #include "procparams.h" diff --git a/rtengine/iccstore.h b/rtengine/iccstore.h index cc67c6152..731a155bb 100644 --- a/rtengine/iccstore.h +++ b/rtengine/iccstore.h @@ -27,8 +27,6 @@ #include -#include "color.h" - namespace rtengine { diff --git a/rtengine/iimage.cc b/rtengine/iimage.cc index a1ec979a1..a8bcf9368 100644 --- a/rtengine/iimage.cc +++ b/rtengine/iimage.cc @@ -17,6 +17,7 @@ * along with RawTherapee. If not, see . */ +#include "color.h" #include "procparams.h" #include "rtengine.h" @@ -45,3 +46,6 @@ int rtengine::getCoarseBitMask( const procparams::CoarseTransformParams &coarse) return tr; } +int rtengine::igammasrgb(float in) { + return Color::igamma_srgb(in); +} diff --git a/rtengine/iimage.h b/rtengine/iimage.h index 3c39b7659..73e38b45f 100644 --- a/rtengine/iimage.h +++ b/rtengine/iimage.h @@ -21,9 +21,9 @@ #include #include +#include #include "alignedbuffer.h" -#include "color.h" #include "coord2d.h" #include "imagedimensions.h" #include "LUT.h" @@ -59,6 +59,7 @@ extern const char sImage16[]; extern const char sImagefloat[]; int getCoarseBitMask(const procparams::CoarseTransformParams& coarse); +int igammasrgb(float in); enum TypeInterpolation { TI_Nearest, TI_Bilinear }; @@ -964,9 +965,9 @@ public: convertTo(r(i, j), r_); convertTo(g(i, j), g_); convertTo(b(i, j), b_); - histogram[(int)Color::igamma_srgb (r_) >> histcompr]++; - histogram[(int)Color::igamma_srgb (g_) >> histcompr]++; - histogram[(int)Color::igamma_srgb (b_) >> histcompr]++; + histogram[igammasrgb (r_) >> histcompr]++; + histogram[igammasrgb (g_) >> histcompr]++; + histogram[igammasrgb (b_) >> histcompr]++; } } @@ -982,9 +983,9 @@ public: convertTo(r(i, j), r_); convertTo(g(i, j), g_); convertTo(b(i, j), b_); - int rtemp = Color::igamma_srgb (r_); - int gtemp = Color::igamma_srgb (g_); - int btemp = Color::igamma_srgb (b_); + int rtemp = igammasrgb (r_); + int gtemp = igammasrgb (g_); + int btemp = igammasrgb (b_); histogram[rtemp >> compression]++; histogram[gtemp >> compression] += 2; @@ -1573,9 +1574,9 @@ public: convertTo(r(i, j), r_); convertTo(g(i, j), g_); convertTo(b(i, j), b_); - histogram[(int)Color::igamma_srgb (r_) >> histcompr]++; - histogram[(int)Color::igamma_srgb (g_) >> histcompr]++; - histogram[(int)Color::igamma_srgb (b_) >> histcompr]++; + histogram[igammasrgb (r_) >> histcompr]++; + histogram[igammasrgb (g_) >> histcompr]++; + histogram[igammasrgb (b_) >> histcompr]++; } } @@ -1591,9 +1592,9 @@ public: convertTo(r(i, j), r_); convertTo(g(i, j), g_); convertTo(b(i, j), b_); - int rtemp = Color::igamma_srgb (r_); - int gtemp = Color::igamma_srgb (g_); - int btemp = Color::igamma_srgb (b_); + int rtemp = igammasrgb (r_); + int gtemp = igammasrgb (g_); + int btemp = igammasrgb (b_); histogram[rtemp >> compression]++; histogram[gtemp >> compression] += 2; diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 6b5a22b63..e0c26aa9f 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -28,6 +28,11 @@ #include "LUT.h" #include "rtengine.h" +template +class LUT; + +using LUTf = LUT; + template class multi_array2D; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index b1bff49a0..b58c60780 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -42,6 +42,7 @@ #include "improccoordinator.h" #include "clutstore.h" #include "ciecam02.h" +#include "satandvalueblendingcurve.h" #include "StopWatch.h" #include "procparams.h" #include "../rtgui/ppversion.h" diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 2c4efbfe9..2229987a1 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -20,13 +20,17 @@ #include -#include "color.h" #include "coord2d.h" #include "gamutwarning.h" -#include "LUT.h" #include "pipettebuffer.h" #include "shmap.h" +template +class LUT; + +using LUTu = LUT; +using LUTf = LUT; + template class multi_array2D; namespace rtengine diff --git a/rtengine/init.cc b/rtengine/init.cc index 453374e3a..1a00f7ff6 100644 --- a/rtengine/init.cc +++ b/rtengine/init.cc @@ -18,6 +18,7 @@ */ #include #include "../rtgui/profilestorecombobox.h" +#include "color.h" #include "rtengine.h" #include "iccstore.h" #include "dcp.h" diff --git a/rtengine/ipdehaze.cc b/rtengine/ipdehaze.cc index c9579cf05..28a0f2d57 100644 --- a/rtengine/ipdehaze.cc +++ b/rtengine/ipdehaze.cc @@ -32,6 +32,7 @@ #include #include +#include "color.h" #include "guidedfilter.h" #include "iccstore.h" #include "imagefloat.h" diff --git a/rtengine/iplabregions.cc b/rtengine/iplabregions.cc index cea23bc6b..305a449ee 100644 --- a/rtengine/iplabregions.cc +++ b/rtengine/iplabregions.cc @@ -22,6 +22,7 @@ #include #endif +#include "color.h" #include "curves.h" #include "guidedfilter.h" #include "iccstore.h" diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index ab3a632da..b5d504a99 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -41,6 +41,7 @@ #include #include +#include "color.h" #include "curves.h" #include "gauss.h" #include "improcfun.h" diff --git a/rtengine/ipshadowshighlights.cc b/rtengine/ipshadowshighlights.cc index 0eceb5a3b..45031da53 100644 --- a/rtengine/ipshadowshighlights.cc +++ b/rtengine/ipshadowshighlights.cc @@ -20,6 +20,7 @@ #include "improcfun.h" +#include "color.h" #include "curves.h" #include "gauss.h" #include "guidedfilter.h" diff --git a/rtengine/ipsoftlight.cc b/rtengine/ipsoftlight.cc index ab2e7c8b1..41d0d48bf 100644 --- a/rtengine/ipsoftlight.cc +++ b/rtengine/ipsoftlight.cc @@ -19,6 +19,7 @@ * along with RawTherapee. If not, see . */ +#include "color.h" #include "iccstore.h" #include "improcfun.h" #include "labimage.h" diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 78a4dd509..08b317e4c 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -29,6 +29,7 @@ #include "../rtgui/threadutils.h" #include "array2D.h" +#include "color.h" #include "curves.h" #include "EdgePreservingDecomposition.h" #include "iccstore.h" diff --git a/rtengine/pixelshift.cc b/rtengine/pixelshift.cc index 9cb5844c2..7a6b6db41 100644 --- a/rtengine/pixelshift.cc +++ b/rtengine/pixelshift.cc @@ -28,7 +28,7 @@ #include "median.h" #include "procparams.h" #include "rawimagesource.h" - +#include "sleef.c" #include "../rtgui/multilangmgr.h" #include "../rtgui/options.h" diff --git a/rtengine/previewimage.cc b/rtengine/previewimage.cc index 7216e6a34..de1603f1c 100644 --- a/rtengine/previewimage.cc +++ b/rtengine/previewimage.cc @@ -19,6 +19,7 @@ #include "previewimage.h" +#include "color.h" #include "iimage.h" #include "iimage.h" #include "procparams.h" diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index df5ac40a9..c09da1e84 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -26,6 +26,7 @@ #include #include +#include "color.h" #include "curves.h" #include "procparams.h" #include "utils.h" diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 82e842ad3..f876fecb4 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -23,7 +23,6 @@ #include #include "array2D.h" -#include "color.h" #include "colortemp.h" #include "iimage.h" #include "imagesource.h" diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index 287759009..0473622c4 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -29,7 +29,6 @@ #include "iimage.h" #include "imageformat.h" -#include "LUT.h" #include "procevents.h" #include "rawmetadatalocation.h" #include "rt_math.h" @@ -43,6 +42,11 @@ * */ +template +class LUT; + +using LUTu = LUT; + class EditDataProvider; namespace rtexif { diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index d6ff53750..b1953bb3d 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -27,6 +27,7 @@ #include #include "cieimage.h" +#include "color.h" #include "colortemp.h" #include "curves.h" #include "dcp.h" diff --git a/rtengine/rtthumbnail.h b/rtengine/rtthumbnail.h index 473c74e7c..dcc9596f6 100644 --- a/rtengine/rtthumbnail.h +++ b/rtengine/rtthumbnail.h @@ -25,6 +25,7 @@ #include "image16.h" #include "image8.h" #include "imagefloat.h" +#include "LUT.h" #include "rawmetadatalocation.h" #include "../rtgui/threadutils.h" diff --git a/rtengine/satandvalueblendingcurve.h b/rtengine/satandvalueblendingcurve.h new file mode 100644 index 000000000..c610652b4 --- /dev/null +++ b/rtengine/satandvalueblendingcurve.h @@ -0,0 +1,70 @@ +/* + * This file is part of RawTherapee. + * + * Copyright (c) 2004-2010 Gabor Horvath + * + * RawTherapee is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RawTherapee is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RawTherapee. If not, see . + */ +#pragma once + +#include "color.h" +#include "curves.h" + +namespace rtengine +{ + +class SatAndValueBlendingToneCurve : public ToneCurve +{ +public: + void Apply(float& r, float& g, float& b) const; +}; + +// Tone curve modifying the value channel only, preserving hue and saturation +// values in 0xffff space +inline void SatAndValueBlendingToneCurve::Apply (float& ir, float& ig, float& ib) const +{ + + assert (lutToneCurve); + + float r = CLIP(ir); + float g = CLIP(ig); + float b = CLIP(ib); + + const float lum = (r + g + b) / 3.f; + const float newLum = lutToneCurve[lum]; + + if (newLum == lum) { + return; + } + + float h, s, v; + Color::rgb2hsvtc(r, g, b, h, s, v); + + float dV; + if (newLum > lum) { + // Linearly targeting Value = 1 and Saturation = 0 + const float coef = (newLum - lum) / (65535.f - lum); + dV = (1.f - v) * coef; + s *= 1.f - coef; + } else { + // Linearly targeting Value = 0 + const float coef = (newLum - lum) / lum ; + dV = v * coef; + } + Color::hsv2rgbdcp(h, s, v + dV, r, g, b); + + setUnlessOOG(ir, ig, ib, r, g, b); +} + +} diff --git a/rtengine/shmap.cc b/rtengine/shmap.cc index 36582df39..d0c34e925 100644 --- a/rtengine/shmap.cc +++ b/rtengine/shmap.cc @@ -22,6 +22,7 @@ #include "rtengine.h" #include "rt_math.h" #include "rawimagesource.h" +#include "sleef.c" #include "jaggedarray.h" #undef THREAD_PRIORITY_NORMAL #include "opthelper.h" diff --git a/rtengine/shmap.h b/rtengine/shmap.h index b40e872bb..5373b8302 100644 --- a/rtengine/shmap.h +++ b/rtengine/shmap.h @@ -18,9 +18,13 @@ */ #pragma once -#include "LUT.h" #include "noncopyable.h" +template +class LUT; + +using LUTf = LUT; + namespace rtengine { diff --git a/rtengine/tmo_fattal02.cc b/rtengine/tmo_fattal02.cc index d28606edb..173171e0e 100644 --- a/rtengine/tmo_fattal02.cc +++ b/rtengine/tmo_fattal02.cc @@ -66,6 +66,7 @@ #include #include "array2D.h" +#include "color.h" #include "iccstore.h" #include "imagefloat.h" #include "improcfun.h" diff --git a/rtengine/xtrans_demosaic.cc b/rtengine/xtrans_demosaic.cc index 418d369b8..c1a526535 100644 --- a/rtengine/xtrans_demosaic.cc +++ b/rtengine/xtrans_demosaic.cc @@ -19,6 +19,7 @@ // //////////////////////////////////////////////////////////////// +#include "color.h" #include "rtengine.h" #include "rawimage.h" #include "rawimagesource.h" diff --git a/rtgui/bayerexposre.h b/rtgui/bayerexposre.h new file mode 100644 index 000000000..e69de29bb diff --git a/rtgui/bayerexposure.h b/rtgui/bayerexposure.h new file mode 100644 index 000000000..e69de29bb diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index f177602a3..1a6a9b918 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -7,6 +7,7 @@ #include "eventmapper.h" #include "labgrid.h" #include "options.h" +#include "../rtengine/color.h" using namespace rtengine; using namespace rtengine::procparams; diff --git a/rtgui/defringe.cc b/rtgui/defringe.cc index 8aa79dddd..7114f9a52 100644 --- a/rtgui/defringe.cc +++ b/rtgui/defringe.cc @@ -22,6 +22,7 @@ #include "defringe.h" #include "options.h" +#include "../rtengine/color.h" #include "../rtengine/procparams.h" using namespace rtengine; diff --git a/rtgui/dirpyrdenoise.cc b/rtgui/dirpyrdenoise.cc index dd695eecf..b429dfc9f 100644 --- a/rtgui/dirpyrdenoise.cc +++ b/rtgui/dirpyrdenoise.cc @@ -25,6 +25,7 @@ #include "guiutils.h" #include "options.h" +#include "../rtengine/color.h" #include "../rtengine/procparams.h" using namespace rtengine; diff --git a/rtgui/dirpyrequalizer.cc b/rtgui/dirpyrequalizer.cc index fc03c83ad..fd0268efa 100644 --- a/rtgui/dirpyrequalizer.cc +++ b/rtgui/dirpyrequalizer.cc @@ -19,6 +19,8 @@ #include "dirpyrequalizer.h" +#include "../rtengine/color.h" + using namespace rtengine; using namespace rtengine::procparams; diff --git a/rtgui/labcurve.cc b/rtgui/labcurve.cc index fd1065269..bd4b27f14 100644 --- a/rtgui/labcurve.cc +++ b/rtgui/labcurve.cc @@ -22,6 +22,7 @@ #include "options.h" +#include "../rtengine/color.h" #include "../rtengine/improcfun.h" #include "../rtengine/procparams.h" #include "editcallbacks.h" diff --git a/rtgui/labgrid.cc b/rtgui/labgrid.cc index fa452815e..516dbb825 100644 --- a/rtgui/labgrid.cc +++ b/rtgui/labgrid.cc @@ -38,6 +38,7 @@ #include "labgrid.h" +#include "../rtengine/color.h" #include "options.h" #include "rtimage.h" diff --git a/rtgui/mydiagonalcurve.h b/rtgui/mydiagonalcurve.h index d9f2518fb..a71c0565c 100644 --- a/rtgui/mydiagonalcurve.h +++ b/rtgui/mydiagonalcurve.h @@ -26,9 +26,12 @@ #include "curvelistener.h" #include "mycurve.h" -#include "../rtengine/LUT.h" #include "../rtengine/diagonalcurvetypes.h" +template +class LUT; + +using LUTf = LUT; class DiagonalCurveDescr { diff --git a/rtgui/retinex.cc b/rtgui/retinex.cc index dddf1da20..33f1c2f6a 100644 --- a/rtgui/retinex.cc +++ b/rtgui/retinex.cc @@ -5,6 +5,7 @@ #include "mycurve.h" #include "rtimage.h" #include "options.h" +#include "../rtengine/color.h" using namespace rtengine; using namespace rtengine::procparams; diff --git a/rtgui/wavelet.cc b/rtgui/wavelet.cc index 6e49d36b9..4fd3a7b8f 100644 --- a/rtgui/wavelet.cc +++ b/rtgui/wavelet.cc @@ -24,6 +24,7 @@ #include "guiutils.h" #include "rtimage.h" #include "options.h" +#include "../rtengine/color.h" using namespace rtengine; using namespace rtengine::procparams;