capture sharpening: own compilation unit, smooth progressbar, #5412
This commit is contained in:
parent
ad52c4afc6
commit
f882309f59
@ -32,6 +32,7 @@ set(CAMCONSTSFILE "camconst.json")
|
|||||||
set(RTENGINESOURCEFILES
|
set(RTENGINESOURCEFILES
|
||||||
badpixels.cc
|
badpixels.cc
|
||||||
CA_correct_RT.cc
|
CA_correct_RT.cc
|
||||||
|
capturesharpening.cc
|
||||||
EdgePreservingDecomposition.cc
|
EdgePreservingDecomposition.cc
|
||||||
FTblockDN.cc
|
FTblockDN.cc
|
||||||
PF_correct_RT.cc
|
PF_correct_RT.cc
|
||||||
|
218
rtengine/capturesharpening.cc
Normal file
218
rtengine/capturesharpening.cc
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of RawTherapee.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Ingo Weyrich (heckflosse67@gmx.de)
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <cmath>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "jaggedarray.h"
|
||||||
|
#include "rtengine.h"
|
||||||
|
#include "rawimagesource.h"
|
||||||
|
#include "rt_math.h"
|
||||||
|
#include "improcfun.h"
|
||||||
|
#include "procparams.h"
|
||||||
|
#include "color.h"
|
||||||
|
#include "gauss.h"
|
||||||
|
#include "rt_algo.h"
|
||||||
|
#define BENCHMARK
|
||||||
|
#include "StopWatch.h"
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#include <omp.h>
|
||||||
|
#endif
|
||||||
|
#include "opthelper.h"
|
||||||
|
#include "../rtgui/multilangmgr.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void CaptureDeconvSharpening (float** luminance, float** tmp, const float * const * blend, int W, int H, double sigma, int iterations, rtengine::ProgressListener* plistener, double start, double step)
|
||||||
|
{
|
||||||
|
|
||||||
|
rtengine::JaggedArray<float> tmpI(W, H);
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp for
|
||||||
|
#endif
|
||||||
|
for (int i = 0; i < H; i++) {
|
||||||
|
for(int j = 0; j < W; j++) {
|
||||||
|
tmpI[i][j] = max(luminance[i][j], 0.f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k < iterations; k++) {
|
||||||
|
// apply gaussian blur and divide luminance by result of gaussian blur
|
||||||
|
gaussianBlur(tmpI, tmp, W, H, sigma, nullptr, GAUSS_DIV, luminance);
|
||||||
|
gaussianBlur(tmp, tmpI, W, H, sigma, nullptr, GAUSS_MULT);
|
||||||
|
if (plistener) {
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp single
|
||||||
|
#endif
|
||||||
|
start += step;
|
||||||
|
plistener->setProgress(start);
|
||||||
|
}
|
||||||
|
} // end for
|
||||||
|
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp for
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < H; ++i) {
|
||||||
|
for (int j = 0; j < W; ++j) {
|
||||||
|
luminance[i][j] = rtengine::intp(blend[i][j], max(tmpI[i][j], 0.0f), luminance[i][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // end parallel
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace rtengine
|
||||||
|
{
|
||||||
|
|
||||||
|
void RawImageSource::captureSharpening(const procparams::CaptureSharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) {
|
||||||
|
BENCHFUN
|
||||||
|
|
||||||
|
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgressStr(M("TP_PDSHARPENING_LABEL"));
|
||||||
|
plistener->setProgress(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const 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 }
|
||||||
|
};
|
||||||
|
|
||||||
|
float contrast = conrastThreshold / 100.f;
|
||||||
|
|
||||||
|
array2D<float>& redVals = redCache ? *redCache : red;
|
||||||
|
array2D<float>& greenVals = greenCache ? *greenCache : green;
|
||||||
|
array2D<float>& blueVals = blueCache ? *blueCache : blue;
|
||||||
|
|
||||||
|
if (showMask) {
|
||||||
|
StopWatch Stop1("Show mask");
|
||||||
|
array2D<float>& L = blue; // blue will be overridden anyway => we can use its buffer to store L
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int i = 0; i < H; ++i) {
|
||||||
|
Color::RGB2L(redVals[i], greenVals[i], blueVals[i], L[i], xyz_rgb, W);
|
||||||
|
}
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgress(0.1);
|
||||||
|
}
|
||||||
|
array2D<float>& blend = red; // red will be overridden anyway => we can use its buffer to store the blend mask
|
||||||
|
buildBlendMask(L, blend, W, H, contrast, 1.f, sharpeningParams.autoContrast);
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgress(0.2);
|
||||||
|
}
|
||||||
|
conrastThreshold = contrast * 100.f;
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for
|
||||||
|
#endif
|
||||||
|
for (int i = 0; i < H; ++i) {
|
||||||
|
for (int j = 0; j < W; ++j) {
|
||||||
|
red[i][j] = green[i][j] = blue[i][j] = blend[i][j] * 16384.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgress(1.0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
array2D<float>* Lbuffer = nullptr;
|
||||||
|
if (!redCache) {
|
||||||
|
Lbuffer = new array2D<float>(W, H);
|
||||||
|
}
|
||||||
|
|
||||||
|
array2D<float>* YOldbuffer = nullptr;
|
||||||
|
if (!greenCache) {
|
||||||
|
YOldbuffer = new array2D<float>(W, H);
|
||||||
|
}
|
||||||
|
|
||||||
|
array2D<float>* YNewbuffer = nullptr;
|
||||||
|
if (!blueCache) {
|
||||||
|
YNewbuffer = new array2D<float>(W, H);
|
||||||
|
}
|
||||||
|
array2D<float>& L = Lbuffer ? *Lbuffer : red;
|
||||||
|
array2D<float>& YOld = YOldbuffer ? * YOldbuffer : green;
|
||||||
|
array2D<float>& YNew = YNewbuffer ? * YNewbuffer : blue;
|
||||||
|
|
||||||
|
StopWatch Stop1("rgb2YL");
|
||||||
|
#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], sharpeningParams.gamma, W);
|
||||||
|
}
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgress(0.1);
|
||||||
|
}
|
||||||
|
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
|
||||||
|
JaggedArray<float> blend(W, H);
|
||||||
|
buildBlendMask(L, blend, W, H, contrast, 1.f, sharpeningParams.autoContrast);
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgress(0.2);
|
||||||
|
}
|
||||||
|
conrastThreshold = contrast * 100.f;
|
||||||
|
|
||||||
|
Stop1.stop();
|
||||||
|
array2D<float>& tmp = L; // L is not used anymore now => we can use its buffer as the needed temporary buffer
|
||||||
|
CaptureDeconvSharpening(YNew, tmp, blend, W, H, sharpeningParams.deconvradius, sharpeningParams.deconviter, plistener, 0.2, (0.9 - 0.2) / sharpeningParams.deconviter);
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgress(0.9);
|
||||||
|
}
|
||||||
|
StopWatch Stop2("Y2RGB");
|
||||||
|
const float gamma = sharpeningParams.gamma;
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp parallel for schedule(dynamic, 16)
|
||||||
|
#endif
|
||||||
|
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(LVFU(YNew[i][j]) / vmaxf(LVFU(YOld[i][j]), F2V(0.00001f)), gammav);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
for (; j < W; ++j) {
|
||||||
|
const float factor = pow_F(YNew[i][j] / std::max(YOld[i][j], 0.00001f), gamma);
|
||||||
|
red[i][j] = redVals[i][j] * factor;
|
||||||
|
green[i][j] = greenVals[i][j] * factor;
|
||||||
|
blue[i][j] = blueVals[i][j] * factor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Stop2.stop();
|
||||||
|
delete Lbuffer;
|
||||||
|
delete YOldbuffer;
|
||||||
|
delete YNewbuffer;
|
||||||
|
if (plistener) {
|
||||||
|
plistener->setProgress(1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace */
|
@ -46,7 +46,7 @@ struct LensProfParams;
|
|||||||
struct RAWParams;
|
struct RAWParams;
|
||||||
struct RetinexParams;
|
struct RetinexParams;
|
||||||
struct ToneCurveParams;
|
struct ToneCurveParams;
|
||||||
struct SharpeningParams;
|
struct CaptureSharpeningParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageMatrices
|
class ImageMatrices
|
||||||
@ -182,7 +182,7 @@ public:
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
virtual void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) = 0;
|
virtual void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) = 0;
|
||||||
virtual void captureSharpening(const procparams::SharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) = 0;
|
virtual void captureSharpening(const procparams::CaptureSharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1149,6 +1149,32 @@ bool SharpeningParams::operator !=(const SharpeningParams& other) const
|
|||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CaptureSharpeningParams::CaptureSharpeningParams() :
|
||||||
|
enabled(false),
|
||||||
|
autoContrast(true),
|
||||||
|
contrast(10.0),
|
||||||
|
gamma(1.35),
|
||||||
|
deconvradius(0.75),
|
||||||
|
deconviter(30)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CaptureSharpeningParams::operator ==(const CaptureSharpeningParams& other) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
enabled == other.enabled
|
||||||
|
&& contrast == other.contrast
|
||||||
|
&& gamma == other.gamma
|
||||||
|
&& autoContrast == other.autoContrast
|
||||||
|
&& deconvradius == other.deconvradius
|
||||||
|
&& deconviter == other.deconviter;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CaptureSharpeningParams::operator !=(const CaptureSharpeningParams& other) const
|
||||||
|
{
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
SharpenEdgeParams::SharpenEdgeParams() :
|
SharpenEdgeParams::SharpenEdgeParams() :
|
||||||
enabled(false),
|
enabled(false),
|
||||||
passes(2),
|
passes(2),
|
||||||
@ -2830,12 +2856,6 @@ void ProcParams::setDefaults()
|
|||||||
prsharpening.deconvdamping = 0;
|
prsharpening.deconvdamping = 0;
|
||||||
|
|
||||||
pdsharpening = {};
|
pdsharpening = {};
|
||||||
pdsharpening.contrast = 10.0;
|
|
||||||
pdsharpening.autoContrast = true;
|
|
||||||
prsharpening.method = "rld";
|
|
||||||
pdsharpening.gamma = 1.35;
|
|
||||||
pdsharpening.deconvradius = 0.75;
|
|
||||||
pdsharpening.deconviter = 30;
|
|
||||||
|
|
||||||
vibrance = {};
|
vibrance = {};
|
||||||
|
|
||||||
|
@ -542,6 +542,20 @@ struct SharpenMicroParams {
|
|||||||
bool operator !=(const SharpenMicroParams& other) const;
|
bool operator !=(const SharpenMicroParams& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CaptureSharpeningParams {
|
||||||
|
bool enabled;
|
||||||
|
bool autoContrast;
|
||||||
|
double contrast;
|
||||||
|
double gamma;
|
||||||
|
double deconvradius;
|
||||||
|
int deconviter;
|
||||||
|
|
||||||
|
CaptureSharpeningParams();
|
||||||
|
|
||||||
|
bool operator ==(const CaptureSharpeningParams& other) const;
|
||||||
|
bool operator !=(const CaptureSharpeningParams& other) const;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters of the vibrance
|
* Parameters of the vibrance
|
||||||
*/
|
*/
|
||||||
@ -1530,7 +1544,7 @@ public:
|
|||||||
ColorToningParams colorToning; ///< Color Toning parameters
|
ColorToningParams colorToning; ///< Color Toning parameters
|
||||||
SharpeningParams sharpening; ///< Sharpening parameters
|
SharpeningParams sharpening; ///< Sharpening parameters
|
||||||
SharpeningParams prsharpening; ///< Sharpening parameters for post resize sharpening
|
SharpeningParams prsharpening; ///< Sharpening parameters for post resize sharpening
|
||||||
SharpeningParams pdsharpening; ///< Sharpening parameters for post demosaic sharpening
|
CaptureSharpeningParams pdsharpening; ///< Sharpening parameters for post demosaic sharpening
|
||||||
SharpenEdgeParams sharpenEdge; ///< Sharpen edge parameters
|
SharpenEdgeParams sharpenEdge; ///< Sharpen edge parameters
|
||||||
SharpenMicroParams sharpenMicro; ///< Sharpen microcontrast parameters
|
SharpenMicroParams sharpenMicro; ///< Sharpen microcontrast parameters
|
||||||
VibranceParams vibrance; ///< Vibrance parameters
|
VibranceParams vibrance; ///< Vibrance parameters
|
||||||
|
@ -38,14 +38,12 @@
|
|||||||
#include "camconst.h"
|
#include "camconst.h"
|
||||||
#include "procparams.h"
|
#include "procparams.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "rt_algo.h"
|
//#define BENCHMARK
|
||||||
#define BENCHMARK
|
//#include "StopWatch.h"
|
||||||
#include "StopWatch.h"
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
#include "opthelper.h"
|
#include "opthelper.h"
|
||||||
#include "../rtgui/multilangmgr.h"
|
|
||||||
#define clipretinex( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val )
|
#define clipretinex( val, minv, maxv ) (( val = (val < minv ? minv : val ) ) > maxv ? maxv : val )
|
||||||
#undef CLIPD
|
#undef CLIPD
|
||||||
#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f)
|
#define CLIPD(a) ((a)>0.0f?((a)<1.0f?(a):1.0f):0.0f)
|
||||||
@ -5000,138 +4998,6 @@ void RawImageSource::getRawValues(int x, int y, int rotate, int &R, int &G, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawImageSource::captureSharpening(const procparams::SharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) {
|
|
||||||
BENCHFUN
|
|
||||||
|
|
||||||
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgressStr(M("TP_PDSHARPENING_LABEL"));
|
|
||||||
plistener->setProgress(0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const 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 }
|
|
||||||
};
|
|
||||||
|
|
||||||
float contrast = conrastThreshold / 100.f;
|
|
||||||
|
|
||||||
array2D<float>& redVals = redCache ? *redCache : red;
|
|
||||||
array2D<float>& greenVals = greenCache ? *greenCache : green;
|
|
||||||
array2D<float>& blueVals = blueCache ? *blueCache : blue;
|
|
||||||
|
|
||||||
if (showMask) {
|
|
||||||
StopWatch Stop1("Show mask");
|
|
||||||
array2D<float>& L = blue; // blue will be overridden anyway => we can use its buffer to store L
|
|
||||||
#ifdef _OPENMP
|
|
||||||
#pragma omp parallel for
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < H; ++i) {
|
|
||||||
Color::RGB2L(redVals[i], greenVals[i], blueVals[i], L[i], xyz_rgb, W);
|
|
||||||
}
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgress(0.1);
|
|
||||||
}
|
|
||||||
array2D<float>& blend = red; // red will be overridden anyway => we can use its buffer to store the blend mask
|
|
||||||
buildBlendMask(L, blend, W, H, contrast, 1.f, sharpeningParams.autoContrast);
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgress(0.2);
|
|
||||||
}
|
|
||||||
conrastThreshold = contrast * 100.f;
|
|
||||||
#ifdef _OPENMP
|
|
||||||
#pragma omp parallel for
|
|
||||||
#endif
|
|
||||||
for (int i = 0; i < H; ++i) {
|
|
||||||
for (int j = 0; j < W; ++j) {
|
|
||||||
red[i][j] = green[i][j] = blue[i][j] = blend[i][j] * 16384.f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgress(1.0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
array2D<float>* Lbuffer = nullptr;
|
|
||||||
if (!redCache) {
|
|
||||||
Lbuffer = new array2D<float>(W, H);
|
|
||||||
}
|
|
||||||
|
|
||||||
array2D<float>* YOldbuffer = nullptr;
|
|
||||||
if (!greenCache) {
|
|
||||||
YOldbuffer = new array2D<float>(W, H);
|
|
||||||
}
|
|
||||||
|
|
||||||
array2D<float>* YNewbuffer = nullptr;
|
|
||||||
if (!blueCache) {
|
|
||||||
YNewbuffer = new array2D<float>(W, H);
|
|
||||||
}
|
|
||||||
array2D<float>& L = Lbuffer ? *Lbuffer : red;
|
|
||||||
array2D<float>& YOld = YOldbuffer ? * YOldbuffer : green;
|
|
||||||
array2D<float>& YNew = YNewbuffer ? * YNewbuffer : blue;
|
|
||||||
|
|
||||||
StopWatch Stop1("rgb2YL");
|
|
||||||
#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], sharpeningParams.gamma, W);
|
|
||||||
}
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgress(0.1);
|
|
||||||
}
|
|
||||||
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
|
|
||||||
JaggedArray<float> blend(W, H);
|
|
||||||
buildBlendMask(L, blend, W, H, contrast, 1.f, sharpeningParams.autoContrast);
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgress(0.2);
|
|
||||||
}
|
|
||||||
conrastThreshold = contrast * 100.f;
|
|
||||||
|
|
||||||
Stop1.stop();
|
|
||||||
array2D<float>& tmp = L; // L is not used anymore now => we can use its buffer as the needed temporary buffer
|
|
||||||
ProcParams dummy;
|
|
||||||
ImProcFunctions ipf(&dummy);
|
|
||||||
ipf.deconvsharpening(YNew, tmp, blend, W, H, sharpeningParams, 1.0);
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgress(0.9);
|
|
||||||
}
|
|
||||||
StopWatch Stop2("Y2RGB");
|
|
||||||
const float gamma = sharpeningParams.gamma;
|
|
||||||
#ifdef _OPENMP
|
|
||||||
#pragma omp parallel for schedule(dynamic, 16)
|
|
||||||
#endif
|
|
||||||
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(LVFU(YNew[i][j]) / vmaxf(LVFU(YOld[i][j]), F2V(0.00001f)), gammav);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
for (; j < W; ++j) {
|
|
||||||
const float factor = pow_F(YNew[i][j] / std::max(YOld[i][j], 0.00001f), gamma);
|
|
||||||
red[i][j] = redVals[i][j] * factor;
|
|
||||||
green[i][j] = greenVals[i][j] * factor;
|
|
||||||
blue[i][j] = blueVals[i][j] * factor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Stop2.stop();
|
|
||||||
delete Lbuffer;
|
|
||||||
delete YOldbuffer;
|
|
||||||
delete YNewbuffer;
|
|
||||||
if (plistener) {
|
|
||||||
plistener->setProgress(1.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RawImageSource::cleanup ()
|
void RawImageSource::cleanup ()
|
||||||
{
|
{
|
||||||
delete phaseOneIccCurve;
|
delete phaseOneIccCurve;
|
||||||
|
@ -311,7 +311,7 @@ protected:
|
|||||||
void hflip (Imagefloat* im);
|
void hflip (Imagefloat* im);
|
||||||
void vflip (Imagefloat* im);
|
void vflip (Imagefloat* im);
|
||||||
void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) override;
|
void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) override;
|
||||||
void captureSharpening(const procparams::SharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) override;
|
void captureSharpening(const procparams::CaptureSharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public:
|
|||||||
void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) override { R = G = B = 0;}
|
void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) override { R = G = B = 0;}
|
||||||
|
|
||||||
void flushRGB () override;
|
void flushRGB () override;
|
||||||
void captureSharpening(const procparams::SharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) override {};
|
void captureSharpening(const procparams::CaptureSharpeningParams &sharpeningParams, bool showMask, double &conrastThreshold) override {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,7 +169,6 @@ void ParamsEdited::set(bool v)
|
|||||||
pdsharpening.contrast = v;
|
pdsharpening.contrast = v;
|
||||||
pdsharpening.autoContrast = v;
|
pdsharpening.autoContrast = v;
|
||||||
pdsharpening.gamma = v;
|
pdsharpening.gamma = v;
|
||||||
pdsharpening.deconvamount = v;
|
|
||||||
pdsharpening.deconvradius = v;
|
pdsharpening.deconvradius = v;
|
||||||
pdsharpening.deconviter = v;
|
pdsharpening.deconviter = v;
|
||||||
prsharpening.enabled = v;
|
prsharpening.enabled = v;
|
||||||
@ -1733,10 +1732,6 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
|
|||||||
toEdit.pdsharpening.autoContrast = mods.pdsharpening.autoContrast;
|
toEdit.pdsharpening.autoContrast = mods.pdsharpening.autoContrast;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdsharpening.deconvamount) {
|
|
||||||
toEdit.pdsharpening.deconvamount = dontforceSet && options.baBehav[ADDSET_SHARP_AMOUNT] ? toEdit.pdsharpening.deconvamount + mods.pdsharpening.deconvamount : mods.pdsharpening.deconvamount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pdsharpening.gamma) {
|
if (pdsharpening.gamma) {
|
||||||
toEdit.pdsharpening.gamma = dontforceSet && options.baBehav[ADDSET_SHARP_GAMMA] ? toEdit.pdsharpening.gamma + mods.pdsharpening.gamma : mods.pdsharpening.gamma;
|
toEdit.pdsharpening.gamma = dontforceSet && options.baBehav[ADDSET_SHARP_GAMMA] ? toEdit.pdsharpening.gamma + mods.pdsharpening.gamma : mods.pdsharpening.gamma;
|
||||||
}
|
}
|
||||||
@ -3292,7 +3287,7 @@ bool FilmNegativeParamsEdited::isUnchanged() const
|
|||||||
return enabled && redRatio && greenExp && blueRatio;
|
return enabled && redRatio && greenExp && blueRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharpeningParamsEdited::isUnchanged() const
|
bool CaptureSharpeningParamsEdited::isUnchanged() const
|
||||||
{
|
{
|
||||||
return enabled && contrast && autoContrast && gamma && deconvradius && deconviter;
|
return enabled && contrast && autoContrast && gamma && deconvradius && deconviter;
|
||||||
}
|
}
|
@ -196,6 +196,15 @@ struct SharpeningParamsEdited {
|
|||||||
bool deconvradius;
|
bool deconvradius;
|
||||||
bool deconviter;
|
bool deconviter;
|
||||||
bool deconvdamping;
|
bool deconvdamping;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CaptureSharpeningParamsEdited {
|
||||||
|
bool enabled;
|
||||||
|
bool contrast;
|
||||||
|
bool autoContrast;
|
||||||
|
bool gamma;
|
||||||
|
bool deconvradius;
|
||||||
|
bool deconviter;
|
||||||
bool isUnchanged() const;
|
bool isUnchanged() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -687,7 +696,7 @@ struct ParamsEdited {
|
|||||||
ColorToningEdited colorToning;
|
ColorToningEdited colorToning;
|
||||||
RetinexParamsEdited retinex;
|
RetinexParamsEdited retinex;
|
||||||
SharpeningParamsEdited sharpening;
|
SharpeningParamsEdited sharpening;
|
||||||
SharpeningParamsEdited pdsharpening;
|
CaptureSharpeningParamsEdited pdsharpening;
|
||||||
SharpeningParamsEdited prsharpening;
|
SharpeningParamsEdited prsharpening;
|
||||||
SharpenEdgeParamsEdited sharpenEdge;
|
SharpenEdgeParamsEdited sharpenEdge;
|
||||||
SharpenMicroParamsEdited sharpenMicro;
|
SharpenMicroParamsEdited sharpenMicro;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user