diff --git a/rtdata/languages/default b/rtdata/languages/default index ed8756b21..73cc79a89 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1084,7 +1084,6 @@ HISTORY_MSG_MICROCONTRAST_CONTRAST;Microcontrast - Contrast threshold HISTORY_MSG_PDSHARPEN_AUTO_CONTRAST;CS - Auto threshold HISTORY_MSG_PDSHARPEN_AUTO_RADIUS;CS - Auto radius HISTORY_MSG_PDSHARPEN_CONTRAST;CS - Contrast threshold -HISTORY_MSG_PDSHARPEN_GAMMA;CS - Gamma HISTORY_MSG_PDSHARPEN_ITERATIONS;CS - Iterations HISTORY_MSG_PDSHARPEN_RADIUS;CS - Radius HISTORY_MSG_PDSHARPEN_RADIUS_BOOST;CS - Corner radius boost @@ -1098,7 +1097,6 @@ HISTORY_MSG_RAW_BORDER;Raw border HISTORY_MSG_RESIZE_ALLOWUPSCALING;Resize - Allow upscaling HISTORY_MSG_SHARPENING_BLUR;Sharpening - Blur radius HISTORY_MSG_SHARPENING_CONTRAST;Sharpening - Contrast threshold -HISTORY_MSG_SHARPENING_GAMMA;Sharpening - Gamma HISTORY_MSG_SH_COLORSPACE;S/H - Colorspace HISTORY_MSG_SOFTLIGHT_ENABLED;Soft light HISTORY_MSG_SOFTLIGHT_STRENGTH;Soft light - Strength @@ -2705,7 +2703,6 @@ TP_SHARPENING_BLUR;Blur radius TP_SHARPENING_CONTRAST;Contrast threshold TP_SHARPENING_EDRADIUS;Radius TP_SHARPENING_EDTOLERANCE;Edge tolerance -TP_SHARPENING_GAMMA;Gamma TP_SHARPENING_HALOCONTROL;Halo control TP_SHARPENING_HCAMOUNT;Amount TP_SHARPENING_LABEL;Sharpening diff --git a/rtengine/capturesharpening.cc b/rtengine/capturesharpening.cc index f574fa45f..b1e1657b4 100644 --- a/rtengine/capturesharpening.cc +++ b/rtengine/capturesharpening.cc @@ -99,33 +99,48 @@ void compute3x3kernel(float sigma, float kernel[3][3]) { } } -inline void gauss3x3div (float** RESTRICT src, float** RESTRICT dst, float** RESTRICT divBuffer, const int W, const int H, const float kernel[3][3]) +inline void initTile(float** dst, const int tileSize) +{ + + // first rows + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < tileSize; ++j) { + dst[i][j] = 1.f; + } + } + + // left and right border + for (int i = 3; i < tileSize - 3; ++i) { + dst[i][0] = dst[i][1] = dst[i][2] = 1.f; + dst[i][tileSize - 3] = dst[i][tileSize - 2] = dst[i][tileSize - 1] = 1.f; + } + + // last rows + for (int i = tileSize - 3 ; i < tileSize; ++i) { + for (int j = 0; j < tileSize; ++j) { + dst[i][j] = 1.f; + } + } +} + +inline void gauss3x3div (float** RESTRICT src, float** RESTRICT dst, float** RESTRICT divBuffer, const int tileSize, const float kernel[3][3]) { const float c11 = kernel[0][0]; const float c10 = kernel[0][1]; const float c00 = kernel[1][1]; - for (int i = 1; i < H - 1; i++) { - dst[i][0] = 1.f; - for (int j = 1; j < W - 1; j++) { + for (int i = 1; i < tileSize - 1; i++) { + for (int j = 1; j < tileSize - 1; j++) { const float val = c11 * (src[i - 1][j - 1] + src[i - 1][j + 1] + src[i + 1][j - 1] + src[i + 1][j + 1]) + c10 * (src[i - 1][j] + src[i][j - 1] + src[i][j + 1] + src[i + 1][j]) + c00 * src[i][j]; dst[i][j] = divBuffer[i][j] / std::max(val, 0.00001f); } - dst[i][W - 1] = 1.f; - } - // first and last row - for (int j = 0; j < W; ++j) { - dst[0][j] = 1.f; - } - for (int j = 0; j < W; ++j) { - dst[H - 1][j] = 1.f; } } -inline void gauss5x5div (float** RESTRICT src, float** RESTRICT dst, float** RESTRICT divBuffer, const int W, const int H, const float kernel[5][5]) +inline void gauss5x5div (float** RESTRICT src, float** RESTRICT dst, float** RESTRICT divBuffer, const int tileSize, const float kernel[5][5]) { const float c21 = kernel[0][1]; @@ -134,10 +149,9 @@ inline void gauss5x5div (float** RESTRICT src, float** RESTRICT dst, float** RES const float c10 = kernel[1][2]; const float c00 = kernel[2][2]; - for (int i = 2; i < H - 2; ++i) { - dst[i][0] = dst[i][1] = 1.f; + for (int i = 2; i < tileSize - 2; ++i) { // I tried hand written SSE code but gcc vectorizes better - for (int j = 2; j < W - 2; ++j) { + for (int j = 2; j < tileSize - 2; ++j) { const float val = c21 * (src[i - 2][j - 1] + src[i - 2][j + 1] + src[i - 1][j - 2] + src[i - 1][j + 2] + src[i + 1][j - 2] + src[i + 1][j + 2] + src[i + 2][j - 1] + src[i + 2][j + 1]) + c20 * (src[i - 2][j] + src[i][j - 2] + src[i][j + 2] + src[i + 2][j]) + c11 * (src[i - 1][j - 1] + src[i - 1][j + 1] + src[i + 1][j - 1] + src[i + 1][j + 1]) + @@ -146,23 +160,10 @@ inline void gauss5x5div (float** RESTRICT src, float** RESTRICT dst, float** RES dst[i][j] = divBuffer[i][j] / std::max(val, 0.00001f); } - dst[i][W - 2] = dst[i][W - 1] = 1.f; - } - - // first and last rows - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < W; ++j) { - dst[i][j] = 1.f; - } - } - for (int i = H - 2 ; i < H; ++i) { - for (int j = 0; j < W; ++j) { - dst[i][j] = 1.f; - } } } -inline void gauss7x7div(float** RESTRICT src, float** RESTRICT dst, float** RESTRICT divBuffer, const int W, const int H, const float kernel[7][7]) +inline void gauss7x7div(float** RESTRICT src, float** RESTRICT dst, float** RESTRICT divBuffer, const int tileSize, const float kernel[7][7]) { const float c31 = kernel[0][2]; @@ -174,10 +175,9 @@ inline void gauss7x7div(float** RESTRICT src, float** RESTRICT dst, float** REST const float c10 = kernel[2][3]; const float c00 = kernel[3][3]; - for (int i = 3; i < H - 3; ++i) { - dst[i][0] = dst[i][1] = dst[i][2] = 1.f; + for (int i = 3; i < tileSize - 3; ++i) { // I tried hand written SSE code but gcc vectorizes better - for (int j = 3; j < W - 3; ++j) { + for (int j = 3; j < tileSize - 3; ++j) { const float val = c31 * (src[i - 3][j - 1] + src[i - 3][j + 1] + src[i - 1][j - 3] + src[i - 1][j + 3] + src[i + 1][j - 3] + src[i + 1][j + 3] + src[i + 3][j - 1] + src[i + 3][j + 1]) + c30 * (src[i - 3][j] + src[i][j - 3] + src[i][j + 3] + src[i + 3][j]) + c22 * (src[i - 2][j - 2] + src[i - 2][j + 2] + src[i + 2][j - 2] + src[i + 2][j + 2]) + @@ -189,30 +189,17 @@ inline void gauss7x7div(float** RESTRICT src, float** RESTRICT dst, float** REST dst[i][j] = divBuffer[i][j] / std::max(val, 0.00001f); } - dst[i][W - 3] = dst[i][W - 2] = dst[i][W - 1] = 1.f; - } - - // first and last rows - for (int i = 0; i < 3; ++i) { - for (int j = 0; j < W; ++j) { - dst[i][j] = 1.f; - } - } - for (int i = H - 3 ; i < H; ++i) { - for (int j = 0; j < W; ++j) { - dst[i][j] = 1.f; - } } } -inline void gauss3x3mult(float** RESTRICT src, float** RESTRICT dst, const int W, const int H, const float kernel[3][3]) +inline void gauss3x3mult(float** RESTRICT src, float** RESTRICT dst, const int tileSize, const float kernel[3][3]) { const float c11 = kernel[0][0]; const float c10 = kernel[0][1]; const float c00 = kernel[1][1]; - for (int i = 1; i < H - 1; i++) { - for (int j = 1; j < W - 1; j++) { + for (int i = 1; i < tileSize - 1; i++) { + for (int j = 1; j < tileSize - 1; j++) { const float val = c11 * (src[i - 1][j - 1] + src[i - 1][j + 1] + src[i + 1][j - 1] + src[i + 1][j + 1]) + c10 * (src[i - 1][j] + src[i][j - 1] + src[i][j + 1] + src[i + 1][j]) + c00 * src[i][j]; @@ -222,7 +209,7 @@ inline void gauss3x3mult(float** RESTRICT src, float** RESTRICT dst, const int W } -inline void gauss5x5mult (float** RESTRICT src, float** RESTRICT dst, const int W, const int H, const float kernel[5][5]) +inline void gauss5x5mult (float** RESTRICT src, float** RESTRICT dst, const int tileSize, const float kernel[5][5]) { const float c21 = kernel[0][1]; @@ -231,9 +218,9 @@ inline void gauss5x5mult (float** RESTRICT src, float** RESTRICT dst, const int const float c10 = kernel[1][2]; const float c00 = kernel[2][2]; - for (int i = 2; i < H - 2; ++i) { + for (int i = 2; i < tileSize - 2; ++i) { // I tried hand written SSE code but gcc vectorizes better - for (int j = 2; j < W - 2; ++j) { + for (int j = 2; j < tileSize - 2; ++j) { const float val = c21 * (src[i - 2][j - 1] + src[i - 2][j + 1] + src[i - 1][j - 2] + src[i - 1][j + 2] + src[i + 1][j - 2] + src[i + 1][j + 2] + src[i + 2][j - 1] + src[i + 2][j + 1]) + c20 * (src[i - 2][j] + src[i][j - 2] + src[i][j + 2] + src[i + 2][j]) + c11 * (src[i - 1][j - 1] + src[i - 1][j + 1] + src[i + 1][j - 1] + src[i + 1][j + 1]) + @@ -245,7 +232,7 @@ inline void gauss5x5mult (float** RESTRICT src, float** RESTRICT dst, const int } } -inline void gauss7x7mult(float** RESTRICT src, float** RESTRICT dst, const int W, const int H, const float kernel[7][7]) +inline void gauss7x7mult(float** RESTRICT src, float** RESTRICT dst, const int tileSize, const float kernel[7][7]) { const float c31 = kernel[0][2]; @@ -257,9 +244,9 @@ inline void gauss7x7mult(float** RESTRICT src, float** RESTRICT dst, const int W const float c10 = kernel[2][3]; const float c00 = kernel[3][3]; - for (int i = 3; i < H - 3; ++i) { + for (int i = 3; i < tileSize - 3; ++i) { // I tried hand written SSE code but gcc vectorizes better - for (int j = 3; j < W - 3; ++j) { + for (int j = 3; j < tileSize - 3; ++j) { const float val = c31 * (src[i - 3][j - 1] + src[i - 3][j + 1] + src[i - 1][j - 3] + src[i - 1][j + 3] + src[i + 1][j - 3] + src[i + 1][j + 3] + src[i + 3][j - 1] + src[i + 3][j + 1]) + c30 * (src[i - 3][j] + src[i][j - 3] + src[i][j + 3] + src[i + 3][j]) + c22 * (src[i - 2][j - 2] + src[i - 2][j + 2] + src[i + 2][j - 2] + src[i + 2][j + 2]) + @@ -543,7 +530,10 @@ BENCHFUN array2D tmpIThr(fullTileSize, fullTileSize); array2D tmpThr(fullTileSize, fullTileSize); array2D lumThr(fullTileSize, fullTileSize); -#pragma omp for schedule(dynamic,2) collapse(2) + initTile(tmpThr, fullTileSize); +#ifdef _OPENMP + #pragma omp for schedule(dynamic,2) collapse(2) +#endif for (int i = border; i < H - border; i+= tileSize) { for(int j = border; j < W - border; j+= tileSize) { const bool endOfCol = (i + tileSize + border) >= H; @@ -568,14 +558,14 @@ BENCHFUN if (is3x3) { for (int k = 0; k < iterations; ++k) { // apply 3x3 gaussian blur and divide luminance by result of gaussian blur - gauss3x3div(tmpIThr, tmpThr, lumThr, fullTileSize, fullTileSize, kernel3); - gauss3x3mult(tmpThr, tmpIThr, fullTileSize, fullTileSize, kernel3); + gauss3x3div(tmpIThr, tmpThr, lumThr, fullTileSize, kernel3); + gauss3x3mult(tmpThr, tmpIThr, fullTileSize, kernel3); } } else if (is5x5) { for (int k = 0; k < iterations; ++k) { // apply 5x5 gaussian blur and divide luminance by result of gaussian blur - gauss5x5div(tmpIThr, tmpThr, lumThr, fullTileSize, fullTileSize, kernel5); - gauss5x5mult(tmpThr, tmpIThr, fullTileSize, fullTileSize, kernel5); + gauss5x5div(tmpIThr, tmpThr, lumThr, fullTileSize, kernel5); + gauss5x5mult(tmpThr, tmpIThr, fullTileSize, kernel5); } } else { if (sigmaCornerOffset != 0.0) { @@ -584,17 +574,17 @@ BENCHFUN if (sigmaTile >= 0.4f) { float lkernel7[7][7]; compute7x7kernel(static_cast(sigma) + distanceFactor * distance, lkernel7); - for (int k = 0; k < iterations - 1; ++k) { + for (int k = 0; k < iterations; ++k) { // apply 7x7 gaussian blur and divide luminance by result of gaussian blur - gauss7x7div(tmpIThr, tmpThr, lumThr, fullTileSize, fullTileSize, lkernel7); - gauss7x7mult(tmpThr, tmpIThr, fullTileSize, fullTileSize, lkernel7); + gauss7x7div(tmpIThr, tmpThr, lumThr, fullTileSize, lkernel7); + gauss7x7mult(tmpThr, tmpIThr, fullTileSize, lkernel7); } } } else { for (int k = 0; k < iterations; ++k) { // apply 7x7 gaussian blur and divide luminance by result of gaussian blur - gauss7x7div(tmpIThr, tmpThr, lumThr, fullTileSize, fullTileSize, kernel7); - gauss7x7mult(tmpThr, tmpIThr, fullTileSize, fullTileSize, kernel7); + gauss7x7div(tmpIThr, tmpThr, lumThr, fullTileSize, kernel7); + gauss7x7mult(tmpThr, tmpIThr, fullTileSize, kernel7); } } } @@ -641,7 +631,7 @@ void RawImageSource::captureSharpening(const procparams::CaptureSharpeningParams plistener->setProgress(0.0); } BENCHFUN - const float xyz_rgb[3][3] = { // XYZ from RGB + constexpr float xyz_rgb[3][3] = { // XYZ from RGB { 0.412453, 0.357580, 0.180423 }, { 0.212671, 0.715160, 0.072169 }, { 0.019334, 0.119193, 0.950227 } @@ -657,6 +647,8 @@ BENCHFUN array2D clipMask(W, H); constexpr float clipLimit = 0.95f; + constexpr float maxSigma = 1.15f; + if (getSensorType() == ST_BAYER) { const float whites[2][2] = { {(ri->get_white(FC(0,0)) - c_black[FC(0,0)]) * scale_mul[FC(0,0)] * clipLimit, (ri->get_white(FC(0,1)) - c_black[FC(0,1)]) * scale_mul[FC(0,1)] * clipLimit}, @@ -665,7 +657,7 @@ BENCHFUN buildClipMaskBayer(rawData, W, H, clipMask, whites); const unsigned int fc[2] = {FC(0,0), FC(1,0)}; if (sharpeningParams.autoRadius) { - radius = std::min(calcRadiusBayer(rawData, W, H, 1000.f, clipVal, fc), 1.15f); + radius = std::min(calcRadiusBayer(rawData, W, H, 1000.f, clipVal, fc), maxSigma); } } else if (getSensorType() == ST_FUJI_XTRANS) { float whites[6][6]; @@ -693,14 +685,14 @@ BENCHFUN } } if (sharpeningParams.autoRadius) { - radius = std::min(calcRadiusXtrans(rawData, W, H, 1000.f, clipVal, i, j), 1.15f); + radius = std::min(calcRadiusXtrans(rawData, W, H, 1000.f, clipVal, i, j), maxSigma); } } else if (ri->get_colors() == 1) { buildClipMaskMono(rawData, W, H, clipMask, (ri->get_white(0) - c_black[0]) * scale_mul[0] * clipLimit); if (sharpeningParams.autoRadius) { const unsigned int fc[2] = {0, 0}; - radius = std::min(calcRadiusBayer(rawData, W, H, 1000.f, clipVal, fc), 1.15f); + radius = std::min(calcRadiusBayer(rawData, W, H, 1000.f, clipVal, fc), maxSigma); } } @@ -754,14 +746,13 @@ BENCHFUN array2D& L = Lbuffer ? *Lbuffer : red; array2D& YOld = YOldbuffer ? * YOldbuffer : green; array2D& YNew = YNewbuffer ? * YNewbuffer : blue; - const float gamma = sharpeningParams.gamma; #ifdef _OPENMP #pragma omp parallel for schedule(dynamic, 16) #endif for (int i = 0; i < H; ++i) { Color::RGB2L(redVals[i], greenVals[i], blueVals[i], L[i], xyz_rgb, W); - Color::RGB2Y(redVals[i], greenVals[i], blueVals[i], YOld[i], YNew[i], gamma, W); + Color::RGB2Y(redVals[i], greenVals[i], blueVals[i], YOld[i], YNew[i], W); } if (plistener) { plistener->setProgress(0.1); @@ -784,9 +775,8 @@ BENCHFUN for (int i = 0; i < H; ++i) { int j = 0; #ifdef __SSE2__ - const vfloat gammav = F2V(gamma); for (; j < W - 3; j += 4) { - const vfloat factor = pow_F(vmaxf(LVFU(YNew[i][j]), ZEROV) / vmaxf(LVFU(YOld[i][j]), F2V(0.00001f)), gammav); + const vfloat factor = vmaxf(LVFU(YNew[i][j]), ZEROV) / vmaxf(LVFU(YOld[i][j]), F2V(0.00001f)); STVFU(red[i][j], LVFU(redVals[i][j]) * factor); STVFU(green[i][j], LVFU(greenVals[i][j]) * factor); STVFU(blue[i][j], LVFU(blueVals[i][j]) * factor); @@ -794,7 +784,7 @@ BENCHFUN #endif for (; j < W; ++j) { - const float factor = pow_F(std::max(YNew[i][j], 0.f) / std::max(YOld[i][j], 0.00001f), gamma); + const float factor = std::max(YNew[i][j], 0.f) / std::max(YOld[i][j], 0.00001f); red[i][j] = redVals[i][j] * factor; green[i][j] = greenVals[i][j] * factor; blue[i][j] = blueVals[i][j] * factor; diff --git a/rtengine/color.h b/rtengine/color.h index 09e515c73..979573e44 100644 --- a/rtengine/color.h +++ b/rtengine/color.h @@ -1868,11 +1868,9 @@ public: return (hr); } - static inline void RGB2Y(const float* R, const float* G, const float* B, float* Y1, float * Y2, float gamma, int W) { - gamma = 1.f / gamma; + static inline void RGB2Y(const float* R, const float* G, const float* B, float* Y1, float * Y2, int W) { int i = 0; #ifdef __SSE2__ - const vfloat gammav = F2V(gamma); const vfloat c1v = F2V(0.2627f); const vfloat c2v = F2V(0.6780f); const vfloat c3v = F2V(0.0593f); @@ -1880,7 +1878,7 @@ public: const vfloat Rv = vmaxf(LVFU(R[i]), ZEROV); const vfloat Gv = vmaxf(LVFU(G[i]), ZEROV); const vfloat Bv = vmaxf(LVFU(B[i]), ZEROV); - vfloat yv = pow_F(c1v * Rv + c2v * Gv + c3v * Bv, gammav); + vfloat yv = c1v * Rv + c2v * Gv + c3v * Bv; STVFU(Y1[i], yv); STVFU(Y2[i], yv); } @@ -1889,7 +1887,7 @@ public: const float r = std::max(R[i], 0.f); const float g = std::max(G[i], 0.f); const float b = std::max(B[i], 0.f); - Y1[i] = Y2[i] = pow_F(0.2627f * r + 0.6780f * g + 0.0593f * b, gamma); + Y1[i] = Y2[i] = 0.2627f * r + 0.6780f * g + 0.0593f * b; } } }; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index d970c36dd..23ffe5cd9 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1159,7 +1159,6 @@ CaptureSharpeningParams::CaptureSharpeningParams() : autoContrast(true), autoRadius(true), contrast(10.0), - gamma(1.00), deconvradius(0.75), deconvradiusOffset(0.0), deconviter(20) @@ -1171,7 +1170,6 @@ bool CaptureSharpeningParams::operator ==(const CaptureSharpeningParams& other) return enabled == other.enabled && contrast == other.contrast - && gamma == other.gamma && autoContrast == other.autoContrast && autoRadius == other.autoRadius && deconvradius == other.deconvradius @@ -4399,7 +4397,6 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo saveToKeyfile(!pedited || pedited->pdsharpening.contrast, "PostDemosaicSharpening", "Contrast", pdsharpening.contrast, keyFile); saveToKeyfile(!pedited || pedited->pdsharpening.autoContrast, "PostDemosaicSharpening", "AutoContrast", pdsharpening.autoContrast, keyFile); saveToKeyfile(!pedited || pedited->pdsharpening.autoRadius, "PostDemosaicSharpening", "AutoRadius", pdsharpening.autoRadius, keyFile); - saveToKeyfile(!pedited || pedited->pdsharpening.gamma, "PostDemosaicSharpening", "DeconvGamma", pdsharpening.gamma, keyFile); saveToKeyfile(!pedited || pedited->pdsharpening.deconvradius, "PostDemosaicSharpening", "DeconvRadius", pdsharpening.deconvradius, keyFile); saveToKeyfile(!pedited || pedited->pdsharpening.deconvradiusOffset, "PostDemosaicSharpening", "DeconvRadiusOffset", pdsharpening.deconvradiusOffset, keyFile); saveToKeyfile(!pedited || pedited->pdsharpening.deconviter, "PostDemosaicSharpening", "DeconvIterations", pdsharpening.deconviter, keyFile); @@ -5885,8 +5882,6 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) assignFromKeyfile(keyFile, "PostDemosaicSharpening", "Contrast", pedited, pdsharpening.contrast, pedited->pdsharpening.contrast); assignFromKeyfile(keyFile, "PostDemosaicSharpening", "AutoContrast", pedited, pdsharpening.autoContrast, pedited->pdsharpening.autoContrast); assignFromKeyfile(keyFile, "PostDemosaicSharpening", "AutoRadius", pedited, pdsharpening.autoRadius, pedited->pdsharpening.autoRadius); - - assignFromKeyfile(keyFile, "PostDemosaicSharpening", "DeconvGamma", pedited, pdsharpening.gamma, pedited->pdsharpening.gamma); assignFromKeyfile(keyFile, "PostDemosaicSharpening", "DeconvRadius", pedited, pdsharpening.deconvradius, pedited->pdsharpening.deconvradius); assignFromKeyfile(keyFile, "PostDemosaicSharpening", "DeconvRadiusOffset", pedited, pdsharpening.deconvradiusOffset, pedited->pdsharpening.deconvradiusOffset); assignFromKeyfile(keyFile, "PostDemosaicSharpening", "DeconvIterations", pedited, pdsharpening.deconviter, pedited->pdsharpening.deconviter); diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 2176aaf49..bdc40c657 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -567,7 +567,6 @@ struct CaptureSharpeningParams { bool autoContrast; bool autoRadius; double contrast; - double gamma; double deconvradius; double deconvradiusOffset; int deconviter; diff --git a/rtgui/batchtoolpanelcoord.cc b/rtgui/batchtoolpanelcoord.cc index 0ede8a4af..a09fa0e14 100644 --- a/rtgui/batchtoolpanelcoord.cc +++ b/rtgui/batchtoolpanelcoord.cc @@ -159,7 +159,7 @@ void BatchToolPanelCoordinator::initSession () cacorrection->setAdjusterBehavior (false); sharpening->setAdjusterBehavior (false, false, false, false, false, false, false); prsharpening->setAdjusterBehavior (false, false, false, false, false, false, false); - pdSharpening->setAdjusterBehavior (false, false, false, false); + pdSharpening->setAdjusterBehavior (false, false, false); sharpenEdge->setAdjusterBehavior (false, false); sharpenMicro->setAdjusterBehavior (false, false, false); epd->setAdjusterBehavior (false, false, false, false, false); diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 1cf336fa2..b9db8ce52 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -169,7 +169,6 @@ void ParamsEdited::set(bool v) pdsharpening.contrast = v; pdsharpening.autoContrast = v; pdsharpening.autoRadius = v; - pdsharpening.gamma = v; pdsharpening.deconvradius = v; pdsharpening.deconvradiusOffset = v; pdsharpening.deconviter = v; @@ -770,7 +769,6 @@ void ParamsEdited::initFrom(const std::vector& pdsharpening.contrast = pdsharpening.contrast && p.pdsharpening.contrast == other.pdsharpening.contrast; pdsharpening.autoContrast = pdsharpening.autoContrast && p.pdsharpening.autoContrast == other.pdsharpening.autoContrast; pdsharpening.autoRadius = pdsharpening.autoRadius && p.pdsharpening.autoRadius == other.pdsharpening.autoRadius; - pdsharpening.gamma = pdsharpening.gamma && p.pdsharpening.gamma == other.pdsharpening.gamma; pdsharpening.deconvradius = pdsharpening.deconvradius && p.pdsharpening.deconvradius == other.pdsharpening.deconvradius; pdsharpening.deconvradiusOffset = pdsharpening.deconvradiusOffset && p.pdsharpening.deconvradiusOffset == other.pdsharpening.deconvradiusOffset; pdsharpening.deconviter = pdsharpening.deconviter && p.pdsharpening.deconviter == other.pdsharpening.deconviter; @@ -2093,10 +2091,6 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng toEdit.pdsharpening.autoRadius = mods.pdsharpening.autoRadius; } - if (pdsharpening.gamma) { - toEdit.pdsharpening.gamma = dontforceSet && options.baBehav[ADDSET_SHARP_GAMMA] ? toEdit.pdsharpening.gamma + mods.pdsharpening.gamma : mods.pdsharpening.gamma; - } - if (pdsharpening.deconvradius) { toEdit.pdsharpening.deconvradius = dontforceSet && options.baBehav[ADDSET_SHARP_RADIUS] ? toEdit.pdsharpening.deconvradius + mods.pdsharpening.deconvradius : mods.pdsharpening.deconvradius; } @@ -5544,5 +5538,5 @@ void LocallabParamsEdited::LocallabSpotEdited::set(bool v) bool CaptureSharpeningParamsEdited::isUnchanged() const { - return enabled && contrast && autoContrast && autoRadius && gamma && deconvradius && deconvradiusOffset && deconviter; + return enabled && contrast && autoContrast && autoRadius && deconvradius && deconvradiusOffset && deconviter; } \ No newline at end of file diff --git a/rtgui/paramsedited.h b/rtgui/paramsedited.h index 427e8f130..86e2b64d9 100644 --- a/rtgui/paramsedited.h +++ b/rtgui/paramsedited.h @@ -215,7 +215,6 @@ struct CaptureSharpeningParamsEdited { bool contrast; bool autoContrast; bool autoRadius; - bool gamma; bool deconvradius; bool deconvradiusOffset; bool deconviter; diff --git a/rtgui/pdsharpening.cc b/rtgui/pdsharpening.cc index d0ccc43a8..ad982b82e 100644 --- a/rtgui/pdsharpening.cc +++ b/rtgui/pdsharpening.cc @@ -37,7 +37,6 @@ PdSharpening::PdSharpening() : { auto m = ProcEventMapper::getInstance(); EvPdShrContrast = m->newEvent(CAPTURESHARPEN, "HISTORY_MSG_PDSHARPEN_CONTRAST"); - EvPdSharpenGamma = m->newEvent(CAPTURESHARPEN, "HISTORY_MSG_PDSHARPEN_GAMMA"); EvPdShrDRadius = m->newEvent(CAPTURESHARPEN, "HISTORY_MSG_PDSHARPEN_RADIUS"); EvPdShrDRadiusOffset = m->newEvent(CAPTURESHARPEN, "HISTORY_MSG_PDSHARPEN_RADIUS_BOOST"); EvPdShrDIterations = m->newEvent(CAPTURESHARPEN, "HISTORY_MSG_PDSHARPEN_ITERATIONS"); @@ -57,17 +56,14 @@ PdSharpening::PdSharpening() : pack_start(*hb); Gtk::VBox* rld = Gtk::manage(new Gtk::VBox()); - gamma = Gtk::manage(new Adjuster(M("TP_SHARPENING_GAMMA"), 0.5, 6.0, 0.05, 1.00)); dradius = Gtk::manage(new Adjuster(M("TP_SHARPENING_RADIUS"), 0.4, 1.15, 0.01, 0.75)); dradius->addAutoButton(); dradius->setAutoValue(true); dradiusOffset = Gtk::manage(new Adjuster(M("TP_SHARPENING_RADIUS_BOOST"), -0.5, 0.5, 0.01, 0.0)); diter = Gtk::manage(new Adjuster(M("TP_SHARPENING_RLD_ITERATIONS"), 1, 100, 1, 20)); - rld->pack_start(*gamma); rld->pack_start(*dradius); rld->pack_start(*dradiusOffset); rld->pack_start(*diter); - gamma->show(); dradius->show(); dradiusOffset->show(); diter->show(); @@ -76,13 +72,11 @@ PdSharpening::PdSharpening() : dradius->setAdjusterListener(this); dradiusOffset->setAdjusterListener(this); - gamma->setAdjusterListener(this); diter->setAdjusterListener(this); contrast->delay = std::max(contrast->delay, options.adjusterMaxDelay); dradius->delay = std::max(dradius->delay, options.adjusterMaxDelay); dradiusOffset->delay = std::max(dradiusOffset->delay, options.adjusterMaxDelay); - gamma->delay = std::max(gamma->delay, options.adjusterMaxDelay); diter->delay = std::max(diter->delay, options.adjusterMaxDelay); } @@ -101,7 +95,6 @@ void PdSharpening::read(const ProcParams* pp, const ParamsEdited* pedited) contrast->setEditedState(pedited->pdsharpening.contrast ? Edited : UnEdited); contrast->setAutoInconsistent(multiImage && !pedited->pdsharpening.autoContrast); dradius->setAutoInconsistent(multiImage && !pedited->pdsharpening.autoRadius); - gamma->setEditedState(pedited->pdsharpening.gamma ? Edited : UnEdited); dradius->setEditedState(pedited->pdsharpening.deconvradius ? Edited : UnEdited); dradiusOffset->setEditedState(pedited->pdsharpening.deconvradiusOffset ? Edited : UnEdited); diter->setEditedState(pedited->pdsharpening.deconviter ? Edited : UnEdited); @@ -113,7 +106,6 @@ void PdSharpening::read(const ProcParams* pp, const ParamsEdited* pedited) contrast->setValue(pp->pdsharpening.contrast); contrast->setAutoValue(pp->pdsharpening.autoContrast); - gamma->setValue(pp->pdsharpening.gamma); dradius->setValue(pp->pdsharpening.deconvradius); dradius->setAutoValue(pp->pdsharpening.autoRadius); dradiusOffset->setValue(pp->pdsharpening.deconvradiusOffset); @@ -130,7 +122,6 @@ void PdSharpening::write(ProcParams* pp, ParamsEdited* pedited) pp->pdsharpening.contrast = contrast->getValue(); pp->pdsharpening.autoContrast = contrast->getAutoValue(); pp->pdsharpening.enabled = getEnabled(); - pp->pdsharpening.gamma = gamma->getValue(); pp->pdsharpening.deconvradius = dradius->getValue(); pp->pdsharpening.autoRadius = dradius->getAutoValue(); pp->pdsharpening.deconvradiusOffset = dradiusOffset->getValue(); @@ -139,7 +130,6 @@ void PdSharpening::write(ProcParams* pp, ParamsEdited* pedited) if (pedited) { pedited->pdsharpening.contrast = contrast->getEditedState(); pedited->pdsharpening.autoContrast = !contrast->getAutoInconsistent(); - pedited->pdsharpening.gamma = gamma->getEditedState(); pedited->pdsharpening.deconvradius = dradius->getEditedState(); pedited->pdsharpening.autoRadius = !dradius->getAutoInconsistent(); pedited->pdsharpening.deconvradiusOffset = dradiusOffset->getEditedState(); @@ -152,20 +142,17 @@ void PdSharpening::setDefaults(const ProcParams* defParams, const ParamsEdited* { contrast->setDefault(defParams->pdsharpening.contrast); - gamma->setDefault(defParams->pdsharpening.gamma); dradius->setDefault(defParams->pdsharpening.deconvradius); dradiusOffset->setDefault(defParams->pdsharpening.deconvradiusOffset); diter->setDefault(defParams->pdsharpening.deconviter); if (pedited) { contrast->setDefaultEditedState(pedited->pdsharpening.contrast ? Edited : UnEdited); - gamma->setDefaultEditedState(pedited->pdsharpening.gamma ? Edited : UnEdited); dradius->setDefaultEditedState(pedited->pdsharpening.deconvradius ? Edited : UnEdited); dradiusOffset->setDefaultEditedState(pedited->pdsharpening.deconvradiusOffset ? Edited : UnEdited); diter->setDefaultEditedState(pedited->pdsharpening.deconviter ? Edited : UnEdited); } else { contrast->setDefaultEditedState(Irrelevant); - gamma->setDefaultEditedState(Irrelevant); dradius->setDefaultEditedState(Irrelevant); dradiusOffset->setDefaultEditedState(Irrelevant); diter->setDefaultEditedState(Irrelevant); @@ -178,7 +165,7 @@ void PdSharpening::adjusterChanged(Adjuster* a, double newval) Glib::ustring costr; - if (a == gamma || a == dradius || a == dradiusOffset) { + if (a == dradius || a == dradiusOffset) { costr = Glib::ustring::format(std::setw(3), std::fixed, std::setprecision(2), a->getValue()); } else { costr = Glib::ustring::format((int)a->getValue()); @@ -186,8 +173,6 @@ void PdSharpening::adjusterChanged(Adjuster* a, double newval) if (a == contrast) { listener->panelChanged(EvPdShrContrast, costr); - } else if (a == gamma) { - listener->panelChanged(EvPdSharpenGamma, costr); } else if (a == dradius) { listener->panelChanged(EvPdShrDRadius, costr); } else if (a == dradiusOffset) { @@ -217,17 +202,15 @@ void PdSharpening::setBatchMode(bool batchMode) ToolPanel::setBatchMode(batchMode); contrast->showEditedCB(); - gamma->showEditedCB(); dradius->showEditedCB(); dradiusOffset->showEditedCB(); diter->showEditedCB(); } -void PdSharpening::setAdjusterBehavior(bool contrastadd, bool gammaadd, bool radiusadd, bool iteradd) +void PdSharpening::setAdjusterBehavior(bool contrastadd, bool radiusadd, bool iteradd) { contrast->setAddMode(contrastadd); - gamma->setAddMode(gammaadd); dradius->setAddMode(radiusadd); dradiusOffset->setAddMode(radiusadd); diter->setAddMode(iteradd); @@ -237,7 +220,6 @@ void PdSharpening::trimValues(rtengine::procparams::ProcParams* pp) { contrast->trimValue(pp->pdsharpening.contrast); - gamma->trimValue(pp->pdsharpening.gamma); dradius->trimValue(pp->pdsharpening.deconvradius); dradiusOffset->trimValue(pp->pdsharpening.deconvradiusOffset); diter->trimValue(pp->pdsharpening.deconviter); @@ -271,47 +253,25 @@ void PdSharpening::autoRadiusChanged(double autoRadius) void PdSharpening::adjusterAutoToggled(Adjuster* a, bool newval) { - if (a == contrast) { - if (multiImage) { - if (contrast->getAutoInconsistent()) { - contrast->setAutoInconsistent(false); - contrast->setAutoValue(false); - } else if (lastAutoContrast) { - contrast->setAutoInconsistent(true); - } - - lastAutoContrast = contrast->getAutoValue(); + if (multiImage) { + if (a->getAutoInconsistent()) { + a->setAutoInconsistent(false); + a->setAutoValue(false); + } else if (lastAutoRadius) { + a->setAutoInconsistent(true); } - if (listener) { - if (contrast->getAutoInconsistent()) { - listener->panelChanged(EvPdShrAutoContrast, M("GENERAL_UNCHANGED")); - } else if (contrast->getAutoValue()) { - listener->panelChanged(EvPdShrAutoContrast, M("GENERAL_ENABLED")); - } else { - listener->panelChanged(EvPdShrAutoContrast, M("GENERAL_DISABLED")); - } - } - } else { // must be dradius - if (multiImage) { - if (dradius->getAutoInconsistent()) { - dradius->setAutoInconsistent(false); - dradius->setAutoValue(false); - } else if (lastAutoRadius) { - dradius->setAutoInconsistent(true); - } + (a == contrast ? lastAutoContrast : lastAutoRadius) = a->getAutoValue(); + } - lastAutoRadius = dradius->getAutoValue(); - } - - if (listener) { - if (dradius->getAutoInconsistent()) { - listener->panelChanged(EvPdShrAutoRadius, M("GENERAL_UNCHANGED")); - } else if (dradius->getAutoValue()) { - listener->panelChanged(EvPdShrAutoRadius, M("GENERAL_ENABLED")); - } else { - listener->panelChanged(EvPdShrAutoRadius, M("GENERAL_DISABLED")); - } + if (listener) { + const auto event = (a == contrast ? EvPdShrAutoContrast : EvPdShrAutoRadius); + if (a->getAutoInconsistent()) { + listener->panelChanged(event, M("GENERAL_UNCHANGED")); + } else if (a->getAutoValue()) { + listener->panelChanged(event, M("GENERAL_ENABLED")); + } else { + listener->panelChanged(event, M("GENERAL_DISABLED")); } } } diff --git a/rtgui/pdsharpening.h b/rtgui/pdsharpening.h index f621fd0a5..61d80503f 100644 --- a/rtgui/pdsharpening.h +++ b/rtgui/pdsharpening.h @@ -26,7 +26,6 @@ class PdSharpening final : public ToolParamBlock, public AdjusterListener, publi protected: Adjuster* contrast; - Adjuster* gamma; Adjuster* dradius; Adjuster* dradiusOffset; Adjuster* diter; @@ -36,7 +35,6 @@ protected: rtengine::ProcEvent EvPdShrContrast; rtengine::ProcEvent EvPdShrDRadius; rtengine::ProcEvent EvPdShrDRadiusOffset; - rtengine::ProcEvent EvPdSharpenGamma; rtengine::ProcEvent EvPdShrDIterations; rtengine::ProcEvent EvPdShrAutoContrast; rtengine::ProcEvent EvPdShrAutoRadius; @@ -59,6 +57,6 @@ public: void autoContrastChanged (double autoContrast) override; void autoRadiusChanged (double autoRadius) override; - void setAdjusterBehavior (bool contrastadd, bool gammaadd, bool radiusadd, bool iteradds); + void setAdjusterBehavior (bool contrastadd, bool radiusadd, bool iteradds); void trimValues (rtengine::procparams::ProcParams* pp) override; };