buildBlendMask: remove multiplication by amount as amount always was 1
This commit is contained in:
@@ -800,7 +800,7 @@ BENCHFUN
|
|||||||
}
|
}
|
||||||
|
|
||||||
array2D<float>& blend = red; // red will be overridden anyway => we can use its buffer to store the blend mask
|
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, clipMask);
|
buildBlendMask(L, blend, W, H, contrast, sharpeningParams.autoContrast, clipMask);
|
||||||
if (plistener) {
|
if (plistener) {
|
||||||
plistener->setProgress(0.2);
|
plistener->setProgress(0.2);
|
||||||
}
|
}
|
||||||
@@ -849,7 +849,7 @@ BENCHFUN
|
|||||||
}
|
}
|
||||||
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
|
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
|
||||||
array2D<float>& blend = clipMask; // we can share blend and clipMask buffer here
|
array2D<float>& blend = clipMask; // we can share blend and clipMask buffer here
|
||||||
buildBlendMask(L, blend, W, H, contrast, 1.f, sharpeningParams.autoContrast, clipMask);
|
buildBlendMask(L, blend, W, H, contrast, sharpeningParams.autoContrast, clipMask);
|
||||||
if (plistener) {
|
if (plistener) {
|
||||||
plistener->setProgress(0.2);
|
plistener->setProgress(0.2);
|
||||||
}
|
}
|
||||||
|
@@ -105,7 +105,7 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const procparams::RAWParams
|
|||||||
JaggedArray<float> blend(winw, winh);
|
JaggedArray<float> blend(winw, winh);
|
||||||
float contrastf = contrast / 100.f;
|
float contrastf = contrast / 100.f;
|
||||||
|
|
||||||
buildBlendMask(L, blend, winw, winh, contrastf, 1.f, autoContrast);
|
buildBlendMask(L, blend, winw, winh, contrastf, autoContrast);
|
||||||
contrast = contrastf * 100.f;
|
contrast = contrastf * 100.f;
|
||||||
|
|
||||||
array2D<float>& redTmp = L; // L is not needed anymore => reuse it
|
array2D<float>& redTmp = L; // L is not needed anymore => reuse it
|
||||||
|
@@ -256,7 +256,7 @@ void ImProcFunctions::sharpening (LabImage* lab, const procparams::SharpeningPar
|
|||||||
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
|
// calculate contrast based blend factors to reduce sharpening in regions with low contrast
|
||||||
JaggedArray<float> blend(W, H);
|
JaggedArray<float> blend(W, H);
|
||||||
float contrast = sharpenParam.contrast / 100.f;
|
float contrast = sharpenParam.contrast / 100.f;
|
||||||
buildBlendMask(lab->L, blend, W, H, contrast, 1.f);
|
buildBlendMask(lab->L, blend, W, H, contrast);
|
||||||
|
|
||||||
if(showMask) {
|
if(showMask) {
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
|
@@ -299,7 +299,7 @@ void findMinMaxPercentile(const float* data, size_t size, float minPrct, float&
|
|||||||
maxOut = rtengine::LIM(maxOut, minVal, maxVal);
|
maxOut = rtengine::LIM(maxOut, minVal, maxVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildBlendMask(const float* const * luminance, float **blend, int W, int H, float &contrastThreshold, float amount, bool autoContrast, float ** clipMask) {
|
void buildBlendMask(const float* const * luminance, float **blend, int W, int H, float &contrastThreshold, bool autoContrast, float ** clipMask) {
|
||||||
|
|
||||||
if (autoContrast) {
|
if (autoContrast) {
|
||||||
constexpr float minLuminance = 2000.f;
|
constexpr float minLuminance = 2000.f;
|
||||||
@@ -403,7 +403,7 @@ void buildBlendMask(const float* const * luminance, float **blend, int W, int H,
|
|||||||
if(contrastThreshold == 0.f) {
|
if(contrastThreshold == 0.f) {
|
||||||
for(int j = 0; j < H; ++j) {
|
for(int j = 0; j < H; ++j) {
|
||||||
for(int i = 0; i < W; ++i) {
|
for(int i = 0; i < W; ++i) {
|
||||||
blend[j][i] = amount;
|
blend[j][i] = 1.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -415,7 +415,6 @@ void buildBlendMask(const float* const * luminance, float **blend, int W, int H,
|
|||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
const vfloat contrastThresholdv = F2V(contrastThreshold);
|
const vfloat contrastThresholdv = F2V(contrastThreshold);
|
||||||
const vfloat scalev = F2V(scale);
|
const vfloat scalev = F2V(scale);
|
||||||
const vfloat amountv = F2V(amount);
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp for schedule(dynamic,16)
|
#pragma omp for schedule(dynamic,16)
|
||||||
@@ -429,14 +428,14 @@ void buildBlendMask(const float* const * luminance, float **blend, int W, int H,
|
|||||||
vfloat contrastv = vsqrtf(SQRV(LVFU(luminance[j][i+1]) - LVFU(luminance[j][i-1])) + SQRV(LVFU(luminance[j+1][i]) - LVFU(luminance[j-1][i])) +
|
vfloat contrastv = vsqrtf(SQRV(LVFU(luminance[j][i+1]) - LVFU(luminance[j][i-1])) + SQRV(LVFU(luminance[j+1][i]) - LVFU(luminance[j-1][i])) +
|
||||||
SQRV(LVFU(luminance[j][i+2]) - LVFU(luminance[j][i-2])) + SQRV(LVFU(luminance[j+2][i]) - LVFU(luminance[j-2][i]))) * scalev;
|
SQRV(LVFU(luminance[j][i+2]) - LVFU(luminance[j][i-2])) + SQRV(LVFU(luminance[j+2][i]) - LVFU(luminance[j-2][i]))) * scalev;
|
||||||
|
|
||||||
STVFU(blend[j][i], LVFU(clipMask[j][i]) * amountv * calcBlendFactor(contrastv, contrastThresholdv));
|
STVFU(blend[j][i], LVFU(clipMask[j][i]) * calcBlendFactor(contrastv, contrastThresholdv));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(; i < W - 5; i += 4) {
|
for(; i < W - 5; i += 4) {
|
||||||
vfloat contrastv = vsqrtf(SQRV(LVFU(luminance[j][i+1]) - LVFU(luminance[j][i-1])) + SQRV(LVFU(luminance[j+1][i]) - LVFU(luminance[j-1][i])) +
|
vfloat contrastv = vsqrtf(SQRV(LVFU(luminance[j][i+1]) - LVFU(luminance[j][i-1])) + SQRV(LVFU(luminance[j+1][i]) - LVFU(luminance[j-1][i])) +
|
||||||
SQRV(LVFU(luminance[j][i+2]) - LVFU(luminance[j][i-2])) + SQRV(LVFU(luminance[j+2][i]) - LVFU(luminance[j-2][i]))) * scalev;
|
SQRV(LVFU(luminance[j][i+2]) - LVFU(luminance[j][i-2])) + SQRV(LVFU(luminance[j+2][i]) - LVFU(luminance[j-2][i]))) * scalev;
|
||||||
|
|
||||||
STVFU(blend[j][i], amountv * calcBlendFactor(contrastv, contrastThresholdv));
|
STVFU(blend[j][i], calcBlendFactor(contrastv, contrastThresholdv));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -445,7 +444,7 @@ void buildBlendMask(const float* const * luminance, float **blend, int W, int H,
|
|||||||
float contrast = sqrtf(rtengine::SQR(luminance[j][i+1] - luminance[j][i-1]) + rtengine::SQR(luminance[j+1][i] - luminance[j-1][i]) +
|
float contrast = sqrtf(rtengine::SQR(luminance[j][i+1] - luminance[j][i-1]) + rtengine::SQR(luminance[j+1][i] - luminance[j-1][i]) +
|
||||||
rtengine::SQR(luminance[j][i+2] - luminance[j][i-2]) + rtengine::SQR(luminance[j+2][i] - luminance[j-2][i])) * scale;
|
rtengine::SQR(luminance[j][i+2] - luminance[j][i-2]) + rtengine::SQR(luminance[j+2][i] - luminance[j-2][i])) * scale;
|
||||||
|
|
||||||
blend[j][i] = (clipMask ? clipMask[j][i] : 1.f) * amount * calcBlendFactor(contrast, contrastThreshold);
|
blend[j][i] = (clipMask ? clipMask[j][i] : 1.f) * calcBlendFactor(contrast, contrastThreshold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,5 +24,5 @@
|
|||||||
namespace rtengine
|
namespace rtengine
|
||||||
{
|
{
|
||||||
void findMinMaxPercentile(const float* data, size_t size, float minPrct, float& minOut, float maxPrct, float& maxOut, bool multiThread = true);
|
void findMinMaxPercentile(const float* data, size_t size, float minPrct, float& minOut, float maxPrct, float& maxOut, bool multiThread = true);
|
||||||
void buildBlendMask(const float* const * luminance, float **blend, int W, int H, float &contrastThreshold, float amount = 1.f, bool autoContrast = false, float ** clipmask = nullptr);
|
void buildBlendMask(const float* const * luminance, float **blend, int W, int H, float &contrastThreshold, bool autoContrast = false, float ** clipmask = nullptr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user