solved merge conflicts for merge from dev into newlocallab

This commit is contained in:
heckflosse 2017-11-15 16:49:53 +01:00
commit 0df571b2db
63 changed files with 1212 additions and 1927 deletions

View File

@ -1,5 +1,8 @@
if(WIN32)
cmake_minimum_required(VERSION 2.8.4)
elseif(APPLE)
cmake_minimum_required(VERSION 3.3)
CMAKE_POLICY(SET CMP0025 NEW)
else()
cmake_minimum_required(VERSION 2.6)
endif()
@ -54,7 +57,8 @@ set(CACHE_NAME_SUFFIX "" CACHE STRING "RawTherapee's cache folder suffix")
set(PROC_TARGET_NUMBER 0 CACHE STRING "Selected target processor from the list above (taken from ProcessorTargets.cmake)")
# Set special compilation flags for rtengine which get added to CMAKE_CXX_FLAGS:
set(RTENGINE_CXX_FLAGS "" CACHE STRING "Special compilation flags for RTEngine")
# Some Linux distros build with -O2 instead of -O3. We explicitly enable auto vectorization by using -ftree-vectorize
set(RTENGINE_CXX_FLAGS "-ftree-vectorize" CACHE STRING "Special compilation flags for RTEngine")
# Loads the ProcessorTargets list:
include(ProcessorTargets.cmake)

View File

@ -72,6 +72,7 @@ set(RTENGINESOURCEFILES
imageio.cc
improccoordinator.cc
improcfun.cc
impulse_denoise.cc
init.cc
iplab2rgb.cc
iplocallab.cc

View File

@ -6,7 +6,6 @@
#endif
#include "sleef.c"
#include "opthelper.h"
#define pow_F(a,b) (xexpf(b*xlogf(a)))
#define DIAGONALS 5
#define DIAGONALSP1 6

View File

@ -424,7 +424,7 @@ void ImProcFunctions::Tile_calc(int tilesize, int overlap, int kall, int imwidth
int denoiseNestedLevels = 1;
enum nrquality {QUALITY_STANDARD, QUALITY_HIGH};
SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &chaut, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &nresi, float &highresi)
SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &nresi, float &highresi)
{
//#ifdef _DEBUG
MyTime t1e, t2e;
@ -2819,10 +2819,10 @@ SSEFUNCTION void ImProcFunctions::ShrinkAllAB(wavelet_decomposition &WaveletCoef
}
SSEFUNCTION void ImProcFunctions::ShrinkAll_info(float ** WavCoeffs_a, float ** WavCoeffs_b, int level,
int W_ab, int H_ab, int skip_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut,
float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, bool autoch, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc,
float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread)
SSEFUNCTION void ImProcFunctions::ShrinkAll_info(float ** WavCoeffs_a, float ** WavCoeffs_b,
int W_ab, int H_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut,
float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc,
float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb)
{
//simple wavelet shrinkage
@ -2938,8 +2938,8 @@ SSEFUNCTION void ImProcFunctions::ShrinkAll_info(float ** WavCoeffs_a, float **
void ImProcFunctions::WaveletDenoiseAll_info(int levwav, wavelet_decomposition &WaveletCoeffs_a,
wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice, bool autoch,
float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread)
wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice,
float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb)
{
int maxlvl = levwav;
@ -2949,14 +2949,12 @@ void ImProcFunctions::WaveletDenoiseAll_info(int levwav, wavelet_decomposition &
int Wlvl_ab = WaveletCoeffs_a.level_W(lvl);
int Hlvl_ab = WaveletCoeffs_a.level_H(lvl);
int skip_ab = WaveletCoeffs_a.level_stride(lvl);
float ** WavCoeffs_a = WaveletCoeffs_a.level_coeffs(lvl);
float ** WavCoeffs_b = WaveletCoeffs_b.level_coeffs(lvl);
ShrinkAll_info(WavCoeffs_a, WavCoeffs_b, lvl, Wlvl_ab, Hlvl_ab,
skip_ab, noisevarlum, noisevarchrom, noisevarhue, width, height, noisevar_abr, noisevar_abb, noi, chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut,
autoch, schoice, lvl, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, maxchred, maxchblue, minchred, minchblue, nb, chau, chred, chblue, denoiseMethodRgb, multiThread);
ShrinkAll_info(WavCoeffs_a, WavCoeffs_b, Wlvl_ab, Hlvl_ab,
noisevarlum, noisevarchrom, noisevarhue, chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut,
schoice, lvl, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, maxchred, maxchblue, minchred, minchblue, nb, chau, chred, chblue, denoiseMethodRgb);
}
}
@ -3257,9 +3255,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat
noisevarhue[i] = new float[(width + 1) / 2];
}
// init luma noisevarL
float noisevarab_b, noisevarab_r;
float realred, realblue;
float interm_med = static_cast<float>( dnparams.chroma) / 10.0;
float intermred, intermblue;
@ -3288,7 +3283,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat
realblue = 0.001f;
}
//TODO: implement using AlignedBufferMP
//fill tile from image; convert RGB to "luma/chroma"
if (isRAW) {//image is raw; use channel differences for chroma channels
@ -3489,8 +3483,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat
//and whether to subsample the image after wavelet filtering. Subsampling is coded as
//binary 1 or 0 for each level, eg subsampling = 0 means no subsampling, 1 means subsample
//the first level only, 7 means subsample the first three levels, etc.
noisevarab_r = SQR(realred) + 0.01f;
noisevarab_b = SQR(realblue) + 0.01f;
wavelet_decomposition* adecomp;
wavelet_decomposition* bdecomp;
@ -3519,8 +3511,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat
bdecomp = new wavelet_decomposition (labdn->data + 2 * datalen, labdn->W, labdn->H, levwav, 1);
}
}
const bool autoch = (settings->leveldnautsimpl == 1 && (dnparams.Cmethod == "AUT" || dnparams.Cmethod == "PRE")) || (settings->leveldnautsimpl == 0 && (dnparams.C2method == "AUTO" || dnparams.C2method == "PREV"));
if (comptlevel == 0) {
WaveletDenoiseAll_info(
@ -3530,11 +3520,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat
noisevarlum,
noisevarchrom,
noisevarhue,
width,
height,
noisevarab_r,
noisevarab_b,
labdn,
chaut,
Nb,
redaut,
@ -3544,7 +3529,6 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat
minredaut,
minblueaut,
schoice,
autoch,
chromina,
sigma,
lumema,
@ -3560,8 +3544,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise_info(Imagefloat * src, Imagefloat
chau,
chred,
chblue,
denoiseMethodRgb,
multiThread
denoiseMethodRgb
); // Enhance mode
}

View File

@ -655,7 +655,7 @@ SSEFUNCTION void ImProcFunctions::PF_correct_RTcam(CieImage * src, CieImage * ds
free(fringe);
}
SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad)
SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, double radius, int thresh, int mode, float skinprot, float chrom, int hotbad)
{
const int halfwin = ceil(2 * radius) + 1;
MyTime t1, t2;
@ -1263,7 +1263,7 @@ SSEFUNCTION void ImProcFunctions::Badpixelscam(CieImage * src, CieImage * dst, d
}
SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom)
SSEFUNCTION void ImProcFunctions::BadpixelsLab(LabImage * src, LabImage * dst, double radius, int thresh, int mode, float skinprot, float chrom)
{
const int halfwin = ceil(2 * radius) + 1;
MyTime t1, t2;

View File

@ -18,12 +18,8 @@
*/
#ifndef _ALIGNEDBUFFER_
#define _ALIGNEDBUFFER_
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <utility>
#include <glibmm.h>
#include "../rtgui/threadutils.h"
// Aligned buffer that should be faster
template <class T> class AlignedBuffer
@ -111,7 +107,6 @@ public:
}
if (real) {
//data = (T*)( (uintptr_t)real + (alignment-((uintptr_t)real)%alignment) );
data = (T*)( ( uintptr_t(real) + uintptr_t(alignment - 1)) / alignment * alignment);
inUse = true;
} else {
@ -142,51 +137,4 @@ public:
}
};
// Multi processor version, use with OpenMP
template <class T> class AlignedBufferMP
{
private:
MyMutex mtx;
std::vector<AlignedBuffer<T>*> buffers;
size_t size;
public:
explicit AlignedBufferMP(size_t sizeP)
{
size = sizeP;
}
~AlignedBufferMP()
{
for (size_t i = 0; i < buffers.size(); i++) {
delete buffers[i];
}
}
AlignedBuffer<T>* acquire()
{
MyMutex::MyLock lock(mtx);
// Find available buffer
for (size_t i = 0; i < buffers.size(); i++) {
if (!buffers[i]->inUse) {
buffers[i]->inUse = true;
return buffers[i];
}
}
// Add new buffer if nothing is free
AlignedBuffer<T>* buffer = new AlignedBuffer<T>(size);
buffers.push_back(buffer);
return buffer;
}
void release(AlignedBuffer<T>* buffer)
{
MyMutex::MyLock lock(mtx);
buffer->inUse = false;
}
};
#endif

View File

@ -34,8 +34,6 @@ namespace rtengine
template<class T, class A> void boxblur (T** src, A** dst, int radx, int rady, int W, int H)
{
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//box blur image; box range = (radx,rady)
AlignedBuffer<float>* buffer = new AlignedBuffer<float> (W * H);
@ -125,8 +123,6 @@ template<class T, class A> void boxblur (T** src, A** dst, int radx, int rady, i
template<class T, class A> SSEFUNCTION void boxblur (T** src, A** dst, T* buffer, int radx, int rady, int W, int H)
{
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//box blur image; box range = (radx,rady)
float* temp = buffer;
@ -313,13 +309,8 @@ template<class T, class A> SSEFUNCTION void boxblur (T** src, A** dst, T* buffer
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template<class T, class A> SSEFUNCTION void boxblur (T* src, A* dst, A* buffer, int radx, int rady, int W, int H)
{
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1)
float* temp = buffer;
@ -505,489 +496,6 @@ template<class T, class A> SSEFUNCTION void boxblur (T* src, A* dst, A* buffer,
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template<typename T> void boxvar (T* src, T* dst, int radx, int rady, int W, int H)
{
AlignedBuffer<float> buffer1(W * H);
AlignedBuffer<float> buffer2(W * H);
float* tempave = buffer1.data;
float* tempsqave = buffer2.data;
AlignedBufferMP<float> buffer3(H);
//float image_ave = 0;
//box blur image channel; box size = 2*box+1
//horizontal blur
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++) {
int len = radx + 1;
tempave[row * W + 0] = src[row * W + 0] / len;
tempsqave[row * W + 0] = SQR(src[row * W + 0]) / len;
for (int j = 1; j <= radx; j++) {
tempave[row * W + 0] += src[row * W + j] / len;
tempsqave[row * W + 0] += SQR(src[row * W + j]) / len;
}
for (int col = 1; col <= radx; col++) {
tempave[row * W + col] = (tempave[row * W + col - 1] * len + src[row * W + col + radx]) / (len + 1);
tempsqave[row * W + col] = (tempsqave[row * W + col - 1] * len + SQR(src[row * W + col + radx])) / (len + 1);
len ++;
}
for (int col = radx + 1; col < W - radx; col++) {
tempave[row * W + col] = tempave[row * W + col - 1] + (src[row * W + col + radx] - src[row * W + col - radx - 1]) / len;
tempsqave[row * W + col] = tempsqave[row * W + col - 1] + (SQR(src[row * W + col + radx]) - SQR(src[row * W + col - radx - 1])) / len;
}
for (int col = W - radx; col < W; col++) {
tempave[row * W + col] = (tempave[row * W + col - 1] * len - src[row * W + col - radx - 1]) / (len - 1);
tempsqave[row * W + col] = (tempsqave[row * W + col - 1] * len - SQR(src[row * W + col - radx - 1])) / (len - 1);
len --;
}
}
//vertical blur
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int col = 0; col < W; col++) {
AlignedBuffer<float>* pBuf3 = buffer3.acquire();
T* tempave2 = (T*)pBuf3->data;
int len = rady + 1;
tempave2[0] = tempave[0 * W + col] / len;
dst[0 * W + col] = tempsqave[0 * W + col] / len;
for (int i = 1; i <= rady; i++) {
tempave2[0] += tempave[i * W + col] / len;
dst[0 * W + col] += tempsqave[i * W + col] / len;
}
for (int row = 1; row <= rady; row++) {
tempave2[row] = (tempave2[(row - 1)] * len + tempave[(row + rady) * W + col]) / (len + 1);
dst[row * W + col] = (dst[(row - 1) * W + col] * len + tempsqave[(row + rady) * W + col]) / (len + 1);
len ++;
}
for (int row = rady + 1; row < H - rady; row++) {
tempave2[row] = tempave2[(row - 1)] + (tempave[(row + rady) * W + col] - tempave[(row - rady - 1) * W + col]) / len;
dst[row * W + col] = dst[(row - 1) * W + col] + (tempsqave[(row + rady) * W + col] - tempsqave[(row - rady - 1) * W + col]) / len;
}
for (int row = H - rady; row < H; row++) {
tempave2[row] = (tempave2[(row - 1)] * len - tempave[(row - rady - 1) * W + col]) / (len - 1);
dst[row * W + col] = (dst[(row - 1) * W + col] * len - tempsqave[(row - rady - 1) * W + col]) / (len - 1);
len --;
}
//now finish off
for (int row = 0; row < H; row++) {
dst[row * W + col] = fabs(dst[row * W + col] - SQR(tempave2[row]));
//image_ave += src[row*W+col];
}
buffer3.release(pBuf3);
}
//image_ave /= (W*H);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template<typename T> void boxdev (T* src, T* dst, int radx, int rady, int W, int H)
{
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1)
AlignedBuffer<float>* buffer1 = new AlignedBuffer<float> (W * H);
float* temp = buffer1->data;
AlignedBuffer<float>* buffer2 = new AlignedBuffer<float> (W * H);
float* tempave = buffer2->data;
if (radx == 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++)
for (int col = 0; col < W; col++) {
temp[row * W + col] = src[row * W + col];
}
} else {
//horizontal blur
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++) {
int len = radx + 1;
temp[row * W + 0] = (float)src[row * W + 0] / len;
for (int j = 1; j <= radx; j++) {
temp[row * W + 0] += (float)src[row * W + j] / len;
}
for (int col = 1; col <= radx; col++) {
temp[row * W + col] = (temp[row * W + col - 1] * len + src[row * W + col + radx]) / (len + 1);
len ++;
}
for (int col = radx + 1; col < W - radx; col++) {
temp[row * W + col] = temp[row * W + col - 1] + ((float)(src[row * W + col + radx] - src[row * W + col - radx - 1])) / len;
}
for (int col = W - radx; col < W; col++) {
temp[row * W + col] = (temp[row * W + col - 1] * len - src[row * W + col - radx - 1]) / (len - 1);
len --;
}
}
}
if (rady == 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++) {
for (int col = 0; col < W; col++) {
tempave[row * W + col] = temp[row * W + col];
}
}
} else {
//vertical blur
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int col = 0; col < W; col++) {
int len = rady + 1;
tempave[0 * W + col] = temp[0 * W + col] / len;
for (int i = 1; i <= rady; i++) {
tempave[0 * W + col] += temp[i * W + col] / len;
}
for (int row = 1; row <= rady; row++) {
tempave[row * W + col] = (tempave[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1);
len ++;
}
for (int row = rady + 1; row < H - rady; row++) {
tempave[row * W + col] = tempave[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len;
}
for (int row = H - rady; row < H; row++) {
tempave[row * W + col] = (tempave[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1);
len --;
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//box blur absolute deviation
if (radx == 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++)
for (int col = 0; col < W; col++) {
temp[row * W + col] = fabs(src[row * W + col] - tempave[row * W + col]);
}
} else {
//horizontal blur
//OpenMP here
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++) {
int len = radx + 1;
temp[row * W + 0] = fabs(src[row * W + 0] - tempave[row * W + 0]) / len;
for (int j = 1; j <= radx; j++) {
temp[row * W + 0] += fabs(src[row * W + j] - tempave[row * W + j]) / len;
}
for (int col = 1; col <= radx; col++) {
temp[row * W + col] = (temp[row * W + col - 1] * len + fabs(src[row * W + col + radx] - tempave[row * W + col + radx])) / (len + 1);
len ++;
}
for (int col = radx + 1; col < W - radx; col++) {
temp[row * W + col] = temp[row * W + col - 1] + (fabs(src[row * W + col + radx] - tempave[row * W + col + radx]) - \
fabs(src[row * W + col - radx - 1] - tempave[row * W + col - radx - 1])) / len;
}
for (int col = W - radx; col < W; col++) {
temp[row * W + col] = (temp[row * W + col - 1] * len - fabs(src[row * W + col - radx - 1] - tempave[row * W + col - radx - 1])) / (len - 1);
len --;
}
}
}
if (rady == 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++)
for (int col = 0; col < W; col++) {
dst[row * W + col] = temp[row * W + col];
}
} else {
//vertical blur
//OpenMP here
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int col = 0; col < W; col++) {
int len = rady + 1;
dst[0 * W + col] = temp[0 * W + col] / len;
for (int i = 1; i <= rady; i++) {
dst[0 * W + col] += temp[i * W + col] / len;
}
for (int row = 1; row <= rady; row++) {
dst[row * W + col] = (dst[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1);
len ++;
}
for (int row = rady + 1; row < H - rady; row++) {
dst[row * W + col] = dst[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len;
}
for (int row = H - rady; row < H; row++) {
dst[row * W + col] = (dst[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1);
len --;
}
}
}
delete buffer1;
delete buffer2;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template<class T, class A> void boxsqblur (T* src, A* dst, int radx, int rady, int W, int H)
{
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1)
AlignedBuffer<float>* buffer = new AlignedBuffer<float> (W * H);
float* temp = buffer->data;
if (radx == 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++)
for (int col = 0; col < W; col++) {
temp[row * W + col] = SQR(src[row * W + col]);
}
} else {
//horizontal blur
//OpenMP here
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++) {
int len = radx + 1;
temp[row * W + 0] = SQR((float)src[row * W + 0]) / len;
for (int j = 1; j <= radx; j++) {
temp[row * W + 0] += SQR((float)src[row * W + j]) / len;
}
for (int col = 1; col <= radx; col++) {
temp[row * W + col] = (temp[row * W + col - 1] * len + SQR(src[row * W + col + radx])) / (len + 1);
len ++;
}
for (int col = radx + 1; col < W - radx; col++) {
temp[row * W + col] = temp[row * W + col - 1] + ((float)(SQR(src[row * W + col + radx]) - SQR(src[row * W + col - radx - 1]))) / len;
}
for (int col = W - radx; col < W; col++) {
temp[row * W + col] = (temp[row * W + col - 1] * len - SQR(src[row * W + col - radx - 1])) / (len - 1);
len --;
}
}
}
if (rady == 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++)
for (int col = 0; col < W; col++) {
dst[row * W + col] = temp[row * W + col];
}
} else {
//vertical blur
//OpenMP here
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int col = 0; col < W; col++) {
int len = rady + 1;
dst[0 * W + col] = temp[0 * W + col] / len;
for (int i = 1; i <= rady; i++) {
dst[0 * W + col] += temp[i * W + col] / len;
}
for (int row = 1; row <= rady; row++) {
dst[row * W + col] = (dst[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1);
len ++;
}
for (int row = rady + 1; row < H - rady; row++) {
dst[row * W + col] = dst[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len;
}
for (int row = H - rady; row < H; row++) {
dst[row * W + col] = (dst[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1);
len --;
}
}
}
delete buffer;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template<class T, class A> void boxcorrelate (T* src, A* dst, int dx, int dy, int radx, int rady, int W, int H)
{
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//box blur image; box range = (radx,rady) i.e. box size is (2*radx+1)x(2*rady+1)
AlignedBuffer<float>* buffer = new AlignedBuffer<float> (W * H);
float* temp = buffer->data;
if (radx == 0) {
for (int row = 0; row < H; row++) {
int rr = min(H - 1, max(0, row + dy));
for (int col = 0; col < W; col++) {
int cc = min(W - 1, max(0, col + dx));
temp[row * W + col] = dy > 0 ? (src[row * W + col]) * (src[rr * W + cc]) : 0;
}
}
} else {
//horizontal blur
for (int row = 0; row < H; row++) {
int len = radx + 1;
int rr = min(H - 1, max(0, row + dy));
int cc = min(W - 1, max(0, 0 + dx));
temp[row * W + 0] = ((float)src[row * W + 0]) * (src[rr * W + cc]) / len;
for (int j = 1; j <= radx; j++) {
int cc = min(W - 1, max(0, j + dx));
temp[row * W + 0] += ((float)src[row * W + j]) * (src[rr * W + cc]) / len;
}
for (int col = 1; col <= radx; col++) {
int cc = min(W - 1, max(0, col + dx + radx));
temp[row * W + col] = (temp[row * W + col - 1] * len + (src[row * W + col + radx]) * (src[rr * W + cc])) / (len + 1);
len ++;
}
for (int col = radx + 1; col < W - radx; col++) {
int cc = min(W - 1, max(0, col + dx + radx));
int cc1 = min(W - 1, max(0, col + dx - radx - 1));
temp[row * W + col] = temp[row * W + col - 1] + ((float)((src[row * W + col + radx]) * (src[rr * W + cc]) -
(src[row * W + col - radx - 1]) * (src[rr * W + cc1]))) / len;
}
for (int col = W - radx; col < W; col++) {
int cc1 = min(W - 1, max(0, col + dx - radx - 1));
temp[row * W + col] = (temp[row * W + col - 1] * len - (src[row * W + col - radx - 1]) * (src[rr * W + cc1])) / (len - 1);
len --;
}
}
}
if (rady == 0) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int row = 0; row < H; row++)
for (int col = 0; col < W; col++) {
dst[row * W + col] = temp[row * W + col];
}
} else {
//vertical blur
//OpenMP here
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int col = 0; col < W; col++) {
int len = rady + 1;
dst[0 * W + col] = temp[0 * W + col] / len;
for (int i = 1; i <= rady; i++) {
dst[0 * W + col] += temp[i * W + col] / len;
}
for (int row = 1; row <= rady; row++) {
dst[row * W + col] = (dst[(row - 1) * W + col] * len + temp[(row + rady) * W + col]) / (len + 1);
len ++;
}
for (int row = rady + 1; row < H - rady; row++) {
dst[row * W + col] = dst[(row - 1) * W + col] + (temp[(row + rady) * W + col] - temp[(row - rady - 1) * W + col]) / len;
}
for (int row = H - rady; row < H; row++) {
dst[row * W + col] = (dst[(row - 1) * W + col] * len - temp[(row - rady - 1) * W + col]) / (len - 1);
len --;
}
}
}
delete buffer;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
template<class T, class A> SSEFUNCTION void boxabsblur (T* src, A* dst, int radx, int rady, int W, int H, float * temp)
{
@ -1131,7 +639,5 @@ template<class T, class A> SSEFUNCTION void boxabsblur (T* src, A* dst, int radx
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
#endif /* _BOXBLUR_H_ */

View File

@ -191,12 +191,21 @@ static const char *parse_string(cJSON *item,const char *str)
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
#if defined( __GNUC__ ) && __GNUC__ >= 7// silence warning
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
switch (len) {
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 1: *--ptr2 =(uc | firstByteMark[len]);
}
#if defined( __GNUC__ ) && __GNUC__ >= 7
#pragma GCC diagnostic pop
#endif
ptr2+=len;
break;
default: *ptr2++=*ptr; break;

View File

@ -30,7 +30,6 @@
#undef CLIPD
#define CLIPD(a) ((a)>0.0?((a)<1.0?(a):1.0):0.0)
#define MAXR(a,b) ((a) > (b) ? (a) : (b))
#define pow_F(a,b) (xexpf(b*xlogf(a)))
namespace rtengine
{
@ -780,7 +779,7 @@ void Ciecam02::initcam2float (float gamu, float yb, float pilotd, float f, float
void Ciecam02::xyz2jchqms_ciecam02 ( double &J, double &C, double &h, double &Q, double &M, double &s, double &aw, double &fl, double &wh,
double x, double y, double z, double xw, double yw, double zw,
double yb, double la, double f, double c, double nc, double pilotd, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d)
double c, double nc, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d)
{
double r, g, b;
double rw, gw, bw;
@ -1040,8 +1039,8 @@ void Ciecam02::xyz2jch_ciecam02float ( float &J, float &C, float &h, float aw, f
void Ciecam02::jch2xyz_ciecam02 ( double &x, double &y, double &z, double J, double C, double h,
double xw, double yw, double zw, double yb, double la,
double f, double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw )
double xw, double yw, double zw,
double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw )
{
double r, g, b;
double rc, gc, bc;
@ -1075,7 +1074,7 @@ void Ciecam02::jch2xyz_ciecam02 ( double &x, double &y, double &z, double J, dou
void Ciecam02::jch2xyz_ciecam02float ( float &x, float &y, float &z, float J, float C, float h,
float xw, float yw, float zw,
float f, float c, float nc, int gamu, float pow1, float nbb, float ncb, float fl, float cz, float d, float aw)
float c, float nc, int gamu, float pow1, float nbb, float ncb, float fl, float cz, float d, float aw)
{
float r, g, b;
float rc, gc, bc;
@ -1110,7 +1109,7 @@ void Ciecam02::jch2xyz_ciecam02float ( float &x, float &y, float &z, float J, fl
#ifdef __SSE2__
void Ciecam02::jch2xyz_ciecam02float ( vfloat &x, vfloat &y, vfloat &z, vfloat J, vfloat C, vfloat h,
vfloat xw, vfloat yw, vfloat zw,
vfloat f, vfloat nc, vfloat pow1, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz)
vfloat nc, vfloat pow1, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz)
{
vfloat r, g, b;
vfloat rc, gc, bc;

View File

@ -82,19 +82,18 @@ public:
static void jch2xyz_ciecam02 ( double &x, double &y, double &z,
double J, double C, double h,
double xw, double yw, double zw,
double yb, double la,
double f, double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw);
double c, double nc, int gamu, double n, double nbb, double ncb, double fl, double cz, double d, double aw);
static void jch2xyz_ciecam02float ( float &x, float &y, float &z,
float J, float C, float h,
float xw, float yw, float zw,
float f, float c, float nc, int gamu, float n, float nbb, float ncb, float fl, float cz, float d, float aw );
float c, float nc, int gamu, float n, float nbb, float ncb, float fl, float cz, float d, float aw );
#ifdef __SSE2__
static void jch2xyz_ciecam02float ( vfloat &x, vfloat &y, vfloat &z,
vfloat J, vfloat C, vfloat h,
vfloat xw, vfloat yw, vfloat zw,
vfloat f, vfloat nc, vfloat n, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz );
vfloat nc, vfloat n, vfloat nbb, vfloat ncb, vfloat fl, vfloat d, vfloat aw, vfloat reccmcz );
#endif
/**
* Forward transform from XYZ to CIECAM02 JCh.
@ -115,8 +114,7 @@ public:
double &Q, double &M, double &s, double &aw, double &fl, double &wh,
double x, double y, double z,
double xw, double yw, double zw,
double yb, double la,
double f, double c, double nc, double pilotd, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d );
double c, double nc, int gamu, double n, double nbb, double ncb, double pfl, double cz, double d );
static void xyz2jch_ciecam02float ( float &J, float &C, float &h,
float aw, float fl,

View File

@ -52,7 +52,7 @@ bool loadFile(
rtengine::procparams::ColorManagementParams icm;
icm.working = working_color_space;
img_src.getImage(curr_wb, TR_NONE, img_float.get(), pp, rtengine::procparams::ToneCurveParams(), icm, rtengine::procparams::RAWParams());
img_src.getImage(curr_wb, TR_NONE, img_float.get(), pp, rtengine::procparams::ToneCurveParams(), rtengine::procparams::RAWParams());
if (!working_color_space.empty()) {
img_src.convertColorSpace(img_float.get(), icm, curr_wb);

View File

@ -25,8 +25,6 @@
#include "opthelper.h"
#include "iccstore.h"
#define pow_F(a,b) (xexpf(b*xlogf(a)))
using namespace std;
namespace rtengine
@ -1543,9 +1541,9 @@ void Color::interpolateRGBColor (const float balance, const float r1, const floa
void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom,
bool chr, bool lum, float chromat, float luma, const float r1, const float g1, const float b1,
float chromat, float luma, const float r1, const float g1, const float b1,
const float xl, const float yl, const float zl, const float x2, const float y2, const float z2,
int toDo, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo)
const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo)
{
float X1, Y1, Z1, X2, Y2, Z2, X, Y, Z, XL, YL, ZL;
float L1 = 0.f, L2, LL, a_1 = 0.f, b_1 = 0.f, a_2 = 0.f, b_2 = 0.f, a_L, b_L;
@ -1637,7 +1635,7 @@ void Color::interpolateRGBColor (float realL, float iplow, float iphigh, int alg
Color::xyz2rgb (X, Y, Z, ro, go, bo, rgb_xyz); // ro go bo in gamut
}
void Color::calcGamma (double pwr, double ts, int mode, int imax, GammaValues &gamma)
void Color::calcGamma (double pwr, double ts, int mode, GammaValues &gamma)
{
//from Dcraw (D.Coffin)
int i;
@ -2621,7 +2619,7 @@ void Color::gamutLchonly (float2 sincosval, float &Lprov1, float &Chprov1, const
* const double wip[3][3]: matrix for working profile
* bool multiThread : parallelize the loop
*/
SSEFUNCTION void Color::LabGamutMunsell (float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3], bool multiThread )
SSEFUNCTION void Color::LabGamutMunsell(float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3])
{
#ifdef _DEBUG
MyTime t1e, t2e;

View File

@ -734,7 +734,7 @@ public:
* @param go green channel of output color [0 ; 65535] (return value)
* @param bo blue channel of output color [0 ; 65535] (return value)
*/
static void interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, bool chr, bool lum, float chromat, float luma, const float r1, const float g1, const float b1, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, int channels, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo);
static void interpolateRGBColor (float realL, float iplow, float iphigh, int algm, const float balance, int twoc, int metchrom, float chromat, float luma, const float r1, const float g1, const float b1, const float xl, const float yl, const float zl, const float x2, const float y2, const float z2, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float &ro, float &go, float &bo);
/**
@ -899,7 +899,7 @@ public:
* gamma4 used in ip2Lab2rgb [0 ; 1], usually near 0.03(return value)
* gamma5 used in ip2Lab2rgb [0 ; 1], usually near 0.5 (return value)
*/
static void calcGamma (double pwr, double ts, int mode, int imax, GammaValues &gamma);
static void calcGamma (double pwr, double ts, int mode, GammaValues &gamma);
/**
@ -1316,7 +1316,7 @@ public:
* @param wip matrix for working profile
* @param multiThread whether to parallelize the loop or not
*/
static void LabGamutMunsell (float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3], bool multiThread );
static void LabGamutMunsell (float *labL, float *laba, float *labb, const int N, bool corMunsell, bool lumaMuns, bool isHLEnabled, bool gamut, const double wip[3][3]);
/*

View File

@ -24,11 +24,6 @@
#include "sleef.c"
#include "settings.h"
#undef CLIPD
#define CLIPD(a) ((a)>0.0?((a)<1.0?(a):1.0):0.0)
#define CLIPQQ(a) ((a)>0?((a)<250?(a):250):0)
#define MAXR(a,b) ((a) > (b) ? (a) : (b))
namespace rtengine
{
@ -70,48 +65,22 @@ static const double cie_colour_match_jd[97][3] = {//350nm to 830nm 5 nm J.Desm
{0.000001251141, 0.00000045181, 0.000000}
};
ColorTemp::ColorTemp (double t, double g, double e, const Glib::ustring &m) : temp(t), green(g), equal(e), method(m)
ColorTemp::ColorTemp (double t, double g, double e, const std::string &m) : temp(t), green(g), equal(e), method(m)
{
clip (temp, green, equal);
}
void ColorTemp::clip (double &temp, double &green)
{
if (temp < MINTEMP) {
temp = MINTEMP;
} else if (temp > MAXTEMP) {
temp = MAXTEMP;
}
if (green < MINGREEN) {
green = MINGREEN;
} else if (green > MAXGREEN) {
green = MAXGREEN;
}
temp = rtengine::LIM(temp, MINTEMP, MAXTEMP);
green = rtengine::LIM(green, MINGREEN, MAXGREEN);
}
void ColorTemp::clip (double &temp, double &green, double &equal)
{
if (temp < MINTEMP) {
temp = MINTEMP;
} else if (temp > MAXTEMP) {
temp = MAXTEMP;
}
if (green < MINGREEN) {
green = MINGREEN;
} else if (green > MAXGREEN) {
green = MAXGREEN;
}
if(equal < MINEQUAL) {
equal = MINEQUAL;
} else if(equal > MAXEQUAL) {
equal = MAXEQUAL;
}
temp = rtengine::LIM(temp, MINTEMP, MAXTEMP);
green = rtengine::LIM(green, MINGREEN, MAXGREEN);
equal = rtengine::LIM(equal, MINEQUAL, MAXEQUAL);
}
ColorTemp::ColorTemp (double mulr, double mulg, double mulb, double e) : equal(e), method("Custom")
@ -122,7 +91,7 @@ ColorTemp::ColorTemp (double mulr, double mulg, double mulb, double e) : equal(e
void ColorTemp::mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) const
{
double maxtemp = double(MAXTEMP), mintemp = double(MINTEMP);
double maxtemp = MAXTEMP, mintemp = MINTEMP;
double tmpr, tmpg, tmpb;
temp = (maxtemp + mintemp) / 2;
@ -354,6 +323,37 @@ const double ColorTemp::Flash6500_spect[97] = {
55.72, 51.97, 54.72, 57.46, 58.89, 60.33
};
const std::map<std::string,const double *> ColorTemp::spectMap = {
{"Daylight", Daylight5300_spect},
{"Cloudy", Cloudy6200_spect},
{"Shade", Shade7600_spect},
{"Tungsten", A2856_spect},
{"Fluo F1", FluoF1_spect},
{"Fluo F2", FluoF2_spect},
{"Fluo F3", FluoF3_spect},
{"Fluo F4", FluoF4_spect},
{"Fluo F5", FluoF5_spect},
{"Fluo F6", FluoF6_spect},
{"Fluo F7", FluoF7_spect},
{"Fluo F8", FluoF8_spect},
{"Fluo F9", FluoF9_spect},
{"Fluo F10", FluoF10_spect},
{"Fluo F11", FluoF11_spect},
{"Fluo F12", FluoF12_spect},
{"HMI Lamp", HMI_spect},
{"GTI Lamp", GTI_spect},
{"JudgeIII Lamp", JudgeIII_spect},
{"Solux Lamp 3500K", Solux3500_spect},
{"Solux Lamp 4100K", Solux4100_spect},
{"Solux Lamp 4700K", Solux4700_spect},
{"NG Solux Lamp 4700K", NG_Solux4700_spect},
{"LED LSI Lumelex 2040", NG_LEDLSI2040_spect},
{"LED CRS SP12 WWMR16", NG_CRSSP12WWMR16_spect},
{"Flash 5500K", Flash5500_spect},
{"Flash 6000K", Flash6000_spect},
{"Flash 6500K", Flash6500_spect}
};
// Data for Color ==> CRI (Color Rendering Index and Palette
// actually 20 color that must be good enough for CRI
@ -844,10 +844,7 @@ const double ColorTemp::ColabSky42_0_m24_spect[97] = {
* Gunter Wyszecki and W. S. Stiles, John Wiley & Sons, 1982, pp. 227, 228.
*/
//adaptation to RT by J.Desmis
#include <float.h>
/* LERP(a,b,c) = linear interpolation macro, is 'a' when c == 0.0 and 'b' when c == 1.0 */
#define LERP(a,b,c) (((b) - (a)) * (c) + (a))
int ColorTemp::XYZtoCorColorTemp(double x0, double y0, double z0, double &temp) const
{
@ -922,13 +919,13 @@ int ColorTemp::XYZtoCorColorTemp(double x0, double y0, double z0, double &temp)
}
if (i == 31) {
return(-1); /* bad XYZ input, color temp would be less than minimum of 1666.7 degrees, or too far towards blue */
return -1; /* bad XYZ input, color temp would be less than minimum of 1666.7 degrees, or too far towards blue */
}
di = di / sqrt(1.0 + uvt[i ].t * uvt[i ].t);
dm = dm / sqrt(1.0 + uvt[i - 1].t * uvt[i - 1].t);
p = dm / (dm - di); /* p = interpolation parameter, 0.0 : i-1, 1.0 : i */
p = 1.0 / (LERP(rt[i - 1], rt[i], p));
p = 1.0 / rtengine::intp(p, rt[i], rt[i - 1]);
temp = p;
return 0; /* success */
}
@ -1025,192 +1022,15 @@ void ColorTemp::cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, dou
}
void ColorTemp::temp2mulxyz (double tem, double gree, const std::string &method, double &Xxyz, double &Zxyz)
void ColorTemp::temp2mulxyz (double temp, const std::string &method, double &Xxyz, double &Zxyz)
{
double xD, yD, x_D, y_D, interm;
double x, y, z;
if (method == "Daylight" ) {
spectrum_to_xyz_preset(Daylight5300_spect, x, y, z);
} else if(method == "Cloudy" ) {
spectrum_to_xyz_preset(Cloudy6200_spect, x, y, z);
} else if(method == "Shade" ) {
spectrum_to_xyz_preset(Shade7600_spect, x, y, z);
} else if(method == "Tungsten" ) {
spectrum_to_xyz_preset(A2856_spect, x, y, z);
} else if(method == "Fluo F1" ) {
spectrum_to_xyz_preset(FluoF1_spect, x, y, z);
} else if(method == "Fluo F2" ) {
spectrum_to_xyz_preset(FluoF2_spect, x, y, z);
} else if(method == "Fluo F3" ) {
spectrum_to_xyz_preset(FluoF3_spect, x, y, z);
} else if(method == "Fluo F4" ) {
spectrum_to_xyz_preset(FluoF4_spect, x, y, z);
} else if(method == "Fluo F5" ) {
spectrum_to_xyz_preset(FluoF5_spect, x, y, z);
} else if(method == "Fluo F6" ) {
spectrum_to_xyz_preset(FluoF6_spect, x, y, z);
} else if(method == "Fluo F7" ) {
spectrum_to_xyz_preset(FluoF7_spect, x, y, z);
} else if(method == "Fluo F8" ) {
spectrum_to_xyz_preset(FluoF8_spect, x, y, z);
} else if(method == "Fluo F9" ) {
spectrum_to_xyz_preset(FluoF9_spect, x, y, z);
} else if(method == "Fluo F10" ) {
spectrum_to_xyz_preset(FluoF10_spect, x, y, z);
} else if(method == "Fluo F11" ) {
spectrum_to_xyz_preset(FluoF11_spect, x, y, z);
} else if(method == "Fluo F12" ) {
spectrum_to_xyz_preset(FluoF12_spect, x, y, z);
} else if(method == "HMI Lamp" ) {
spectrum_to_xyz_preset(HMI_spect, x, y, z);
} else if(method == "GTI Lamp" ) {
spectrum_to_xyz_preset(GTI_spect, x, y, z);
} else if(method == "JudgeIII Lamp" ) {
spectrum_to_xyz_preset(JudgeIII_spect, x, y, z);
} else if(method == "Solux Lamp 3500K" ) {
spectrum_to_xyz_preset(Solux3500_spect, x, y, z);
} else if(method == "Solux Lamp 4100K" ) {
spectrum_to_xyz_preset(Solux4100_spect, x, y, z);
} else if(method == "Solux Lamp 4700K" ) {
spectrum_to_xyz_preset(Solux4700_spect, x, y, z);
} else if(method == "NG Solux Lamp 4700K" ) {
spectrum_to_xyz_preset(NG_Solux4700_spect, x, y, z);
} else if(method == "LED LSI Lumelex 2040") {
spectrum_to_xyz_preset(NG_LEDLSI2040_spect, x, y, z);
} else if(method == "LED CRS SP12 WWMR16" ) {
spectrum_to_xyz_preset(NG_CRSSP12WWMR16_spect, x, y, z);
} else if(method == "Flash 5500K" ) {
spectrum_to_xyz_preset(Flash5500_spect, x, y, z);
} else if(method == "Flash 6000K" ) {
spectrum_to_xyz_preset(Flash6000_spect, x, y, z);
} else if(method == "Flash 6500K" ) {
spectrum_to_xyz_preset(Flash6500_spect, x, y, z);
} else {
// otherwise we use the Temp+Green generic solution
if (tem <= INITIALBLACKBODY) {
// if temperature is between 2000K and 4000K we use blackbody, because there will be no Daylight reference below 4000K...
// of course, the previous version of RT used the "magical" but wrong formula of U.Fuchs (Ufraw).
spectrum_to_xyz_blackbody(tem, x, y, z);
} else {
// from 4000K up to 25000K: using the D illuminant (daylight) which is standard
double m1, m2;
if (tem <= 7000) {
x_D = -4.6070e9 / (tem * tem * tem) + 2.9678e6 / (tem * tem) + 0.09911e3 / tem + 0.244063;
} else if (tem <= 25000) {
x_D = -2.0064e9 / (tem * tem * tem) + 1.9018e6 / (tem * tem) + 0.24748e3 / tem + 0.237040;
} else /*if (tem > 25000)*/ {
x_D = -2.0064e9 / (tem * tem * tem) + 1.9018e6 / (tem * tem) + 0.24748e3 / tem + 0.237040 - ((tem - 25000) / 25000) * 0.025; //Jacques empirical adjustemnt for very high temp (underwater !)
}
y_D = -3.0 * x_D * x_D + 2.87 * x_D - 0.275;
//calculate D -daylight in function of s0, s1, s2 and temp ==> x_D y_D
//S(lamda)=So(lambda)+m1*s1(lambda)+m2*s2(lambda)
interm = (0.0241 + 0.2562 * x_D - 0.734 * y_D);
m1 = (-1.3515 - 1.7703 * x_D + 5.9114 * y_D) / interm;
m2 = (0.03 - 31.4424 * x_D + 30.0717 * y_D) / interm;
spectrum_to_xyz_daylight(m1, m2, x, y, z);
xD = x;
yD = y;
}
}
xD = x;
yD = y;
double X = xD / yD;
double Z = (1.0 - xD - yD) / yD;
Xxyz = X;
Zxyz = Z;
//printf("Xxyz=%f Zxyz=%f\n",Xxyz,Zxyz);
}
void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const
{
clip (temp, green, equal);
//printf("temp=%d green=%.3f equal=%.3f\n", (int)temp, (float) green, (float) equal);
//variables for CRI and display Lab, and palette
double xD, yD, x_D, y_D, interm;
double m1, m2;
double x, y, z;
double Xchk[50], Ychk[50], Zchk[50]; //50 : I think it's a good limit for number of color : for CRI and Palette
double Xcam02[50], Ycam02[50], Zcam02[50];
double XchkLamp[50], YchkLamp[50], ZchkLamp[50];
double Xcam02Lamp[50], Ycam02Lamp[50], Zcam02Lamp[50];
const double epsilon = 0.008856; //Lab
const double whiteD50[3] = {0.9646019585, 1.0, 0.8244507152}; //calculate with this tool : spect 5nm
double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02
double xr[50], yr[50], zr[50];
double fx[50], fy[50], fz[50];
// bool palette = false;
// double tempalet; // correlated temperature
// We first test for specially handled methods
if (method == "Daylight" ) {
spectrum_to_xyz_preset(Daylight5300_spect, x, y, z);
} else if(method == "Cloudy" ) {
spectrum_to_xyz_preset(Cloudy6200_spect, x, y, z);
} else if(method == "Shade" ) {
spectrum_to_xyz_preset(Shade7600_spect, x, y, z);
} else if(method == "Tungsten" ) {
spectrum_to_xyz_preset(A2856_spect, x, y, z);
} else if(method == "Fluo F1" ) {
spectrum_to_xyz_preset(FluoF1_spect, x, y, z);
} else if(method == "Fluo F2" ) {
spectrum_to_xyz_preset(FluoF2_spect, x, y, z);
} else if(method == "Fluo F3" ) {
spectrum_to_xyz_preset(FluoF3_spect, x, y, z);
} else if(method == "Fluo F4" ) {
spectrum_to_xyz_preset(FluoF4_spect, x, y, z);
} else if(method == "Fluo F5" ) {
spectrum_to_xyz_preset(FluoF5_spect, x, y, z);
} else if(method == "Fluo F6" ) {
spectrum_to_xyz_preset(FluoF6_spect, x, y, z);
} else if(method == "Fluo F7" ) {
spectrum_to_xyz_preset(FluoF7_spect, x, y, z);
} else if(method == "Fluo F8" ) {
spectrum_to_xyz_preset(FluoF8_spect, x, y, z);
} else if(method == "Fluo F9" ) {
spectrum_to_xyz_preset(FluoF9_spect, x, y, z);
} else if(method == "Fluo F10" ) {
spectrum_to_xyz_preset(FluoF10_spect, x, y, z);
} else if(method == "Fluo F11" ) {
spectrum_to_xyz_preset(FluoF11_spect, x, y, z);
} else if(method == "Fluo F12" ) {
spectrum_to_xyz_preset(FluoF12_spect, x, y, z);
} else if(method == "HMI Lamp" ) {
spectrum_to_xyz_preset(HMI_spect, x, y, z);
} else if(method == "GTI Lamp" ) {
spectrum_to_xyz_preset(GTI_spect, x, y, z);
} else if(method == "JudgeIII Lamp" ) {
spectrum_to_xyz_preset(JudgeIII_spect, x, y, z);
} else if(method == "Solux Lamp 3500K" ) {
spectrum_to_xyz_preset(Solux3500_spect, x, y, z);
} else if(method == "Solux Lamp 4100K" ) {
spectrum_to_xyz_preset(Solux4100_spect, x, y, z);
} else if(method == "Solux Lamp 4700K" ) {
spectrum_to_xyz_preset(Solux4700_spect, x, y, z);
} else if(method == "NG Solux Lamp 4700K" ) {
spectrum_to_xyz_preset(NG_Solux4700_spect, x, y, z);
} else if(method == "LED LSI Lumelex 2040") {
spectrum_to_xyz_preset(NG_LEDLSI2040_spect, x, y, z);
} else if(method == "LED CRS SP12 WWMR16" ) {
spectrum_to_xyz_preset(NG_CRSSP12WWMR16_spect, x, y, z);
} else if(method == "Flash 5500K" ) {
spectrum_to_xyz_preset(Flash5500_spect, x, y, z);
} else if(method == "Flash 6000K" ) {
spectrum_to_xyz_preset(Flash6000_spect, x, y, z);
} else if(method == "Flash 6500K" ) {
spectrum_to_xyz_preset(Flash6500_spect, x, y, z);
const auto iterator = spectMap.find(method);
if (iterator != spectMap.end()) {
spectrum_to_xyz_preset(iterator->second, x, y, z);
} else {
// otherwise we use the Temp+Green generic solution
if (temp <= INITIALBLACKBODY) {
@ -1219,48 +1039,42 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
spectrum_to_xyz_blackbody(temp, x, y, z);
} else {
// from 4000K up to 25000K: using the D illuminant (daylight) which is standard
double x_D, y_D;
if (temp <= 7000) {
x_D = -4.6070e9 / (temp * temp * temp) + 2.9678e6 / (temp * temp) + 0.09911e3 / temp + 0.244063;
} else if (temp <= 25000) {
x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040;
} else /*if (temp > 25000)*/ { // above 25000 it's unknown..then I have modified to adjust for underwater
x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040 - ((temp - 25000) / 25000) * 0.025; //Jacques empirical adjustemnt for very high temp (underwater !)
} else /*if (temp > 25000)*/ {
x_D = -2.0064e9 / (temp * temp * temp) + 1.9018e6 / (temp * temp) + 0.24748e3 / temp + 0.237040 - ((temp - 25000) / 25000) * 0.025; //Jacques empirical adjustment for very high temp (underwater !)
}
y_D = (-3.0 * x_D * x_D + 2.87 * x_D - 0.275); //modify blue / red action
y_D = -3.0 * x_D * x_D + 2.87 * x_D - 0.275; //modify blue / red action
//calculate D -daylight in function of s0, s1, s2 and temp ==> x_D y_D
//S(lamda)=So(lambda)+m1*s1(lambda)+m2*s2(lambda)
interm = (0.0241 + 0.2562 * x_D - 0.734 * y_D);
m1 = (-1.3515 - 1.7703 * x_D + 5.9114 * y_D) / interm;
m2 = (0.03 - 31.4424 * x_D + 30.0717 * y_D) / interm;
double interm = 0.0241 + 0.2562 * x_D - 0.734 * y_D;
double m1 = (-1.3515 - 1.7703 * x_D + 5.9114 * y_D) / interm;
double m2 = (0.03 - 31.4424 * x_D + 30.0717 * y_D) / interm;
spectrum_to_xyz_daylight(m1, m2, x, y, z);
xD = x;
yD = y;
}
}
xD = x;
yD = y;
Xxyz = x / y;
Zxyz = (1.0 - x - y) / y;
}
void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const
{
clip(temp, green, equal);
double Xwb, Zwb;
temp2mulxyz(temp, method, Xwb, Zwb);
float adj = 1.f;
if(equal < 0.9999 || equal > 1.0001 ) {
adj = (100.f + ( 1000.f - (1000.f * (float)equal) ) / 20.f) / 100.f;
}
//printf("adj=%f\n",adj);
double Xwb = xD / yD;
double Ywb = 1.0;
double Zwb = (1.0 - xD - yD) / yD;
if (settings->verbose) {
// double u=4*xD/(-2*xD+12*yD+3);
// double v=6*yD/(-2*xD+12*yD+3);
// printf("xD=%f yD=%f u=%f v=%f\n",xD,yD,u,v);
if(settings->CRI_color != 0) {
printf("xD=%f yD=%f === Xwb=%f Ywb=%f Zwb=%f\n", xD, yD, Xwb, Ywb, Zwb);
}
}
/*if (isRaw) {
rmul = sRGB_xyz[0][0]*X + sRGB_xyz[0][1]*Y + sRGB_xyz[0][2]*Z;
@ -1268,36 +1082,41 @@ void ColorTemp::temp2mul (double temp, double green, double equal, double& rmul,
bmul = sRGB_xyz[2][0]*X + sRGB_xyz[2][1]*Y + sRGB_xyz[2][2]*Z;
} else {*/
//recalculate channels multipliers with new values of XYZ tue to whitebalance
rmul = sRGBd65_xyz[0][0] * Xwb * adj + sRGBd65_xyz[0][1] * Ywb + sRGBd65_xyz[0][2] * Zwb / adj; // Jacques' empirical modification 5/2013
gmul = sRGBd65_xyz[1][0] * Xwb + sRGBd65_xyz[1][1] * Ywb + sRGBd65_xyz[1][2] * Zwb;
bmul = sRGBd65_xyz[2][0] * Xwb * adj + sRGBd65_xyz[2][1] * Ywb + sRGBd65_xyz[2][2] * Zwb / adj;
rmul = sRGBd65_xyz[0][0] * Xwb * adj + sRGBd65_xyz[0][1] + sRGBd65_xyz[0][2] * Zwb / adj; // Jacques' empirical modification 5/2013
gmul = sRGBd65_xyz[1][0] * Xwb + sRGBd65_xyz[1][1] + sRGBd65_xyz[1][2] * Zwb;
bmul = sRGBd65_xyz[2][0] * Xwb * adj + sRGBd65_xyz[2][1] + sRGBd65_xyz[2][2] * Zwb / adj;
//};
gmul /= green;
//printf("rmul=%f gmul=%f bmul=%f\n",rmul, gmul, bmul);
double max = rmul;
if (gmul > max) {
max = gmul;
}
if (bmul > max) {
max = bmul;
}
double max = rtengine::max(rmul, gmul, bmul);
rmul /= max;
gmul /= max;
bmul /= max;
// begin CRI_RT : color rendering index RT - adaptation of CRI by J.Desmis
// CRI = 100 for Blackbody and Daylight
// calculate from spectral data values X, Y, Z , for color of colorchecker24 , SG, DC, JDC_468
//only for lamp different of tungstene
//first calcul with illuminant (choice)
// and calcul with : blackbody at equivalent temp of lamp
if(settings->CRI_color != 0) //activate if CRi_color !=0
if(settings->CRI_color != 0) { //activate if CRi_color !=0
// begin CRI_RT : color rendering index RT - adaptation of CRI by J.Desmis
// CRI = 100 for Blackbody and Daylight
// calculate from spectral data values X, Y, Z , for color of colorchecker24 , SG, DC, JDC_468
// only for lamp different of tungstene
// first calcul with illuminant (choice)
// and calcul with : blackbody at equivalent temp of lamp
// CRI_color-1 = dispaly Lab values of color CRI_color -1
{
const double whiteD50[3] = {0.9646019585, 1.0, 0.8244507152}; //calculate with this tool : spect 5nm
double CAM02BB00, CAM02BB01, CAM02BB02, CAM02BB10, CAM02BB11, CAM02BB12, CAM02BB20, CAM02BB21, CAM02BB22; //for CIECAT02
double Xchk[50], Ychk[50], Zchk[50]; //50 : I think it's a good limit for number of color : for CRI and Palette
double Xcam02[50], Ycam02[50], Zcam02[50];
double XchkLamp[50], YchkLamp[50], ZchkLamp[50];
double Xcam02Lamp[50], Ycam02Lamp[50], Zcam02Lamp[50];
const double epsilon = 0.008856; //Lab
double xr[50], yr[50], zr[50];
double fx[50], fy[50], fz[50];
double x, y, z;
double Ywb = 1.0;
int illum;
int numero_color = settings->CRI_color - 1;

View File

@ -19,22 +19,19 @@
#ifndef _COLORTEMP_
#define _COLORTEMP_
#include <glibmm.h>
#include <cmath>
#define pow_F(a,b) (xexpf(b*xlogf(a)))
#include <map>
namespace rtengine
{
#define MINTEMP 1500
#define MAXTEMP 60000
#define MINGREEN 0.02
#define MAXGREEN 10.0
#define MINEQUAL 0.8
#define MAXEQUAL 1.5
#define INITIALBLACKBODY 4000
constexpr double MINTEMP = 1500.0;
constexpr double MAXTEMP = 60000.0;
constexpr double MINGREEN = 0.02;
constexpr double MAXGREEN = 10.0;
constexpr double MINEQUAL = 0.8;
constexpr double MAXEQUAL = 1.5;
constexpr double INITIALBLACKBODY = 4000.0;
class ColorTemp
@ -49,12 +46,12 @@ private:
static void clip (double &temp, double &green, double &equal);
int XYZtoCorColorTemp(double x0, double y0 , double z0, double &temp) const;
void temp2mul (double temp, double green, double equal, double& rmul, double& gmul, double& bmul) const;
const static std::map<std::string,const double *> spectMap;
public:
ColorTemp () : temp(-1.), green(-1.), equal (1.), method("Custom") {}
explicit ColorTemp (double e) : temp(-1.), green(-1.), equal (e), method("Custom") {}
ColorTemp (double t, double g, double e, const Glib::ustring &m);
ColorTemp (double t, double g, double e, const std::string &m);
ColorTemp (double mulr, double mulg, double mulb, double e);
void update (const double rmul, const double gmul, const double bmul, const double equal, const double tempBias=0.0)
@ -95,7 +92,7 @@ public:
}
void mul2temp (const double rmul, const double gmul, const double bmul, const double equal, double& temp, double& green) const;
static void temp2mulxyz (double tem, double gree, const std::string &method, double &Xxyz, double &Zxyz);
static void temp2mulxyz (double tem, const std::string &method, double &Xxyz, double &Zxyz);
static void cieCAT02(double Xw, double Yw, double Zw, double &CAM02BB00, double &CAM02BB01, double &CAM02BB02, double &CAM02BB10, double &CAM02BB11, double &CAM02BB12, double &CAM02BB20, double &CAM02BB21, double &CAM02BB22, double adap );
//static void CAT02 (Imagefloat* baseImg, const ProcParams* params);

View File

@ -734,14 +734,10 @@ void CurveFactory::complexsgnCurve (bool & autili, bool & butili, bool & ccutil
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSEFUNCTION void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh,
double shcompr, double br, double contr,
procparams::ToneCurveParams::eTCModeId curveMode, const std::vector<double>& curvePoints,
procparams::ToneCurveParams::eTCModeId curveMode2, const std::vector<double>& curvePoints2,
const std::vector<double>& curvePoints,
const std::vector<double>& curvePoints2,
LUTu & histogram,
LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve,
LUTu & outBeforeCCurveHistogram,
@ -2043,7 +2039,7 @@ void ColorGradientCurve::Reset()
lut3.reset();
}
void ColorGradientCurve::SetXYZ (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin)
void ColorGradientCurve::SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], float satur, float lumin)
{
if (pCurve->isIdentity()) {
lut1.reset();
@ -2183,7 +2179,7 @@ void ColorGradientCurve::SetXYZ (const Curve *pCurve, const double xyz_rgb[3][3]
*/
}
void ColorGradientCurve::SetXYZ (const std::vector<double> &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin)
void ColorGradientCurve::SetXYZ(const std::vector<double> &curvePoints, const double xyz_rgb[3][3], float satur, float lumin)
{
std::unique_ptr<FlatCurve> tcurve;
@ -2192,11 +2188,11 @@ void ColorGradientCurve::SetXYZ (const std::vector<double> &curvePoints, const d
}
if (tcurve) {
SetXYZ (tcurve.get(), xyz_rgb, rgb_xyz, satur, lumin);
SetXYZ(tcurve.get(), xyz_rgb, satur, lumin);
}
}
void ColorGradientCurve::SetRGB (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3])
void ColorGradientCurve::SetRGB(const Curve *pCurve)
{
if (pCurve->isIdentity()) {
lut1.reset();
@ -2282,7 +2278,7 @@ void ColorGradientCurve::SetRGB (const Curve *pCurve, const double xyz_rgb[3][3]
*/
}
void ColorGradientCurve::SetRGB (const std::vector<double> &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3])
void ColorGradientCurve::SetRGB(const std::vector<double> &curvePoints)
{
std::unique_ptr<FlatCurve> tcurve;
@ -2291,7 +2287,7 @@ void ColorGradientCurve::SetRGB (const std::vector<double> &curvePoints, const d
}
if (tcurve) {
SetRGB (tcurve.get(), xyz_rgb, rgb_xyz);
SetRGB(tcurve.get());
}
}
@ -2666,10 +2662,10 @@ void PerceptualToneCurve::Apply (float &r, float &g, float &b, PerceptualToneCur
C *= cmul;
Ciecam02::jch2xyz_ciecam02float ( x, y, z,
J, C, h,
xw, yw, zw,
f, c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw );
Ciecam02::jch2xyz_ciecam02float( x, y, z,
J, C, h,
xw, yw, zw,
c, nc, 1, pow1, nbb, ncb, fl, cz, d, aw );
if (!isfinite (x) || !isfinite (y) || !isfinite (z)) {
// can happen for colors on the rim of being outside gamut, that worked without chroma scaling but not with. Then we return only the curve's result.

View File

@ -304,7 +304,7 @@ public:
public:
static void complexCurve (double ecomp, double black, double hlcompr, double hlcomprthresh, double shcompr, double br, double contr,
procparams::ToneCurveParams::eTCModeId curveMode, const std::vector<double>& curvePoints, procparams::ToneCurveParams::eTCModeId curveMode2, const std::vector<double>& curvePoints2,
const std::vector<double>& curvePoints, const std::vector<double>& curvePoints2,
LUTu & histogram, LUTf & hlCurve, LUTf & shCurve, LUTf & outCurve, LUTu & outBeforeCCurveHistogram, ToneCurve & outToneCurve, ToneCurve & outToneCurve2,
int skip = 1);
@ -840,10 +840,10 @@ public:
virtual ~ColorGradientCurve() {};
void Reset();
void SetXYZ (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin);
void SetXYZ (const std::vector<double> &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3], float satur, float lumin);
void SetRGB (const Curve *pCurve, const double xyz_rgb[3][3], const double rgb_xyz[3][3]);
void SetRGB (const std::vector<double> &curvePoints, const double xyz_rgb[3][3], const double rgb_xyz[3][3]);
void SetXYZ(const Curve *pCurve, const double xyz_rgb[3][3], float satur, float lumin);
void SetXYZ(const std::vector<double> &curvePoints, const double xyz_rgb[3][3], float satur, float lumin);
void SetRGB(const Curve *pCurve);
void SetRGB(const std::vector<double> &curvePoints);
/**
* @brief Get the value of Red, Green and Blue corresponding to the requested index
@ -954,11 +954,6 @@ class StandardToneCurve : public ToneCurve
public:
void Apply (float& r, float& g, float& b) const;
};
class StandardToneCurvebw : public ToneCurve
{
public:
void Apply (float& r, float& g, float& b) const;
};
class AdobeToneCurve : public ToneCurve
{
@ -969,27 +964,12 @@ public:
void Apply (float& r, float& g, float& b) const;
};
class AdobeToneCurvebw : public ToneCurve
{
private:
void RGBTone (float& r, float& g, float& b) const; // helper for tone curve
public:
void Apply (float& r, float& g, float& b) const;
};
class SatAndValueBlendingToneCurve : public ToneCurve
{
public:
void Apply (float& r, float& g, float& b) const;
};
class SatAndValueBlendingToneCurvebw : public ToneCurve
{
public:
void Apply (float& r, float& g, float& b) const;
};
class WeightedStdToneCurve : public ToneCurve
{
private:
@ -1037,14 +1017,6 @@ public:
void Apply (float& r, float& g, float& b, PerceptualToneCurveState & state) const;
};
class WeightedStdToneCurvebw : public ToneCurve
{
private:
float Triangle (float refX, float refY, float X2) const;
public:
void Apply (float& r, float& g, float& b) const;
};
// Standard tone curve
inline void StandardToneCurve::Apply (float& r, float& g, float& b) const
{
@ -1055,16 +1027,6 @@ inline void StandardToneCurve::Apply (float& r, float& g, float& b) const
g = lutToneCurve[g];
b = lutToneCurve[b];
}
// Standard tone curve
inline void StandardToneCurvebw::Apply (float& r, float& g, float& b) const
{
assert (lutToneCurve);
r = lutToneCurve[r];
g = lutToneCurve[g];
b = lutToneCurve[b];
}
// Tone curve according to Adobe's reference implementation
// values in 0xffff space
@ -1096,33 +1058,6 @@ inline void AdobeToneCurve::Apply (float& r, float& g, float& b) const
}
}
}
inline void AdobeToneCurvebw::Apply (float& r, float& g, float& b) const
{
assert (lutToneCurve);
if (r >= g) {
if (g > b) {
RGBTone (r, g, b); // Case 1: r >= g > b
} else if (b > r) {
RGBTone (b, r, g); // Case 2: b > r >= g
} else if (b > g) {
RGBTone (r, b, g); // Case 3: r >= b > g
} else { // Case 4: r >= g == b
r = lutToneCurve[r];
g = lutToneCurve[g];
b = g;
}
} else {
if (r >= b) {
RGBTone (g, r, b); // Case 5: g > r >= b
} else if (b > g) {
RGBTone (b, g, r); // Case 6: b > g > r
} else {
RGBTone (g, b, r); // Case 7: g >= b > r
}
}
}
inline void AdobeToneCurve::RGBTone (float& r, float& g, float& b) const
{
@ -1132,14 +1067,6 @@ inline void AdobeToneCurve::RGBTone (float& r, float& g, float& b) const
b = lutToneCurve[bold];
g = b + ((r - b) * (gold - bold) / (rold - bold));
}
inline void AdobeToneCurvebw::RGBTone (float& r, float& g, float& b) const
{
float rold = r, gold = g, bold = b;
r = lutToneCurve[rold];
b = lutToneCurve[bold];
g = b + ((r - b) * (gold - bold) / (rold - bold));
}
// Modifying the Luminance channel only
inline void LuminanceToneCurve::Apply (float &r, float &g, float &b) const
@ -1173,23 +1100,6 @@ inline float WeightedStdToneCurve::Triangle (float a, float a1, float b) const
return a1;
}
inline float WeightedStdToneCurvebw::Triangle (float a, float a1, float b) const
{
if (a != b) {
float b1;
float a2 = a1 - a;
if (b < a) {
b1 = b + a2 * b / a ;
} else {
b1 = b + a2 * (65535.f - b) / (65535.f - a);
}
return b1;
}
return a1;
}
// Tone curve modifying the value channel only, preserving hue and saturation
// values in 0xffff space
@ -1215,28 +1125,6 @@ inline void WeightedStdToneCurve::Apply (float& r, float& g, float& b) const
b = CLIP<float> (b1 * 0.25f + b2 * 0.25f + b3 * 0.50f);
}
inline void WeightedStdToneCurvebw::Apply (float& r, float& g, float& b) const
{
assert (lutToneCurve);
float r1 = lutToneCurve[r];
float g1 = Triangle (r, r1, g);
float b1 = Triangle (r, r1, b);
float g2 = lutToneCurve[g];
float r2 = Triangle (g, g2, r);
float b2 = Triangle (g, g2, b);
float b3 = lutToneCurve[b];
float r3 = Triangle (b, b3, r);
float g3 = Triangle (b, b3, g);
r = CLIP<float> ( r1 * 0.50f + r2 * 0.25f + r3 * 0.25f);
g = CLIP<float> (g1 * 0.25f + g2 * 0.50f + g3 * 0.25f);
b = CLIP<float> (b1 * 0.25f + b2 * 0.25f + b3 * 0.50f);
}
// Tone curve modifying the value channel only, preserving hue and saturation
// values in 0xffff space
inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) const
@ -1253,54 +1141,20 @@ inline void SatAndValueBlendingToneCurve::Apply (float& r, float& g, float& b) c
return;
}
bool increase = newLum > lum;
Color::rgb2hsv(r, g, b, h, s, v);
Color::rgb2hsv (r, g, b, h, s, v);
if (increase) {
float dV;
if (newLum > lum) {
// Linearly targeting Value = 1 and Saturation = 0
float coef = (newLum - lum) / (65535.f - lum);
float dV = (1.f - v) * coef;
dV = (1.f - v) * coef;
s *= 1.f - coef;
Color::hsv2rgb (h, s, v + dV, r, g, b);
} else {
// Linearly targeting Value = 0
float coef = (lum - newLum) / lum ;
float dV = v * coef;
Color::hsv2rgb (h, s, v - dV, r, g, b);
}
}
inline void SatAndValueBlendingToneCurvebw::Apply (float& r, float& g, float& b) const
{
assert (lutToneCurve);
float h, s, v;
float lum = (r + g + b) / 3.f;
//float lum = Color::rgbLuminance(r, g, b);
float newLum = lutToneCurve[lum];
if (newLum == lum) {
return;
}
bool increase = newLum > lum;
Color::rgb2hsv (r, g, b, h, s, v);
if (increase) {
// Linearly targeting Value = 1 and Saturation = 0
float coef = (newLum - lum) / (65535.f - lum);
float dV = (1.f - v) * coef;
s *= 1.f - coef;
Color::hsv2rgb (h, s, v + dV, r, g, b);
} else {
// Linearly targeting Value = 0
float coef = (lum - newLum) / lum ;
float dV = v * coef;
Color::hsv2rgb (h, s, v - dV, r, g, b);
float coef = (newLum - lum) / lum ;
dV = v * coef;
}
Color::hsv2rgb(h, s, v + dV, r, g, b);
}
}

View File

@ -1435,253 +1435,278 @@ int CLASS raw (unsigned row, unsigned col)
void CLASS phase_one_flat_field (int is_float, int nc)
{
ushort head[8];
unsigned wide, high, y, x, c, rend, cend, row, col;
float *mrow, num, mult[4];
ushort uhead[8];
read_shorts (head, 8);
if (head[2] * head[3] * head[4] * head[5] == 0) return;
wide = head[2] / head[4] + (head[2] % head[4] != 0);
high = head[3] / head[5] + (head[3] % head[5] != 0);
mrow = (float *) calloc (nc*wide, sizeof *mrow);
merror (mrow, "phase_one_flat_field()");
for (y=0; y < high; y++) {
for (x=0; x < wide; x++)
for (c=0; c < nc; c+=2) {
num = is_float ? getreal(11) : get2()/32768.0;
if (y==0) mrow[c*wide+x] = num;
else mrow[(c+1)*wide+x] = (num - mrow[c*wide+x]) / head[5];
}
if (y==0) continue;
rend = head[1] + y*head[5];
for (row = rend-head[5];
row < raw_height && row < rend &&
row < head[1]+head[3]-head[5]; row++) {
for (x=1; x < wide; x++) {
for (c=0; c < nc; c+=2) {
mult[c] = mrow[c*wide+x-1];
mult[c+1] = (mrow[c*wide+x] - mult[c]) / head[4];
}
cend = head[0] + x*head[4];
for (col = cend-head[4];
col < raw_width &&
col < cend && col < head[0]+head[2]-head[4]; col++) {
c = nc > 2 ? FC(row-top_margin,col-left_margin) : 0;
if (!(c & 1)) {
c = RAW(row,col) * mult[c];
RAW(row,col) = LIM(c,0,65535);
}
for (c=0; c < nc; c+=2)
mult[c] += mult[c+1];
}
}
for (x=0; x < wide; x++)
for (c=0; c < nc; c+=2)
mrow[c*wide+x] += mrow[(c+1)*wide+x];
read_shorts (uhead, 8);
if (uhead[2] * uhead[3] * uhead[4] * uhead[5] == 0) {
return;
}
}
free (mrow);
const unsigned wide = uhead[2] / uhead[4] + (uhead[2] % uhead[4] != 0);
const unsigned high = uhead[3] / uhead[5] + (uhead[3] % uhead[5] != 0);
const unsigned colLimit = std::min(uhead[0] + uhead[2] - uhead[4], (int)raw_width);
const float head4 = 1.0 / uhead[4];
const float head5 = 1.0 / uhead[5];
float* mrow = (float *) calloc(nc * wide, sizeof *mrow);
merror(mrow, "phase_one_flat_field()");
for (unsigned x=0; x < wide; x++) {
for (unsigned c=0; c < nc; c+=2) {
float num = is_float ? getreal(11) : get2() / 32768.f;
mrow[c * wide + x] = num;
}
}
for (unsigned y=1; y < high; y++) {
for (unsigned x=0; x < wide; x++) {
for (unsigned c=0; c < nc; c+=2) {
float num = is_float ? getreal(11) : get2() / 32768.f;
mrow[(c + 1) * wide + x] = (num - mrow[c * wide + x]) * head5;
}
}
const unsigned rend = uhead[1] + y * uhead[5];
for (unsigned row = rend - uhead[5]; row < raw_height && row < rend && row < uhead[1] + uhead[3] - uhead[5]; row++) {
unsigned cend = uhead[0] + uhead[4];
const unsigned c0 = FC(row - top_margin, cend - uhead[4] - left_margin);
const unsigned c = nc > 2 ? (c0 & 1) ? FC(row - top_margin, cend - uhead[4] - left_margin + 1) : c0 : 0;
for (unsigned x=1; x < wide; x++, cend += uhead[4]) {
float mult0 = mrow[c * wide + x - 1];
float mult1 = (mrow[c * wide + x] - mult0) * head4;
if (nc > 2) {
mult0 += (c0 & 1) ? mult1 : 0;
for (unsigned col = cend - uhead[4] + (c0 & 1); col < std::min(colLimit, cend); col += 2) {
unsigned val = RAW(row, col) * mult0;
RAW(row, col) = rtengine::min(val, 65535u);
mult0 += mult1;
mult0 += mult1; // <= this could be reduced to one addition inside the loop, but then the result is not exactly the same as with old code, though it should be even more accurate then
}
} else {
for (unsigned col = cend - uhead[4]; col < std::min(colLimit, cend); col++) {
unsigned val = RAW(row, col) * mult0;
RAW(row, col) = rtengine::min(val, 65535u);
mult0 += mult1;
}
}
}
for (unsigned x = 0; x < wide; x++) {
for (unsigned c = 0; c < nc; c += 2) {
mrow[c * wide + x] += mrow[(c + 1) * wide + x];
}
}
}
}
free(mrow);
}
void CLASS phase_one_correct()
{
unsigned entries, tag, data, save, col, row, type;
int len, i, j, k, cip, val[4], dev[4], sum, max;
int head[9], diff, mindiff=INT_MAX, off_412=0;
static const signed char dir[12][2] =
{ {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0},
{-2,-2}, {-2,2}, {2,-2}, {2,2} };
float poly[8], num, cfrac, frac, mult[2], *yval[2];
ushort *xval[2];
int qmult_applied = 0, qlin_applied = 0;
unsigned entries, tag, data, save, col, row, type;
int len, i, j, k, cip, val[4], dev[4], sum, max;
int head[9], diff, mindiff=INT_MAX, off_412=0;
static const signed char dir[12][2] = { {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0}, {-2,-2}, {-2,2}, {2,-2}, {2,2} };
float poly[8], num, cfrac, frac, mult[2], *yval[2];
ushort *xval[2];
int qmult_applied = 0, qlin_applied = 0;
if (half_size || !meta_length) return;
if (verbose) fprintf (stderr,_("Phase One correction...\n"));
fseek (ifp, meta_offset, SEEK_SET);
order = get2();
fseek (ifp, 6, SEEK_CUR);
fseek (ifp, meta_offset+get4(), SEEK_SET);
entries = get4(); get4();
while (entries--) {
tag = get4();
len = get4();
data = get4();
save = ftell(ifp);
fseek (ifp, meta_offset+data, SEEK_SET);
if (tag == 0x419) { /* Polynomial curve */
for (get4(), i=0; i < 8; i++)
poly[i] = getreal(11);
poly[3] += (ph1.tag_210 - poly[7]) * poly[6] + 1;
for (i=0; i < 0x10000; i++) {
num = (poly[5]*i + poly[3])*i + poly[1];
curve[i] = LIM(num,0,65535);
} goto apply; /* apply to right half */
} else if (tag == 0x41a) { /* Polynomial curve */
for (i=0; i < 4; i++)
poly[i] = getreal(11);
for (i=0; i < 0x10000; i++) {
for (num=0, j=4; j--; )
num = num * i + poly[j];
curve[i] = LIM(num+i,0,65535);
} apply: /* apply to whole image */
for (row=0; row < raw_height; row++)
for (col = (tag & 1)*ph1.split_col; col < raw_width; col++)
RAW(row,col) = curve[RAW(row,col)];
} else if (tag == 0x400) { /* Sensor defects */
while ((len -= 8) >= 0) {
col = get2();
row = get2();
type = get2(); get2();
if (col >= raw_width) continue;
if (type == 131 || type == 137) /* Bad column */
for (row=0; row < raw_height; row++)
if (FC(row-top_margin,col-left_margin) == 1) {
for (sum=i=0; i < 4; i++)
sum += val[i] = raw (row+dir[i][0], col+dir[i][1]);
for (max=i=0; i < 4; i++) {
dev[i] = abs((val[i] << 2) - sum);
if (dev[max] < dev[i]) max = i;
}
RAW(row,col) = (sum - val[max])/3.0 + 0.5;
} else {
for (sum=0, i=8; i < 12; i++)
sum += raw (row+dir[i][0], col+dir[i][1]);
RAW(row,col) = 0.5 + sum * 0.0732233 +
(raw(row,col-2) + raw(row,col+2)) * 0.3535534;
}
else if (type == 129) { /* Bad pixel */
if (row >= raw_height) continue;
j = (FC(row-top_margin,col-left_margin) != 1) * 4;
for (sum=0, i=j; i < j+8; i++)
sum += raw (row+dir[i][0], col+dir[i][1]);
RAW(row,col) = (sum + 4) >> 3;
}
}
} else if (tag == 0x401) { /* All-color flat fields */
phase_one_flat_field (1, 2);
} else if (tag == 0x416 || tag == 0x410) {
phase_one_flat_field (0, 2);
} else if (tag == 0x40b) { /* Red+blue flat field */
phase_one_flat_field (0, 4);
} else if (tag == 0x412) {
fseek (ifp, 36, SEEK_CUR);
diff = abs (get2() - ph1.tag_21a);
if (mindiff > diff) {
mindiff = diff;
off_412 = ftell(ifp) - 38;
}
} else if (tag == 0x41f && !qlin_applied) { /* Quadrant linearization */
ushort lc[2][2][16], ref[16];
int qr, qc;
for (qr = 0; qr < 2; qr++)
for (qc = 0; qc < 2; qc++)
for (i = 0; i < 16; i++)
lc[qr][qc][i] = get4();
for (i = 0; i < 16; i++) {
int v = 0;
for (qr = 0; qr < 2; qr++)
for (qc = 0; qc < 2; qc++)
v += lc[qr][qc][i];
ref[i] = (v + 2) >> 2;
}
for (qr = 0; qr < 2; qr++) {
for (qc = 0; qc < 2; qc++) {
int cx[19], cf[19];
for (i = 0; i < 16; i++) {
cx[1+i] = lc[qr][qc][i];
cf[1+i] = ref[i];
}
cx[0] = cf[0] = 0;
cx[17] = cf[17] = ((unsigned) ref[15] * 65535) / lc[qr][qc][15];
cx[18] = cf[18] = 65535;
cubic_spline(cx, cf, 19);
for (row = (qr ? ph1.split_row : 0);
row < (qr ? raw_height : ph1.split_row); row++)
for (col = (qc ? ph1.split_col : 0);
col < (qc ? raw_width : ph1.split_col); col++)
RAW(row,col) = curve[RAW(row,col)];
}
}
qlin_applied = 1;
} else if (tag == 0x41e && !qmult_applied) { /* Quadrant multipliers */
float qmult[2][2] = { { 1, 1 }, { 1, 1 } };
get4(); get4(); get4(); get4();
qmult[0][0] = 1.0 + getreal(11);
get4(); get4(); get4(); get4(); get4();
qmult[0][1] = 1.0 + getreal(11);
get4(); get4(); get4();
qmult[1][0] = 1.0 + getreal(11);
get4(); get4(); get4();
qmult[1][1] = 1.0 + getreal(11);
for (row=0; row < raw_height; row++)
for (col=0; col < raw_width; col++) {
i = qmult[row >= ph1.split_row][col >= ph1.split_col] * RAW(row,col);
RAW(row,col) = LIM(i,0,65535);
}
qmult_applied = 1;
} else if (tag == 0x431 && !qmult_applied) { /* Quadrant combined */
ushort lc[2][2][7], ref[7];
int qr, qc;
for (i = 0; i < 7; i++)
ref[i] = get4();
for (qr = 0; qr < 2; qr++)
for (qc = 0; qc < 2; qc++)
for (i = 0; i < 7; i++)
lc[qr][qc][i] = get4();
for (qr = 0; qr < 2; qr++) {
for (qc = 0; qc < 2; qc++) {
int cx[9], cf[9];
for (i = 0; i < 7; i++) {
cx[1+i] = ref[i];
cf[1+i] = ((unsigned) ref[i] * lc[qr][qc][i]) / 10000;
}
cx[0] = cf[0] = 0;
cx[8] = cf[8] = 65535;
cubic_spline(cx, cf, 9);
for (row = (qr ? ph1.split_row : 0);
row < (qr ? raw_height : ph1.split_row); row++)
for (col = (qc ? ph1.split_col : 0);
col < (qc ? raw_width : ph1.split_col); col++)
RAW(row,col) = curve[RAW(row,col)];
}
}
qmult_applied = 1;
qlin_applied = 1;
if (half_size || !meta_length) {
return;
}
if (verbose) {
fprintf (stderr,_("Phase One correction...\n"));
}
fseek (ifp, meta_offset, SEEK_SET);
order = get2();
fseek (ifp, 6, SEEK_CUR);
fseek (ifp, meta_offset+get4(), SEEK_SET);
entries = get4(); get4();
while (entries--) {
tag = get4();
len = get4();
data = get4();
save = ftell(ifp);
fseek (ifp, meta_offset+data, SEEK_SET);
if (tag == 0x419) { /* Polynomial curve */
for (get4(), i=0; i < 8; i++) {
poly[i] = getreal(11);
}
poly[3] += (ph1.tag_210 - poly[7]) * poly[6] + 1;
for (i=0; i < 0x10000; i++) {
num = (poly[5]*i + poly[3])*i + poly[1];
curve[i] = LIM(num,0,65535);
}
goto apply; /* apply to right half */
} else if (tag == 0x41a) { /* Polynomial curve */
for (i=0; i < 4; i++) {
poly[i] = getreal(11);
}
for (i=0; i < 0x10000; i++) {
for (num=0, j=4; j--;) {
num = num * i + poly[j];
}
curve[i] = LIM(num+i,0,65535);
}
apply: /* apply to whole image */
#pragma omp parallel for schedule(dynamic,16)
for (int row=0; row < raw_height; row++) {
for (int col = (tag & 1)*ph1.split_col; col < raw_width; col++) {
RAW(row,col) = curve[RAW(row,col)];
}
}
} else if (tag == 0x400) { /* Sensor defects */
while ((len -= 8) >= 0) {
col = get2();
row = get2();
type = get2();
get2();
if (col >= raw_width) continue;
if (type == 131 || type == 137) { /* Bad column */
for (row=0; row < raw_height; row++) {
if (FC(row-top_margin,col-left_margin) == 1) {
for (sum=i=0; i < 4; i++)
sum += val[i] = raw (row+dir[i][0], col+dir[i][1]);
for (max=i=0; i < 4; i++) {
dev[i] = abs((val[i] << 2) - sum);
if (dev[max] < dev[i]) max = i;
}
RAW(row,col) = (sum - val[max])/3.0 + 0.5;
} else {
for (sum=0, i=8; i < 12; i++)
sum += raw (row+dir[i][0], col+dir[i][1]);
RAW(row,col) = 0.5 + sum * 0.0732233 + (raw(row,col-2) + raw(row,col+2)) * 0.3535534;
}
}
} else if (type == 129) { /* Bad pixel */
if (row >= raw_height) continue;
j = (FC(row-top_margin,col-left_margin) != 1) * 4;
for (sum=0, i=j; i < j+8; i++)
sum += raw (row+dir[i][0], col+dir[i][1]);
RAW(row,col) = (sum + 4) >> 3;
}
}
} else if (tag == 0x401) { /* All-color flat fields */
phase_one_flat_field (1, 2);
} else if (tag == 0x416 || tag == 0x410) {
phase_one_flat_field (0, 2);
} else if (tag == 0x40b) { /* Red+blue flat field */
phase_one_flat_field (0, 4);
} else if (tag == 0x412) {
fseek (ifp, 36, SEEK_CUR);
diff = abs (get2() - ph1.tag_21a);
if (mindiff > diff) {
mindiff = diff;
off_412 = ftell(ifp) - 38;
}
} else if (tag == 0x41f && !qlin_applied) { /* Quadrant linearization */
ushort lc[2][2][16], ref[16];
int qr, qc;
for (qr = 0; qr < 2; qr++)
for (qc = 0; qc < 2; qc++)
for (i = 0; i < 16; i++)
lc[qr][qc][i] = get4();
for (i = 0; i < 16; i++) {
int v = 0;
for (qr = 0; qr < 2; qr++)
for (qc = 0; qc < 2; qc++)
v += lc[qr][qc][i];
ref[i] = (v + 2) >> 2;
}
for (qr = 0; qr < 2; qr++) {
for (qc = 0; qc < 2; qc++) {
int cx[19], cf[19];
for (i = 0; i < 16; i++) {
cx[1+i] = lc[qr][qc][i];
cf[1+i] = ref[i];
}
cx[0] = cf[0] = 0;
cx[17] = cf[17] = ((unsigned) ref[15] * 65535) / lc[qr][qc][15];
cx[18] = cf[18] = 65535;
cubic_spline(cx, cf, 19);
#pragma omp parallel for schedule(dynamic,16)
for (int row = (qr ? ph1.split_row : 0); row < (qr ? raw_height : ph1.split_row); row++)
for (int col = (qc ? ph1.split_col : 0); col < (qc ? raw_width : ph1.split_col); col++)
RAW(row,col) = curve[RAW(row,col)];
}
}
qlin_applied = 1;
} else if (tag == 0x41e && !qmult_applied) { /* Quadrant multipliers */
float qmult[2][2] = { { 1, 1 }, { 1, 1 } };
get4(); get4(); get4(); get4();
qmult[0][0] = 1.0 + getreal(11);
get4(); get4(); get4(); get4(); get4();
qmult[0][1] = 1.0 + getreal(11);
get4(); get4(); get4();
qmult[1][0] = 1.0 + getreal(11);
get4(); get4(); get4();
qmult[1][1] = 1.0 + getreal(11);
#pragma omp parallel for schedule(dynamic,16)
for (int row=0; row < raw_height; row++) {
for (int col=0; col < raw_width; col++) {
int i = qmult[row >= ph1.split_row][col >= ph1.split_col] * RAW(row,col);
RAW(row,col) = LIM(i,0,65535);
}
}
qmult_applied = 1;
} else if (tag == 0x431 && !qmult_applied) { /* Quadrant combined */
ushort lc[2][2][7], ref[7];
int qr, qc;
for (i = 0; i < 7; i++)
ref[i] = get4();
for (qr = 0; qr < 2; qr++)
for (qc = 0; qc < 2; qc++)
for (i = 0; i < 7; i++)
lc[qr][qc][i] = get4();
for (qr = 0; qr < 2; qr++) {
for (qc = 0; qc < 2; qc++) {
int cx[9], cf[9];
for (i = 0; i < 7; i++) {
cx[1+i] = ref[i];
cf[1+i] = ((unsigned) ref[i] * lc[qr][qc][i]) / 10000;
}
cx[0] = cf[0] = 0;
cx[8] = cf[8] = 65535;
cubic_spline(cx, cf, 9);
for (row = (qr ? ph1.split_row : 0); row < (qr ? raw_height : ph1.split_row); row++)
for (col = (qc ? ph1.split_col : 0); col < (qc ? raw_width : ph1.split_col); col++)
RAW(row,col) = curve[RAW(row,col)];
}
}
qmult_applied = 1;
qlin_applied = 1;
}
fseek (ifp, save, SEEK_SET);
}
if (off_412) {
fseek (ifp, off_412, SEEK_SET);
for (i=0; i < 9; i++)
head[i] = get4() & 0x7fff;
yval[0] = (float *) calloc (head[1]*head[3] + head[2]*head[4], 6);
merror (yval[0], "phase_one_correct()");
yval[1] = (float *) (yval[0] + head[1]*head[3]);
xval[0] = (ushort *) (yval[1] + head[2]*head[4]);
xval[1] = (ushort *) (xval[0] + head[1]*head[3]);
get2();
for (i=0; i < 2; i++)
for (j=0; j < head[i+1]*head[i+3]; j++)
yval[i][j] = getreal(11);
for (i=0; i < 2; i++)
for (j=0; j < head[i+1]*head[i+3]; j++)
xval[i][j] = get2();
for (row=0; row < raw_height; row++)
for (col=0; col < raw_width; col++) {
cfrac = (float) col * head[3] / raw_width;
cfrac -= cip = cfrac;
num = RAW(row,col) * 0.5;
for (i=cip; i < cip+2; i++) {
for (k=j=0; j < head[1]; j++)
if (num < xval[0][k = head[1]*i+j])
break;
frac = (j == 0 || j == head[1]) ? 0 : (xval[0][k] - num) / (xval[0][k] - xval[0][k-1]);
mult[i-cip] = yval[0][k-1] * frac + yval[0][k] * (1-frac);
}
i = ((mult[0] * (1-cfrac) + mult[1] * cfrac) * row + num) * 2;
RAW(row,col) = LIM(i,0,65535);
}
free (yval[0]);
}
fseek (ifp, save, SEEK_SET);
}
if (off_412) {
fseek (ifp, off_412, SEEK_SET);
for (i=0; i < 9; i++) head[i] = get4() & 0x7fff;
yval[0] = (float *) calloc (head[1]*head[3] + head[2]*head[4], 6);
merror (yval[0], "phase_one_correct()");
yval[1] = (float *) (yval[0] + head[1]*head[3]);
xval[0] = (ushort *) (yval[1] + head[2]*head[4]);
xval[1] = (ushort *) (xval[0] + head[1]*head[3]);
get2();
for (i=0; i < 2; i++)
for (j=0; j < head[i+1]*head[i+3]; j++)
yval[i][j] = getreal(11);
for (i=0; i < 2; i++)
for (j=0; j < head[i+1]*head[i+3]; j++)
xval[i][j] = get2();
for (row=0; row < raw_height; row++)
for (col=0; col < raw_width; col++) {
cfrac = (float) col * head[3] / raw_width;
cfrac -= cip = cfrac;
num = RAW(row,col) * 0.5;
for (i=cip; i < cip+2; i++) {
for (k=j=0; j < head[1]; j++)
if (num < xval[0][k = head[1]*i+j]) break;
frac = (j == 0 || j == head[1]) ? 0 :
(xval[0][k] - num) / (xval[0][k] - xval[0][k-1]);
mult[i-cip] = yval[0][k-1] * frac + yval[0][k] * (1-frac);
}
i = ((mult[0] * (1-cfrac) + mult[1] * cfrac) * row + num) * 2;
RAW(row,col) = LIM(i,0,65535);
}
free (yval[0]);
}
}
void CLASS phase_one_load_raw()
@ -1725,9 +1750,35 @@ unsigned CLASS ph1_bithuff_t::operator() (int nbits, ushort *huff)
vbits -= nbits;
return c;
}
#define ph1_bits(n) ph1_bithuff(n,0)
inline unsigned CLASS ph1_bithuff_t::operator() (int nbits)
{
/*RT static UINT64 bitbuf=0; */
/*RT static int vbits=0; */
if (vbits < nbits) {
bitbuf = bitbuf << 32 | get4();
vbits += 32;
}
unsigned c = bitbuf << (64-vbits) >> (64-nbits);
vbits -= nbits;
return c;
}
inline unsigned CLASS ph1_bithuff_t::operator() ()
{
/*RT static UINT64 bitbuf=0; */
/*RT static int vbits=0; */
return bitbuf = vbits = 0;
}
#define ph1_init() ph1_bithuff()
#define ph1_bits(n) ph1_bithuff(n)
#define hb_bits(n) ph1_bithuff(n,0)
#define ph1_huff(h) ph1_bithuff(*h,h+1)
#ifndef MYFILE_MMAP
void CLASS phase_one_load_raw_c()
{
static const int length[] = { 8,7,6,9,11,10,5,12,14,13 };
@ -1751,9 +1802,10 @@ void CLASS phase_one_load_raw_c()
read_shorts ((ushort *) rblack[0], raw_width*2);
for (i=0; i < 256; i++)
curve[i] = i*i / 3.969 + 0.5;
ph1_bithuff_t ph1_bithuff(this, ifp, order);
for (row=0; row < raw_height; row++) {
fseek (ifp, data_offset + offset[row], SEEK_SET);
ph1_bits(-1);
ph1_init();
pred[0] = pred[1] = 0;
for (col=0; col < raw_width; col++) {
if (col >= (raw_width & -8))
@ -1781,7 +1833,92 @@ void CLASS phase_one_load_raw_c()
free (pixel);
maximum = 0xfffc - ph1.black;
}
#else
void CLASS phase_one_load_raw_c()
{
static const int length[] = { 8,7,6,9,11,10,5,12,14,13 };
int *offset = (int *)calloc(raw_width * 2 + raw_height * 4, 2);
fseek(ifp, strip_offset, SEEK_SET);
for (int row = 0; row < raw_height; row++) {
offset[row] = get4();
}
short (*cblack)[2] = (short (*)[2]) (offset + raw_height);
fseek(ifp, ph1.black_col, SEEK_SET);
if (ph1.black_col) {
read_shorts ((ushort *) cblack[0], raw_height * 2);
}
short (*rblack)[2] = cblack + raw_height;
fseek(ifp, ph1.black_row, SEEK_SET);
if (ph1.black_row) {
read_shorts ((ushort *) rblack[0], raw_width * 2);
}
for (int i = 0; i < 256; i++) {
curve[i] = i * i / 3.969 + 0.5;
}
#ifdef _OPENMP
#pragma omp parallel
#endif
{
int len[2], pred[2];
IMFILE ifpthr = *ifp;
ifpthr.plistener = nullptr;
#ifdef _OPENMP
#pragma omp master
#endif
{
ifpthr.plistener = ifp->plistener;
}
ph1_bithuff_t ph1_bithuff(this, &ifpthr, order);
#ifdef _OPENMP
#pragma omp for schedule(dynamic,16)
#endif
for (int row = 0; row < raw_height; row++) {
const int shift = 2 * (ph1.format != 8);
fseek(&ifpthr, data_offset + offset[row], SEEK_SET);
ph1_init();
pred[0] = pred[1] = 0;
for (int col = 0; col < raw_width; col++) {
if (col >= (raw_width & -8)) {
len[0] = len[1] = 14;
} else if ((col & 7) == 0) {
for (int i = 0; i < 2; i++) {
int j;
for (j = 0; j < 5 && !ph1_bits(1); j++)
;
if (j--) {
len[i] = length[j * 2 + ph1_bits(1)];
}
}
}
int i = len[col & 1];
ushort pixel;
if (i == 14) {
pixel = pred[col & 1] = ph1_bits(16);
} else {
pixel = pred[col & 1] += ph1_bits(i) + 1 - (1 << (i - 1));
}
if (ph1.format == 5 && pixel < 256) {
pixel = curve[pixel];
}
int rawVal = (pixel << shift) - ph1.black + cblack[row][col >= ph1.split_col] + rblack[col][row >= ph1.split_row];
RAW(row,col) = std::max(rawVal, 0);
}
}
}
free(offset);
maximum = 0xfffc - ph1.black;
}
#endif
void CLASS parse_hasselblad_gain()
{
/*
@ -2122,7 +2259,8 @@ void CLASS hasselblad_load_raw()
if (!ljpeg_start (&jh, 0)) return;
order = 0x4949;
ph1_bits(-1);
ph1_bithuff_t ph1_bithuff(this, ifp, order);
hb_bits(-1);
back[4] = (int *) calloc (raw_width, 3*sizeof **back);
merror (back[4], "hasselblad_load_raw()");
FORC3 back[c] = back[4] + c*raw_width;
@ -2134,7 +2272,7 @@ void CLASS hasselblad_load_raw()
for (s=0; s < tiff_samples*2; s+=2) {
FORC(2) len[c] = ph1_huff(jh.huff[0]);
FORC(2) {
diff[s+c] = ph1_bits(len[c]);
diff[s+c] = hb_bits(len[c]);
if ((diff[s+c] & (1 << (len[c]-1))) == 0)
diff[s+c] -= (1 << len[c]) - 1;
if (diff[s+c] == 65535) diff[s+c] = -32768;
@ -3121,22 +3259,23 @@ void CLASS samsung_load_raw()
int row, col, c, i, dir, op[4], len[4];
order = 0x4949;
ph1_bithuff_t ph1_bithuff(this, ifp, order);
for (row=0; row < raw_height; row++) {
fseek (ifp, strip_offset+row*4, SEEK_SET);
fseek (ifp, data_offset+get4(), SEEK_SET);
ph1_bits(-1);
hb_bits(-1);
FORC4 len[c] = row < 2 ? 7:4;
for (col=0; col < raw_width; col+=16) {
dir = ph1_bits(1);
FORC4 op[c] = ph1_bits(2);
dir = hb_bits(1);
FORC4 op[c] = hb_bits(2);
FORC4 switch (op[c]) {
case 3: len[c] = ph1_bits(4); break;
case 3: len[c] = hb_bits(4); break;
case 2: len[c]--; break;
case 1: len[c]++;
}
for (c=0; c < 16; c+=2) {
i = len[((c & 1) << 1) | (c >> 3)];
RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) +
RAW(row,col+c) = ((signed) hb_bits(i) << (32-i) >> (32-i)) +
(dir ? RAW(row+(~c | -2),col+c) : col ? RAW(row,col+(c | -2)) : 128);
if (c == 14) c = -1;
}
@ -3178,27 +3317,28 @@ void CLASS samsung3_load_raw()
fseek (ifp, 9, SEEK_CUR);
opt = fgetc(ifp);
init = (get2(),get2());
ph1_bithuff_t ph1_bithuff(this, ifp, order);
for (row=0; row < raw_height; row++) {
fseek (ifp, (data_offset-ftell(ifp)) & 15, SEEK_CUR);
ph1_bits(-1);
hb_bits(-1);
mag = 0; pmode = 7;
FORC(6) ((ushort *)lent)[c] = row < 2 ? 7:4;
prow[ row & 1] = &RAW(row-1,1-((row & 1) << 1)); // green
prow[~row & 1] = &RAW(row-2,0); // red and blue
for (tab=0; tab+15 < raw_width; tab+=16) {
if (~opt & 4 && !(tab & 63)) {
i = ph1_bits(2);
mag = i < 3 ? mag-'2'+"204"[i] : ph1_bits(12);
i = hb_bits(2);
mag = i < 3 ? mag-'2'+"204"[i] : hb_bits(12);
}
if (opt & 2)
pmode = 7 - 4*ph1_bits(1);
else if (!ph1_bits(1))
pmode = ph1_bits(3);
if (opt & 1 || !ph1_bits(1)) {
FORC4 len[c] = ph1_bits(2);
pmode = 7 - 4*hb_bits(1);
else if (!hb_bits(1))
pmode = hb_bits(3);
if (opt & 1 || !hb_bits(1)) {
FORC4 len[c] = hb_bits(2);
FORC4 {
i = ((row & 1) << 1 | (c & 1)) % 3;
len[c] = len[c] < 3 ? lent[i][0]-'1'+"120"[len[c]] : ph1_bits(4);
len[c] = len[c] < 3 ? lent[i][0]-'1'+"120"[len[c]] : hb_bits(4);
lent[i][0] = lent[i][1];
lent[i][1] = len[c];
}
@ -3209,7 +3349,7 @@ void CLASS samsung3_load_raw()
? (tab ? RAW(row,tab-2+(col & 1)) : init)
: (prow[col & 1][col-'4'+"0224468"[pmode]] +
prow[col & 1][col-'4'+"0244668"[pmode]] + 1) >> 1;
diff = ph1_bits (i = len[c >> 2]);
diff = hb_bits (i = len[c >> 2]);
if (diff >> (i-1)) diff -= 1 << i;
diff = diff * (mag*2+1) + mag;
RAW(row,col) = pred + diff;
@ -4139,7 +4279,6 @@ void CLASS crop_masked_pixels()
}
}
} else {
#pragma omp parallel for
for (int row=0; row < height; row++)
for (int col=0; col < width; col++)

View File

@ -59,7 +59,6 @@ public:
,RT_blacklevel_from_constant(0)
,RT_matrix_from_constant(0)
,getbithuff(this,ifp,zero_after_ff)
,ph1_bithuff(this,ifp,order)
,pana_bits(ifp,load_flags)
{
memset(&hbd, 0, sizeof(hbd));
@ -285,8 +284,8 @@ void fuji_extend_generic(ushort *linebuf[_ltotal], int line_width, int start, in
void fuji_extend_red(ushort *linebuf[_ltotal], int line_width);
void fuji_extend_green(ushort *linebuf[_ltotal], int line_width);
void fuji_extend_blue(ushort *linebuf[_ltotal], int line_width);
void xtrans_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line);
void fuji_bayer_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line);
void xtrans_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params);
void fuji_bayer_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params);
void fuji_decode_strip(const struct fuji_compressed_params* info_common, int cur_block, INT64 raw_offset, unsigned dsize);
void fuji_compressed_load_raw();
void fuji_decode_loop(const struct fuji_compressed_params* common_info, int count, INT64* raw_block_offsets, unsigned *block_sizes);
@ -316,19 +315,45 @@ void parse_qt (int end);
// ph1_bithuff(int nbits, ushort *huff);
class ph1_bithuff_t {
public:
ph1_bithuff_t(DCraw *p,IMFILE *&i,short &o):parent(p),order(o),ifp(i),bitbuf(0),vbits(0){}
ph1_bithuff_t(DCraw *p, IMFILE *i, short &o):parent(p),order(o),ifp(i),bitbuf(0),vbits(0){}
unsigned operator()(int nbits, ushort *huff);
unsigned operator()(int nbits);
unsigned operator()();
ushort get2() {
uchar str[2] = { 0xff,0xff };
fread (str, 1, 2, ifp);
if (order == 0x4949) { /* "II" means little-endian */
return str[0] | str[1] << 8;
} else { /* "MM" means big-endian */
return str[0] << 8 | str[1];
}
}
private:
unsigned get4(){
return parent->get4();
inline unsigned get4() {
unsigned val = 0xffffff;
uchar* str = (uchar*)&val;
fread (str, 1, 4, ifp);
if (order == 0x4949) {
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
return val;
#else
return str[0] | str[1] << 8 | str[2] << 16 | str[3] << 24;
#endif
} else {
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
return str[0] << 24 | str[1] << 16 | str[2] << 8 | str[3];
#else
return val;
#endif
}
}
DCraw *parent;
short &order;
IMFILE *&ifp;
IMFILE* const ifp;
UINT64 bitbuf;
int vbits;
};
ph1_bithuff_t ph1_bithuff;
void phase_one_load_raw_c();
void hasselblad_correct();

View File

@ -238,18 +238,18 @@ void Crop::update (int todo)
if (settings->leveldnautsimpl == 1) {
if (params.dirpyrDenoise.Cmethod == "MAN" || params.dirpyrDenoise.Cmethod == "PON" ) {
PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip);
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw );
}
} else {
if (params.dirpyrDenoise.C2method == "MANU") {
PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip);
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw );
}
}
if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PRE") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "PREV")) {
PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip);
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw );
if ((!isDetailWindow) && parent->adnListener && skip == 1 && params.dirpyrDenoise.enabled) {
float lowdenoise = 1.f;
@ -461,7 +461,7 @@ void Crop::update (int todo)
for (int wcr = 0; wcr <= 2; wcr++) {
for (int hcr = 0; hcr <= 2; hcr++) {
PreviewProps ppP (coordW[wcr], coordH[hcr], crW, crH, 1);
parent->imgsrc->getImage (parent->currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw );
parent->imgsrc->getImage (parent->currWB, tr, origCropPart, ppP, params.toneCurve, params.raw );
// we only need image reduced to 1/4 here
for (int ii = 0; ii < crH; ii += 2) {
@ -623,7 +623,7 @@ void Crop::update (int todo)
// if(params.dirpyrDenoise.Cmethod=="AUT" || params.dirpyrDenoise.Cmethod=="PON") {//reinit origCrop after Auto
if ((settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "AUT") || (settings->leveldnautsimpl == 0 && params.dirpyrDenoise.C2method == "AUTO")) { //reinit origCrop after Auto
PreviewProps pp (trafx, trafy, trafw * skip, trafh * skip, skip);
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.raw );
}
DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise;
@ -663,8 +663,8 @@ void Crop::update (int todo)
if (skip == 1 && denoiseParams.enabled) {
int kall = 0;
float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi;
parent->ipf.RGB_denoise (kall, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi);
float nresi, highresi;
parent->ipf.RGB_denoise (kall, origCrop, origCrop, calclum, parent->denoiseInfoStore.ch_M, parent->denoiseInfoStore.max_r, parent->denoiseInfoStore.max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, nresi, highresi);
if (parent->adnListener) {
parent->adnListener->noiseChanged (nresi, highresi);
@ -773,7 +773,7 @@ void Crop::update (int todo)
if (todo & M_RGBCURVE) {
double rrm, ggm, bbm;
DCPProfile::ApplyState as;
DCPProfile *dcpProf = parent->imgsrc->getDCP (params.icm, parent->currWB, as);
DCPProfile *dcpProf = parent->imgsrc->getDCP (params.icm, as);
LUTu histToneCurve;
parent->ipf.rgbProc (baseCrop, laboCrop, this, parent->hltonecurve, parent->shtonecurve, parent->tonecurve, cshmap,
@ -814,7 +814,7 @@ void Crop::update (int todo)
bool ccutili = parent->ccutili;
bool clcutili = parent->clcutili;
bool cclutili = parent->cclutili;
bool wavcontlutili = parent->wavcontlutili;
bool locallutili = parent->locallutili;
LUTf lllocalcurve2 (65536, 0);
bool localcutili = parent->locallutili;
@ -1678,7 +1678,7 @@ void Crop::update (int todo)
params.wavelet.getCurves (wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL);
parent->ipf.ip_wavelet (labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, wavcontlutili, skip);
parent->ipf.ip_wavelet (labnCrop, labnCrop, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, parent->wavclCurve, skip);
}
// }
@ -1701,7 +1701,6 @@ void Crop::update (int todo)
// end calculation adaptation scene luminosity
}
int begh = 0, endh = labnCrop->H;
bool execsharp = false;
if (skip == 1) {
@ -1714,13 +1713,13 @@ void Crop::update (int todo)
if (settings->ciecamfloat) {
float d, dj, yb; // not used after this block
parent->ipf.ciecam_02float (cieCrop, float (adap), begh, endh, 1, 2, labnCrop, &params, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3,
parent->ipf.ciecam_02float (cieCrop, float (adap), 1, 2, labnCrop, &params, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3,
dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, d, dj, yb, 1);
} else {
double dd, dj, yb; // not used after this block
double dd, dj; // not used after this block
parent->ipf.ciecam_02 (cieCrop, adap, begh, endh, 1, 2, labnCrop, &params, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3,
dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, dd, dj, yb, 1);
parent->ipf.ciecam_02 (cieCrop, adap, 1, 2, labnCrop, &params, parent->customColCurve1, parent->customColCurve2, parent->customColCurve3,
dummy, dummy, parent->CAMBrightCurveJ, parent->CAMBrightCurveQ, parent->CAMMean, 5, skip, execsharp, dd, dj, 1);
}
} else {
// CIECAM is disbaled, we free up its image buffer to save some space

View File

@ -2612,7 +2612,7 @@ void RawImageSource::igv_interpolate(int winw, int winh)
#define FORC(cnt) for (c=0; c < cnt; c++)
#define FORC3 FORC(3)
void RawImageSource::ahd_demosaic(int winx, int winy, int winw, int winh)
void RawImageSource::ahd_demosaic()
{
int i, j, k, top, left, row, col, tr, tc, c, d, val, hm[2];
float (*pix)[4], (*rix)[3];

View File

@ -20,42 +20,29 @@
#include <cstddef>
#include <cmath>
#include "curves.h"
#include "labimage.h"
#include "color.h"
#include "mytime.h"
#include "improcfun.h"
#include "rawimagesource.h"
#include "array2D.h"
#include "rt_math.h"
#include "opthelper.h"
#ifdef _OPENMP
#include <omp.h>
#endif
#define CLIPI(a) ((a)>0 ?((a)<32768 ?(a):32768):0)
#define RANGEFN(i) ((1000.0f / (i + 1000.0f)))
#define CLIPC(a) ((a)>-32000?((a)<32000?(a):32000):-32000)
#define DIRWT(i1,j1,i,j) ( domker[(i1-i)/scale+halfwin][(j1-j)/scale+halfwin] * RANGEFN(fabsf((data_fine[i1][j1]-data_fine[i][j]))) )
namespace rtengine
{
static const int maxlevel = 6;
static const int maxlevelloc = 5;
static const float noise = 2000;
constexpr int maxlevel = 6;
constexpr int maxlevelloc = 5;
constexpr float noise = 2000;
//sequence of scales
static const int scales[6] = {1, 2, 4, 8, 16, 32};
static const int scalesloc[5] = {1, 2, 4, 8, 16};
constexpr int scales[maxlevel] = {1, 2, 4, 8, 16, 32};
constexpr int scalesloc[5] = {1, 2, 4, 8, 16};
extern const Settings* settings;
//sequence of scales
SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev)
SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer(float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, const double * mult, const double dirpyrThreshold, const double skinprot, float b_l, float t_l, float t_r, int scaleprev)
{
int lastlevel = maxlevel;
@ -98,10 +85,10 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer (float ** src, float ** dst
}
int level;
float multi[6] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
float scalefl[6];
float multi[maxlevel] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
float scalefl[maxlevel];
for (int lv = 0; lv < 6; lv++) {
for(int lv = 0; lv < maxlevel; lv++) {
scalefl[lv] = ((float) scales[lv]) / (float) scaleprev;
if (lv >= 1) {
@ -229,13 +216,13 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer (float ** src, float ** dst
// with the current implementation of idirpyr_eq_channel we can safely use the buffer from last level as buffer, saves some memory
float ** buffer = dirpyrlo[lastlevel - 1];
for (int level = lastlevel - 1; level > 0; level--) {
idirpyr_eq_channel (dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
for(int level = lastlevel - 1; level > 0; level--) {
idirpyr_eq_channel(dirpyrlo[level], dirpyrlo[level - 1], buffer, srcwidth, srcheight, level, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, b_l, t_l, t_r);
}
scale = scales[0];
idirpyr_eq_channel (dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, gamutlab, b_l, t_l, t_r, b_r, choice );
idirpyr_eq_channel(dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, tmpHue, tmpChr, skinprot, b_l, t_l, t_r);
if (skinprot != 0.f) {
for (int i = 0; i < srcheight; i++) {
@ -251,7 +238,6 @@ SSEFUNCTION void ImProcFunctions :: dirpyr_equalizer (float ** src, float ** dst
delete [] tmpHue;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#pragma omp parallel for
for (int i = 0; i < srcheight; i++)
@ -387,7 +373,7 @@ SSEFUNCTION void ImProcFunctions :: cbdl_local_temp (float ** src, float ** dst,
}
void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scaleprev)
void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, float b_l, float t_l, float t_r, int scaleprev)
{
int lastlevel = maxlevel;
@ -431,10 +417,10 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
int level;
float multi[6] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
float scalefl[6];
float multi[maxlevel] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
float scalefl[maxlevel];
for (int lv = 0; lv < 6; lv++) {
for(int lv = 0; lv < maxlevel; lv++) {
scalefl[lv] = ((float) scales[lv]) / (float) scaleprev;
// if(scalefl[lv] < 1.f) multi[lv] = 1.f; else multi[lv]=(float) mult[lv];
@ -499,8 +485,7 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
idirpyr_eq_channelcam (dirpyrlo[0], dst, buffer, srcwidth, srcheight, 0, multi, dirpyrThreshold, h_p, C_p, skinprot, b_l, t_l, t_r);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (execdir) {
if(execdir) {
#ifdef _OPENMP
#pragma omp parallel for schedule(dynamic,16)
#endif
@ -513,20 +498,17 @@ void ImProcFunctions :: dirpyr_equalizercam (CieImage *ncie, float ** src, float
dst[i][j] = src[i][j];
}
}
} else
} else {
for (int i = 0; i < srcheight; i++)
for (int j = 0; j < srcwidth; j++) {
dst[i][j] = CLIP ( buffer[i][j] ); // TODO: Really a clip necessary?
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
}
SSEFUNCTION void ImProcFunctions::dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale)
SSEFUNCTION void ImProcFunctions::dirpyr_channel(float ** data_fine, float ** data_coarse, int width, int height, int level, int scale)
{
//scale is spacing of directional averaging weights
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// scale is spacing of directional averaging weights
// calculate weights, compute directionally weighted average
if (level > 1) {
@ -843,7 +825,7 @@ void ImProcFunctions::idirpyr_eq_channel_loc (float ** data_coarse, float ** dat
*/
}
void ImProcFunctions::idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice)
void ImProcFunctions::idirpyr_eq_channel(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[maxlevel], const double dirpyrThreshold, float ** hue, float ** chrom, const double skinprot, float b_l, float t_l, float t_r)
{
const float skinprotneg = -skinprot;
const float factorHard = (1.f - skinprotneg / 100.f);
@ -856,7 +838,7 @@ void ImProcFunctions::idirpyr_eq_channel (float ** data_coarse, float ** data_fi
offs = -1.f;
}
float multbis[6];
float multbis[maxlevel];
multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult
@ -933,7 +915,7 @@ void ImProcFunctions::idirpyr_eq_channel (float ** data_coarse, float ** data_fi
}
void ImProcFunctions::idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r)
void ImProcFunctions::idirpyr_eq_channelcam(float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float mult[maxlevel], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r)
{
const float skinprotneg = -skinprot;
@ -947,7 +929,7 @@ void ImProcFunctions::idirpyr_eq_channelcam (float ** data_coarse, float ** data
offs = -1.f;
}
float multbis[6];
float multbis[maxlevel];
multbis[level] = mult[level]; //multbis to reduce artifacts for high values mult

View File

@ -80,7 +80,7 @@ void RawImageSource::processRawWhitepoint(float expos, float preser, array2D<flo
if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS) {
// Demosaic to allow calculation of luminosity.
if(ri->getSensorType() == ST_BAYER) {
fast_demosaic (0, 0, W, H);
fast_demosaic();
} else {
fast_xtrans_interpolate();
}

View File

@ -52,7 +52,7 @@ LUTf RawImageSource::initInvGrad()
#endif
//LUTf RawImageSource::invGrad = RawImageSource::initInvGrad();
SSEFUNCTION void RawImageSource::fast_demosaic(int winx, int winy, int winw, int winh)
SSEFUNCTION void RawImageSource::fast_demosaic()
{
double progress = 0.0;

View File

@ -534,7 +534,7 @@ void CLASS fuji_extend_blue (ushort *linebuf[_ltotal], int line_width)
fuji_extend_generic (linebuf, line_width, _B2, _B4);
}
void CLASS xtrans_decode_block (struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line)
void CLASS xtrans_decode_block (struct fuji_compressed_block* info, const struct fuji_compressed_params *params)
{
int r_even_pos = 0, r_odd_pos = 1;
int g_even_pos = 0, g_odd_pos = 1;
@ -699,8 +699,7 @@ void CLASS xtrans_decode_block (struct fuji_compressed_block* info, const struct
}
}
void CLASS fuji_bayer_decode_block (struct fuji_compressed_block *info, const struct fuji_compressed_params *params,
int cur_line)
void CLASS fuji_bayer_decode_block (struct fuji_compressed_block *info, const struct fuji_compressed_params *params)
{
int r_even_pos = 0, r_odd_pos = 1;
int g_even_pos = 0, g_odd_pos = 1;
@ -867,9 +866,9 @@ void CLASS fuji_decode_strip (const struct fuji_compressed_params* info_common,
for (cur_line = 0; cur_line < fuji_total_lines; cur_line++) {
if (fuji_raw_type == 16) {
xtrans_decode_block (&info, info_common, cur_line);
xtrans_decode_block (&info, info_common);
} else {
fuji_bayer_decode_block (&info, info_common, cur_line);
fuji_bayer_decode_block (&info, info_common);
}
// copy data from line buffers and advance

View File

@ -809,8 +809,8 @@ void rtengine::ICCStore::getGammaArray(const procparams::ColorManagementParams &
double ts = icm.slpos;
double slope = icm.slpos == 0 ? eps : icm.slpos;
int mode = 0, imax = 0;
Color::calcGamma(pwr, ts, mode, imax, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
int mode = 0;
Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope : return parameters for LCMS2
ga[4] = g_a[3] * ts;
//printf("g_a.gamma0=%f g_a.gamma1=%f g_a.gamma2=%f g_a.gamma3=%f g_a.gamma4=%f\n", g_a.gamma0,g_a.gamma1,g_a.gamma2,g_a.gamma3,g_a.gamma4);
ga[0] = icm.gampos;

View File

@ -86,7 +86,7 @@ Glib::ustring findIconAbsolutePath (const Glib::ustring& iconName)
return Glib::ustring();
}
void setPaths (const Options& options)
void setPaths ()
{
// TODO: Forcing the Dark theme, so reading the icon set files is useless for now...

View File

@ -26,7 +26,7 @@ namespace rtengine
{
Glib::ustring findIconAbsolutePath (const Glib::ustring& iconName);
void setPaths (const Options& options);
void setPaths ();
}

View File

@ -28,6 +28,7 @@
#include "coord2d.h"
#include "procparams.h"
#include "color.h"
#include "../rtgui/threadutils.h"
#define TR_NONE 0
#define TR_R90 1

View File

@ -24,7 +24,7 @@
#include "iptcpairs.h"
#include "imagesource.h"
#include "rt_math.h"
#pragma GCC diagnostic warning "-Wextra"
#define PRINT_HDR_PS_DETECTION 0
using namespace rtengine;
@ -857,8 +857,7 @@ bool FramesData::hasIPTC (unsigned int frame) const
tm FramesData::getDateTime (unsigned int frame) const
{
if (frames.empty() || frame >= frames.size() ) {
tm emptytm = {0, 0, 0, 0, 0, 0, 0, 0, 0};
return emptytm;
return {};
} else {
return frames.at(frame)->getDateTime ();
}
@ -1041,7 +1040,7 @@ failure:
}
FramesData::FramesData (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml, bool firstFrameOnly, bool loadAll) :
FramesData::FramesData (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml, bool firstFrameOnly) :
iptc(nullptr), dcrawFrameCount (0)
{
if (rml && (rml->exifBase >= 0 || rml->ciffBase >= 0)) {

View File

@ -95,7 +95,7 @@ private:
unsigned int dcrawFrameCount;
public:
FramesData (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml = nullptr, bool firstFrameOnly = false, bool loadAll = false);
FramesData (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml = nullptr, bool firstFrameOnly = false);
~FramesData ();
void setDCRawFrameCount (unsigned int frameCount);

View File

@ -66,7 +66,7 @@ public:
embProfile(nullptr), idata(nullptr), dirpyrdenoiseExpComp(INFINITY) {}
virtual ~ImageSource () {}
virtual int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false) = 0;
virtual int load (const Glib::ustring &fname) = 0;
virtual void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true) {};
virtual void demosaic (const RAWParams &raw) {};
virtual void retinex (ColorManagementParams cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D<float, 4> &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) {};
@ -85,7 +85,7 @@ public:
// use right after demosaicing image, add coarse transformation and put the result in the provided Imagefloat*
virtual void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hlp, const ColorManagementParams &cmp, const RAWParams &raw) = 0;
virtual void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hlp, const RAWParams &raw) = 0;
virtual eSensorType getSensorType () const = 0;
// true is ready to provide the AutoWB, i.e. when the image has been demosaiced for RawImageSource
virtual bool isWBProviderReady () = 0;
@ -110,7 +110,7 @@ public:
virtual FrameData* getImageData (unsigned int frameNum) = 0;
virtual ImageMatrices* getImageMatrices () = 0;
virtual bool isRAW () const = 0;
virtual DCPProfile* getDCP (const ColorManagementParams &cmp, ColorTemp &wb, DCPProfile::ApplyState &as)
virtual DCPProfile* getDCP (const ColorManagementParams &cmp, DCPProfile::ApplyState &as)
{
return nullptr;
};

View File

@ -460,7 +460,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
// Tells to the ImProcFunctions' tools what is the preview scale, which may lead to some simplifications
ipf.setScale (scale);
imgsrc->getImage (currWB, tr, orig_prev, pp, params.toneCurve, params.icm, params.raw);
imgsrc->getImage (currWB, tr, orig_prev, pp, params.toneCurve, params.raw);
denoiseInfoStore.valid = false;
//ColorTemp::CAT02 (orig_prev, &params) ;
// printf("orig_prevW=%d\n scale=%d",orig_prev->width, scale);
@ -570,7 +570,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
LUTu aehist;
int aehistcompr;
imgsrc->getAutoExpHistogram (aehist, aehistcompr);
ipf.getAutoExp (aehist, aehistcompr, imgsrc->getDefGain(), params.toneCurve.clip, params.toneCurve.expcomp,
ipf.getAutoExp (aehist, aehistcompr, params.toneCurve.clip, params.toneCurve.expcomp,
params.toneCurve.brightness, params.toneCurve.contrast, params.toneCurve.black, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh);
if (aeListener)
@ -588,7 +588,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
CurveFactory::complexCurve (params.toneCurve.expcomp, params.toneCurve.black / 65535.0,
params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh,
params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast,
params.toneCurve.curveMode, params.toneCurve.curve, params.toneCurve.curveMode2, params.toneCurve.curve2,
params.toneCurve.curve, params.toneCurve.curve2,
vhist16, hltonecurve, shtonecurve, tonecurve, histToneCurve, customToneCurve1, customToneCurve2, 1);
CurveFactory::RGBCurve (params.rgbCurves.rcurve, rCurve, 1);
@ -605,13 +605,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
{wprof[1][0], wprof[1][1], wprof[1][2]},
{wprof[2][0], wprof[2][1], wprof[2][2]}
};
TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params.icm.working);
double wip[3][3] = {
{wiprof[0][0], wiprof[0][1], wiprof[0][2]},
{wiprof[1][0], wiprof[1][1], wiprof[1][2]},
{wiprof[2][0], wiprof[2][1], wiprof[2][2]}
};
params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili);
params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, opautili);
CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16);
CurveFactory::curveToning (params.colorToning.cl2curve, cl2Toningcurve, scale == 1 ? 1 : 16);
}
@ -683,7 +677,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
double bbm = 33.;
DCPProfile::ApplyState as;
DCPProfile *dcpProf = imgsrc->getDCP (params.icm, currWB, as);
DCPProfile *dcpProf = imgsrc->getDCP (params.icm, as);
ipf.rgbProc (oprevi, oprevl, nullptr, hltonecurve, shtonecurve, tonecurve, shmap, params.toneCurve.saturation,
rCurve, gCurve, bCurve, colourToningSatLimit, colourToningSatLimitOpacity, ctColorCurve, ctOpacityCurve, opautili, clToningcurve, cl2Toningcurve, customToneCurve1, customToneCurve2, beforeToneCurveBW, afterToneCurveBW, rrm, ggm, bbm, bwAutoR, bwAutoG, bwAutoB, params.toneCurve.expcomp, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, dcpProf, as, histToneCurve);
@ -1131,7 +1125,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
}
int realspot = params.locallab.nbspot;
if (realspot >= maxspot) {
@ -3497,7 +3490,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
int kall = 0;
progress ("Wavelet...", 100 * readyphase / numofphases);
// ipf.ip_wavelet(nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, scale);
ipf.ip_wavelet (nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, scale);
ipf.ip_wavelet (nprevl, nprevl, kall, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, scale);
}
@ -3551,8 +3544,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
// end calculation adaptation scene luminosity
}
int begh = 0;
int endh = pH;
float d, dj, yb;
bool execsharp = false;
@ -3573,7 +3564,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
CAMBrightCurveJ.dirty = true;
CAMBrightCurveQ.dirty = true;
ipf.ciecam_02float (ncie, float (adap), begh, endh, pW, 2, nprevl, &params, customColCurve1, customColCurve2, customColCurve3, histLCAM, histCCAM, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, scale, execsharp, d, dj, yb, 1);
ipf.ciecam_02float (ncie, float (adap), pW, 2, nprevl, &params, customColCurve1, customColCurve2, customColCurve3, histLCAM, histCCAM, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, scale, execsharp, d, dj, yb, 1);
if ((params.colorappearance.autodegree || params.colorappearance.autodegreeout) && acListener && params.colorappearance.enabled) {
acListener->autoCamChanged (100.* (double)d, 100.* (double)dj);
@ -4022,7 +4013,7 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring & fname, bool
currWB = ColorTemp(); // = no white balance
}
imgsrc->getImage (currWB, tr, im, pp, ppar.toneCurve, ppar.icm, ppar.raw);
imgsrc->getImage (currWB, tr, im, pp, ppar.toneCurve, ppar.raw);
ImProcFunctions ipf (&ppar, true);
if (ipf.needsTransform()) {

View File

@ -28,7 +28,6 @@
#include "curves.h"
#include "mytime.h"
#include "iccstore.h"
#include "impulse_denoise.h"
#include "imagesource.h"
#include "rtthumbnail.h"
#include "utils.h"
@ -210,9 +209,9 @@ void ImProcFunctions::firstAnalysis (const Imagefloat* const original, const Pro
// Copyright (c) 2012 Jacques Desmis <jdesmis@gmail.com>
void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params,
void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, LabImage* lab, const ProcParams* params,
const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3,
LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, double &yb, int rtt)
LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, int rtt)
{
if (params->colorappearance.enabled) {
//int lastskip;
@ -258,7 +257,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
int width = lab->W, height = lab->H;
float minQ = 10000.f;
float maxQ = -1000.f;
float w_h = 0.f;
float a_w = 0.f;
float c_ = 0.f;
float f_l;
@ -278,9 +276,9 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
bool ciedata = params->colorappearance.datacie;
ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.green, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB
ColorTemp::temp2mulxyz (params->colorappearance.tempout, params->colorappearance.greenout, "Custom", Xwout, Zwout);
ColorTemp::temp2mulxyz (params->colorappearance.tempsc, params->colorappearance.greensc, "Custom", Xwsc, Zwsc);
ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB
ColorTemp::temp2mulxyz (params->colorappearance.tempout, "Custom", Xwout, Zwout);
ColorTemp::temp2mulxyz (params->colorappearance.tempsc, "Custom", Xwsc, Zwsc);
//viewing condition for surrsrc
if (params->colorappearance.surrsrc == "Average") {
@ -609,7 +607,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
#ifndef _DEBUG
#pragma omp parallel default(shared) firstprivate(lab,xw1,xw2,yw1,yw2,zw1,zw2,pilot,jli,chr,yb,la,yb2,la2,fl,nc,f,c, height,width,begh, endh,nc2,f2,c2, alg,algepd, gamu, highlight, rstprotection, pW, scale)
#pragma omp parallel default(shared) firstprivate(lab,xw1,xw2,yw1,yw2,zw1,zw2,pilot,jli,chr,yb,la,yb2,la2,fl,nc,f,c, height,width,nc2,f2,c2, alg,algepd, gamu, highlight, rstprotection, pW, scale)
#endif
{
//matrix for current working space
@ -655,15 +653,13 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
Q, M, s, aw, fl, wh,
x, y, z,
xw1, yw1, zw1,
yb, la,
f, c, nc, pilot, gamu, n, nbb, ncb, pfl, cz, d );
c, nc, gamu, n, nbb, ncb, pfl, cz, d );
Jpro = J;
Cpro = C;
hpro = h;
Qpro = Q;
Mpro = M;
spro = s;
w_h = wh + epsil;
a_w = aw;
c_ = c;
f_l = fl;
@ -1182,8 +1178,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
Ciecam02::jch2xyz_ciecam02 ( xx, yy, zz,
J, C, h,
xw2, yw2, zw2,
yb2, la2,
f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj);
c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj);
x = (float)xx * 655.35;
y = (float)yy * 655.35;
z = (float)zz * 655.35;
@ -1270,11 +1265,6 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
//if(params->dirpyrequalizer.enabled) if(execsharp) {
if (params->dirpyrequalizer.enabled) {
if (params->dirpyrequalizer.gamutlab /*&& execsharp*/) {
float b_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
float artifact = (float) settings->artifact_cbdl;
if (artifact > 6.f) {
@ -1288,14 +1278,14 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
float chrom = 50.f;
{
int hotbad = 0;
ImProcFunctions::badpixcam (ncie, artifact, 5, 2, b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL
ImProcFunctions::badpixcam (ncie, artifact, 5, 2, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL
}
}
}
if (params->colorappearance.badpixsl > 0) if (execsharp) {
int mode = params->colorappearance.badpixsl;
ImProcFunctions::badpixcam (ncie, 3.4, 5, mode, 0, 0, 0, 0, 0, 0, 1);//for bad pixels CIECAM
ImProcFunctions::badpixcam (ncie, 3.4, 5, mode, 0, 0, 1);//for bad pixels CIECAM
}
if (params->sharpenMicro.enabled)if (execsharp) {
@ -1316,10 +1306,8 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
if (rtt == 1) {
float b_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
int choice = 0; //not disabled in case of ! always 0
dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); //contrast by detail adapted to CIECAM
dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, b_l, t_l, t_r, scale); //contrast by detail adapted to CIECAM
}
}
@ -1349,14 +1337,14 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
|| (params->colorappearance.badpixsl > 0 && settings->autocielab)) {
if (params->epd.enabled && params->colorappearance.tonecie && algepd) {
ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale );
ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, width, height, minQ, maxQ, Iterates, scale );
}
//EPDToneMapCIE adapted to CIECAM
#ifndef _DEBUG
#pragma omp parallel default(shared) firstprivate(lab,xw2,yw2,zw2,chr,yb,la2,yb2, height,width,begh, endh, nc2,f2,c2, gamu, highlight,pW)
#pragma omp parallel default(shared) firstprivate(lab,xw2,yw2,zw2,chr,yb,la2,yb2, height,width, nc2,f2,c2, gamu, highlight,pW)
#endif
{
TMatrix wiprofa = ICCStore::getInstance()->workingSpaceInverseMatrix (params->icm.working);
@ -1451,8 +1439,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
Ciecam02::jch2xyz_ciecam02 ( xx, yy, zz,
ncie->J_p[i][j], ncie->C_p[i][j], ncie->h_p[i][j],
xw2, yw2, zw2,
yb2, la2,
f2, c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj);
c2, nc2, gamu, nj, nbbj, ncbj, flj, czj, dj, awj);
x = (float)xx * 655.35;
y = (float)yy * 655.35;
z = (float)zz * 655.35;
@ -1523,7 +1510,7 @@ void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh
// Copyright (c) 2012 Jacques Desmis <jdesmis@gmail.com>
void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params,
void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int pW, int pwb, LabImage* lab, const ProcParams* params,
const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2, const ColorAppearance & customColCurve3,
LUTu & histLCAM, LUTu & histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt)
{
@ -1565,9 +1552,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
|| (params->dirpyrequalizer.enabled && settings->autocielab) || (params->defringe.enabled && settings->autocielab) || (params->sharpenMicro.enabled && settings->autocielab)
|| (params->impulseDenoise.enabled && settings->autocielab) || (params->colorappearance.badpixsl > 0 && settings->autocielab));
ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.green, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB
ColorTemp::temp2mulxyz (params->colorappearance.tempout, params->colorappearance.greenout, "Custom", Xwout, Zwout);
ColorTemp::temp2mulxyz (params->colorappearance.tempsc, params->colorappearance.greensc, "Custom", Xwsc, Zwsc);
ColorTemp::temp2mulxyz (params->wb.temperature, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB
ColorTemp::temp2mulxyz (params->colorappearance.tempout, "Custom", Xwout, Zwout);
ColorTemp::temp2mulxyz (params->colorappearance.tempsc, "Custom", Xwsc, Zwsc);
//viewing condition for surrsrc
if (params->colorappearance.surrsrc == "Average") {
@ -1984,7 +1971,6 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
const float pow1n = pow_F ( 1.64f - pow_F ( 0.29f, nj ), 0.73f );
const float epsil = 0.0001f;
const float w_h = wh + epsil;
const float coefQ = 32767.f / wh;
const float a_w = aw;
const float c_ = c;
@ -2607,7 +2593,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
Ciecam02::jch2xyz_ciecam02float ( x, y, z,
LVF (Jbuffer[k]), LVF (Cbuffer[k]), LVF (hbuffer[k]),
F2V (xw2), F2V (yw2), F2V (zw2),
F2V (f2), F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz));
F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz));
STVF (xbuffer[k], x * c655d35);
STVF (ybuffer[k], y * c655d35);
STVF (zbuffer[k], z * c655d35);
@ -2709,10 +2695,6 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
//if(params->dirpyrequalizer.enabled) if(execsharp) {
if (params->dirpyrequalizer.enabled) {
if (params->dirpyrequalizer.gamutlab /*&& execsharp*/) { //remove artifacts by gaussian blur - skin control
float b_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
float artifact = (float) settings->artifact_cbdl;
if (artifact > 6.f) {
@ -2726,7 +2708,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
int hotbad = 0;
float chrom = 50.f;
lab->deleteLab();
ImProcFunctions::badpixcam (ncie, artifact, 5, 2, b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL
ImProcFunctions::badpixcam (ncie, artifact, 5, 2, params->dirpyrequalizer.skinprotect, chrom, hotbad); //enabled remove artifacts for cbDL
lab->reallocLab();
}
}
@ -2735,7 +2717,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
if (params->colorappearance.badpixsl > 0) if (execsharp) {
int mode = params->colorappearance.badpixsl;
lab->deleteLab();
ImProcFunctions::badpixcam (ncie, 3.0, 10, mode, 0, 0, 0, 0, 0, 0, 1);//for bad pixels CIECAM
ImProcFunctions::badpixcam (ncie, 3.0, 10, mode, 0, 0, 1);//for bad pixels CIECAM
lab->reallocLab();
}
@ -2765,11 +2747,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
if (rtt == 1) {
float b_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
int choice = 0; // I have not suppress this statement in case of !! always to 0
lab->deleteLab();
dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale); //contrast by detail adapted to CIECAM
dirpyr_equalizercam (ncie, ncie->sh_p, ncie->sh_p, ncie->W, ncie->H, ncie->h_p, ncie->C_p, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, true, b_l, t_l, t_r, scale); //contrast by detail adapted to CIECAM
lab->reallocLab();
}
@ -2812,7 +2792,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
if (epdEnabled && params->colorappearance.tonecie && algepd) {
lab->deleteLab();
ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, w_h, width, height, begh, endh, minQ, maxQ, Iterates, scale );
ImProcFunctions::EPDToneMapCIE (ncie, a_w, c_, width, height, minQ, maxQ, Iterates, scale );
lab->reallocLab();
}
@ -2951,7 +2931,7 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int
Ciecam02::jch2xyz_ciecam02float ( x, y, z,
LVF (Jbuffer[k]), LVF (Cbuffer[k]), LVF (hbuffer[k]),
F2V (xw2), F2V (yw2), F2V (zw2),
F2V (f2), F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz));
F2V (nc2), F2V (pow1n), F2V (nbbj), F2V (ncbj), F2V (flj), F2V (dj), F2V (awj), F2V (reccmcz));
x *= c655d35;
y *= c655d35;
z *= c655d35;
@ -4070,7 +4050,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
float lumbefore = 0.299f * r + 0.587f * g + 0.114f * b;
float ro, go, bo;
int mode = 0;
toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, preser, strProtect);
toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, strProtect);
float lumafter = 0.299f * ro + 0.587f * go + 0.114f * bo;
float preserv = 1.f;
@ -4221,21 +4201,21 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
if (beforeCurveMode == BlackWhiteParams::TC_MODE_STD_BW) { // Standard
for (int i = istart, ti = 0; i < tH; i++, ti++) {
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
const StandardToneCurvebw& userToneCurvebw = static_cast<const StandardToneCurvebw&> (customToneCurvebw1);
const StandardToneCurve& userToneCurvebw = static_cast<const StandardToneCurve&> (customToneCurvebw1);
userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]);
}
}
} else if (beforeCurveMode == BlackWhiteParams::TC_MODE_FILMLIKE_BW) { // Adobe like
for (int i = istart, ti = 0; i < tH; i++, ti++) {
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
const AdobeToneCurvebw& userToneCurvebw = static_cast<const AdobeToneCurvebw&> (customToneCurvebw1);
const AdobeToneCurve& userToneCurvebw = static_cast<const AdobeToneCurve&> (customToneCurvebw1);
userToneCurvebw.Apply (rtemp[ti * TS + tj], gtemp[ti * TS + tj], btemp[ti * TS + tj]);
}
}
} else if (beforeCurveMode == BlackWhiteParams::TC_MODE_SATANDVALBLENDING_BW) { // apply the curve on the saturation and value channels
for (int i = istart, ti = 0; i < tH; i++, ti++) {
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
const SatAndValueBlendingToneCurvebw& userToneCurvebw = static_cast<const SatAndValueBlendingToneCurvebw&> (customToneCurvebw1);
const SatAndValueBlendingToneCurve& userToneCurvebw = static_cast<const SatAndValueBlendingToneCurve&> (customToneCurvebw1);
rtemp[ti * TS + tj] = CLIP<float> (rtemp[ti * TS + tj]);
gtemp[ti * TS + tj] = CLIP<float> (gtemp[ti * TS + tj]);
btemp[ti * TS + tj] = CLIP<float> (btemp[ti * TS + tj]);
@ -4245,7 +4225,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
} else if (beforeCurveMode == BlackWhiteParams::TC_MODE_WEIGHTEDSTD_BW) { // apply the curve to the rgb channels, weighted
for (int i = istart, ti = 0; i < tH; i++, ti++) {
for (int j = jstart, tj = 0; j < tW; j++, tj++) {
const WeightedStdToneCurvebw& userToneCurvebw = static_cast<const WeightedStdToneCurvebw&> (customToneCurvebw1);
const WeightedStdToneCurve& userToneCurvebw = static_cast<const WeightedStdToneCurve&> (customToneCurvebw1);
rtemp[ti * TS + tj] = CLIP<float> (rtemp[ti * TS + tj]);
gtemp[ti * TS + tj] = CLIP<float> (gtemp[ti * TS + tj]);
btemp[ti * TS + tj] = CLIP<float> (btemp[ti * TS + tj]);
@ -4685,7 +4665,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
for (int i = 0; i < tH; i++) {
for (int j = 0; j < tW; j++) {
const StandardToneCurvebw& userToneCurve = static_cast<const StandardToneCurvebw&> (customToneCurvebw2);
const StandardToneCurve& userToneCurve = static_cast<const StandardToneCurve&> (customToneCurvebw2);
userToneCurve.Apply (tmpImage->r (i, j), tmpImage->g (i, j), tmpImage->b (i, j));
}
}
@ -4696,7 +4676,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
for (int i = 0; i < tH; i++) { //for ulterior usage if bw data modified
for (int j = 0; j < tW; j++) {
const WeightedStdToneCurvebw& userToneCurve = static_cast<const WeightedStdToneCurvebw&> (customToneCurvebw2);
const WeightedStdToneCurve& userToneCurve = static_cast<const WeightedStdToneCurve&> (customToneCurvebw2);
tmpImage->r (i, j) = CLIP<float> (tmpImage->r (i, j));
tmpImage->g (i, j) = CLIP<float> (tmpImage->g (i, j));
@ -4749,7 +4729,7 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
if (lumbefore < 65000.f && lumbefore > 500.f) { //reduct artifacts for highlights an extrem shadows
float ro, go, bo;
int mode = 1;
toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, preser, strProtect);
toningsmh (r, g, b, ro, go, bo, RedLow, GreenLow, BlueLow, RedMed, GreenMed, BlueMed, RedHigh, GreenHigh, BlueHigh, reducac, mode, strProtect);
float lumafter = 0.299f * ro + 0.587f * go + 0.114f * bo;
float preserv = 1.f;
@ -5091,7 +5071,7 @@ void ImProcFunctions::secondeg_begin (float reducac, float vend, float &aam, flo
* @param mode ?
* @param preser whether to preserve luminance (if 1) or not
**/
void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, int preser, float strProtect)
void ImProcFunctions::toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, float strProtect)
{
float bmu = mode == 1 ? 0.5f : 0.4f;
float RedL = 1.f + (RedLow - 1.f) * 0.4f;
@ -5568,8 +5548,6 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go
float opacity2 = (1.f - min<float> (s / satLimit, 1.f) * (1.f - satLimitOpacity));
//float ro, go, bo;
bool chr = true;
bool lum = false;
float lm = l;
float chromat, luma;
@ -5585,12 +5563,10 @@ void ImProcFunctions::labtoning (float r, float g, float b, float &ro, float &go
luma = 1.f - SQR (SQR ((lm * 65535.f) / (cl2Toningcurve[ (lm) * 65535.f]))); //apply C2=f(L) acts only on 'b'
}
int todo = 1;
if (algm == 1) {
Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo);
Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity, twoc, metchrom, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, wp, wip, ro, go, bo);
} else {
Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity2, twoc, metchrom, chr, lum, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, todo, wp, wip, ro, go, bo);
Color::interpolateRGBColor (realL, iplow, iphigh, algm, opacity2, twoc, metchrom, chromat, luma, r, g, b, xl, yl, zl, x2, y2, z2, wp, wip, ro, go, bo);
}
}
@ -5830,7 +5806,7 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
// only if user activate Lab adjustments
if (autili || butili || ccutili || cclutili || chutili || lhutili || hhutili || clcutili || utili || chromaticity) {
Color::LabGamutMunsell (lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip, multiThread);
Color::LabGamutMunsell (lold->L[i], lold->a[i], lold->b[i], W, /*corMunsell*/true, /*lumaMuns*/false, params->toneCurve.hrenabled, /*gamut*/true, wip);
}
#ifdef __SSE2__
@ -6389,8 +6365,8 @@ SSEFUNCTION void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBu
//#include "cubic.cc"
void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew)
{
//void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew)
//{
/* LUT<double> cmultiplier(181021);
@ -6467,7 +6443,7 @@ void ImProcFunctions::colorCurve (LabImage* lold, LabImage* lnew)
}
*/
//delete [] cmultiplier;
}
//}
void ImProcFunctions::impulsedenoise (LabImage* lab)
{
@ -6506,17 +6482,17 @@ void ImProcFunctions::defringecam (CieImage* ncie)
}
}
void ImProcFunctions::badpixcam (CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad)
void ImProcFunctions::badpixcam (CieImage* ncie, double rad, int thr, int mode, float skinprot, float chrom, int hotbad)
{
if (ncie->W >= 8 && ncie->H >= 8) {
Badpixelscam (ncie, ncie, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom, hotbad);
Badpixelscam (ncie, ncie, rad, thr, mode, skinprot, chrom, hotbad);
}
}
void ImProcFunctions::badpixlab (LabImage* lab, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom)
void ImProcFunctions::badpixlab (LabImage* lab, double rad, int thr, int mode, float skinprot, float chrom)
{
if (lab->W >= 8 && lab->H >= 8) {
BadpixelsLab (lab, lab, rad, thr, mode, b_l, t_l, t_r, b_r, skinprot, chrom);
BadpixelsLab (lab, lab, rad, thr, mode, skinprot, chrom);
}
}
@ -6525,9 +6501,7 @@ void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale)
if (params->dirpyrequalizer.enabled && lab->W >= 8 && lab->H >= 8) {
float b_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[0]) / 100.0f;
float t_l = static_cast<float> (params->dirpyrequalizer.hueskin.value[1]) / 100.0f;
float b_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[2]) / 100.0f;
float t_r = static_cast<float> (params->dirpyrequalizer.hueskin.value[3]) / 100.0f;
int choice = 0; //I have not disabled this statement in case of ! always 0
// if (params->dirpyrequalizer.algo=="FI") choice=0;
// else if(params->dirpyrequalizer.algo=="LA") choice=1;
float artifact = (float) settings->artifact_cbdl;
@ -6543,14 +6517,14 @@ void ImProcFunctions::dirpyrequalizer (LabImage* lab, int scale)
float chrom = 50.f;
if (params->dirpyrequalizer.gamutlab) {
ImProcFunctions::badpixlab (lab, artifact, 5, 3, b_l, t_l, t_r, b_r, params->dirpyrequalizer.skinprotect, chrom); //for artifacts
ImProcFunctions::badpixlab (lab, artifact, 5, 3, params->dirpyrequalizer.skinprotect, chrom); //for artifacts
}
//dirpyrLab_equalizer(lab, lab, params->dirpyrequalizer.mult);
dirpyr_equalizer (lab->L, lab->L, lab->W, lab->H, lab->a, lab->b, lab->a, lab->b, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, params->dirpyrequalizer.gamutlab, b_l, t_l, t_r, b_r, choice, scale);
dirpyr_equalizer (lab->L, lab->L, lab->W, lab->H, lab->a, lab->b, params->dirpyrequalizer.mult, params->dirpyrequalizer.threshold, params->dirpyrequalizer.skinprotect, b_l, t_l, t_r, scale);
}
}
void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates, int skip)
void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wid, int Hei, float minQ, float maxQ, unsigned int Iterates, int skip)
{
if (!params->epd.enabled) {
@ -6866,14 +6840,7 @@ void ImProcFunctions::EPDToneMap (LabImage *lab, unsigned int Iterates, int skip
}
void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double defgain, double clip,
double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh)
void ImProcFunctions::getAutoExp (const LUTu &histogram, int histcompr, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh)
{
float scale = 65536.0f;
@ -7190,7 +7157,7 @@ double ImProcFunctions::getAutoDistor (const Glib::ustring &fname, int thumb_si
return 0.0;
}
Thumbnail* raw = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, w_raw, h_raw, 1, 1.0, FALSE, 0);
Thumbnail* raw = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, w_raw, h_raw, 1, 1.0, FALSE);
if (!raw) {
delete thumb;

View File

@ -61,13 +61,9 @@ class ImProcFunctions
void calcVignettingParams (int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul);
enum TransformMode {
TRANSFORM_PREVIEW,
TRANSFORM_HIGH_QUALITY,
TRANSFORM_HIGH_QUALITY_FULLIMAGE
};
void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH);
void transformGeneral (TransformMode mode, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap);
void transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap);
void transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap);
void sharpenHaloCtrl (float** luminance, float** blurmap, float** base, int W, int H, const SharpeningParams &sharpenParam);
void sharpenHaloCtrl (LabImage* lab, float** blurmap, float** base, int W, int H, SharpeningParams &sharpenParam);
@ -231,7 +227,7 @@ public:
double expcomp, int hlcompr, int hlcomprthresh, DCPProfile *dcpProf, const DCPProfile::ApplyState &asIn, LUTu &histToneCurve);
void labtoning (float r, float g, float b, float &ro, float &go, float &bo, int algm, int metchrom, int twoc, float satLimit, float satLimitOpacity, const ColorGradientCurve & ctColorCurve, const OpacityCurve & ctOpacityCurve, LUTf & clToningcurve, LUTf & cl2Toningcurve, float iplow, float iphigh, double wp[3][3], double wip[3][3] );
void toning2col (float r, float g, float b, float &ro, float &go, float &bo, float iplow, float iphigh, float rl, float gl, float bl, float rh, float gh, float bh, float SatLow, float SatHigh, float balanS, float balanH, float reducac, int mode, int preser, float strProtect);
void toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, int preser, float strProtect);
void toningsmh (float r, float g, float b, float &ro, float &go, float &bo, float RedLow, float GreenLow, float BlueLow, float RedMed, float GreenMed, float BlueMed, float RedHigh, float GreenHigh, float BlueHigh, float reducac, int mode, float strProtect);
void toningsmh2 (float r, float g, float b, float &ro, float &go, float &bo, float low[3], float satLow, float med[3], float satMed, float high[3], float satHigh, float reducac, int mode, int preser);
void secondeg_begin (float reducac, float vend, float &aam, float &bbm);
void secondeg_end (float reducac, float vinf, float &aa, float &bb, float &cc);
@ -240,15 +236,15 @@ public:
void moyeqt (Imagefloat* working, float &moyS, float &eqty);
void luminanceCurve (LabImage* lold, LabImage* lnew, LUTf &curve);
void ciecam_02float (CieImage* ncie, float adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params,
void ciecam_02float (CieImage* ncie, float adap, int pW, int pwb, LabImage* lab, const ProcParams* params,
const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3,
LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, float &d, float &dj, float &yb, int rtt);
void ciecam_02 (CieImage* ncie, double adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params,
void ciecam_02 (CieImage* ncie, double adap, int pW, int pwb, LabImage* lab, const ProcParams* params,
const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3,
LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, double &yb, int rtt);
LUTu &histLCAM, LUTu &histCCAM, LUTf & CAMBrightCurveJ, LUTf & CAMBrightCurveQ, float &mean, int Iterates, int scale, bool execsharp, double &d, double &dj, int rtt);
void chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW, LabImage* lold, LabImage* lnew, LUTf &acurve, LUTf &bcurve, LUTf & satcurve, LUTf & satclcurve, LUTf &clcurve, LUTf &curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, bool clcutili, LUTu &histCCurve, LUTu &histLurve);
void vibrance (LabImage* lab);//Jacques' vibrance
void colorCurve (LabImage* lold, LabImage* lnew);
// void colorCurve (LabImage* lold, LabImage* lnew);
void sharpening (LabImage* lab, float** buffer, SharpeningParams &sharpenParam);
void sharpeningcam (CieImage* ncie, float** buffer);
void transform (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const FramesMetaData *metadata, int rawRotationDeg, bool fullImage);
@ -276,13 +272,13 @@ public:
void EPDToneMapResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params& cp, int W_L, int H_L, float max0, float min0);
float *CompressDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed);
void ContrastResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx);
float *ContrastDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast = nullptr);
float *CompressDR (float *Source, int W_L, int H_L, float Compression, float DetailBoost, float *Compressed);
void ContrastResid (float * WavCoeffs_L0, struct cont_params &cp, int W_L, int H_L, float max0, float min0);
float *ContrastDR (float *Source, int W_L, int H_L, float *Contrast = nullptr);
void EPDToneMap (LabImage *lab, unsigned int Iterates = 0, int skip = 1);
void EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float w_h, int Wid, int Hei, int begh, int endh, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1);
void EPDToneMaplocal (LabImage *lab, LabImage *tmp1, unsigned int Iterates, int skip);
void EPDToneMapCIE (CieImage *ncie, float a_w, float c_, int Wid, int Hei, float minQ, float maxQ, unsigned int Iterates = 0, int skip = 1);
// pyramid denoise
procparams::DirPyrDenoiseParams dnparams;
@ -322,25 +318,25 @@ public:
void Tile_calc (int tilesize, int overlap, int kall, int imwidth, int imheight, int &numtiles_W, int &numtiles_H, int &tilewidth, int &tileheight, int &tileWskip, int &tileHskip);
void ip_wavelet (LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip);
void ip_wavelet (LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, int skip);
void WaveletcontAllL (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L,
struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili);
struct cont_params &cp, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili);
void WaveletcontAllLfinal (wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL);
void WaveletcontAllAB (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, const WavOpacityCurveW & waOpacityCurveW,
struct cont_params &cp, const bool useChannelA);
void WaveletAandBAllAB (LabImage * lab, float **varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b,
struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhcurve, bool hhutili);
void WaveletAandBAllAB (wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b,
struct cont_params &cp, FlatCurve* hhcurve, bool hhutili);
void ContAllL (float **koeLi, float *maxkoeLi, bool lipschitz, int maxlvl, LabImage * lab, float **varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp,
int W_L, int H_L, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili);
int W_L, int H_L, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili);
void finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp,
int W_L, int H_L, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL);
void ContAllAB (LabImage * lab, int maxlvl, float **varhue, float **varchrom, float ** WavCoeffs_a, float * WavCoeffs_a0, int level, int dir, const WavOpacityCurveW & waOpacityCurveW, struct cont_params &cp,
int W_ab, int H_ab, const bool useChannelA);
void Evaluate2 (wavelet_decomposition &WaveletCoeffs_L,
const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3]);
void Eval2 (float ** WavCoeffs_L, int level, const struct cont_params& cp,
int W_L, int H_L, int skip_L, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float *madL);
float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN);
void Eval2 (float ** WavCoeffs_L, int level,
int W_L, int H_L, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN);
void Aver (float * HH_Coeffs, int datalen, float &averagePlus, float &averageNeg, float &max, float &min);
void Sigma (float * HH_Coeffs, int datalen, float averagePlus, float averageNeg, float &sigmaPlus, float &sigmaNeg);
@ -349,7 +345,7 @@ public:
void Median_Denoise ( float **src, float **dst, int width, int height, Median medianType, int iterations, int numThreads, float **buffer = nullptr);
void RGB_denoise (int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &chaut, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &nresi, float &highresi);
void RGB_denoise (int kall, Imagefloat * src, Imagefloat * dst, Imagefloat * calclum, float * ch_M, float *max_r, float *max_b, bool isRAW, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, const NoiseCurve & noiseLCurve, const NoiseCurve & noiseCCurve, float &nresi, float &highresi);
void RGB_denoise_infoGamCurve (const procparams::DirPyrDenoiseParams & dnparams, const bool isRAW, LUTf &gamcurve, float &gam, float &gamthresh, float &gamslope);
void RGB_denoise_info (Imagefloat * src, Imagefloat * provicalc, bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &minredaut, float & minblueaut, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread = false);
void RGBtile_denoise (float * fLblox, int hblproc, float noisevar_Ldetail, float * nbrwt, float * blurbuffer ); //for DCT
@ -357,8 +353,8 @@ public:
bool WaveletDenoiseAllL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge, int denoiseNestedLevels);
bool WaveletDenoiseAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float *variC, int local, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb, int denoiseNestedLevels);
void WaveletDenoiseAll_info (int levwav, wavelet_decomposition &WaveletCoeffs_a,
wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float & minblueaut, int schoice, bool autoch, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc,
float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread);
wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float & minblueaut, int schoice, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc,
float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb);
bool WaveletDenoiseAll_BiShrinkL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3]);
bool WaveletDenoiseAll_BiShrinkAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float noisevar_ab,
@ -366,10 +362,9 @@ public:
void ShrinkAllL (wavelet_decomposition &WaveletCoeffs_L, float **buffer, int level, int dir, float *noisevarlum, float * madL, float * vari, int edge);
void ShrinkAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float **buffer, int level, int dir,
float *noisevarchrom, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb, float * madL, float * variC, int local, float * madaab = nullptr, bool madCalculated = false);
void ShrinkAll_info (float ** WavCoeffs_a, float ** WavCoeffs_b, int level,
int W_ab, int H_ab, int skip_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, bool autoch, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc,
float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread);
void ShrinkAll_info (float ** WavCoeffs_a, float ** WavCoeffs_b,
int W_ab, int H_ab, float **noisevarlum, float **noisevarchrom, float **noisevarhue, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float &minblueaut, int schoice, int lvl, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc,
float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb);
void Noise_residualAB (wavelet_decomposition &WaveletCoeffs_ab, float &chresid, float &chmaxresid, bool denoiseMethodRgb);
void calcautodn_info (float &chaut, float &delta, int Nb, int levaut, float maxmax, float lumema, float chromina, int mode, int lissage, float redyel, float skinc, float nsknc);
float MadMax (float * DataList, int &max, int datalen);
@ -377,30 +372,30 @@ public:
float MadRgb (float * DataList, const int datalen);
// pyramid wavelet
void dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, float ** dest_a, float ** dest_b, const double * mult, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet
void cbdl_local_temp (float ** src, float ** dst, float ** loctemp, int srcwidth, int srcheight, const float * mult, float kchro, const double dirpyrThreshold, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);
void dirpyr_equalizercam (CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice, int scale);//Emil's directional pyramid wavelet
void dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale);
void idirpyr_eq_channel_loc (float ** data_coarse, float ** data_fine, float ** loctemp, float ** buffer, int width, int height, int level, float multi[5], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice);
void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, const bool gamutlab, float b_l, float t_l, float t_r, float b_r, int choice);
void dirpyr_equalizer (float ** src, float ** dst, int srcwidth, int srcheight, float ** l_a, float ** l_b, const double * mult, const double dirpyrThreshold, const double skinprot, float b_l, float t_l, float t_r, int scale);//Emil's directional pyramid wavelet
void dirpyr_equalizercam (CieImage* ncie, float ** src, float ** dst, int srcwidth, int srcheight, float ** h_p, float ** C_p, const double * mult, const double dirpyrThreshold, const double skinprot, bool execdir, float b_l, float t_l, float t_r, int scale);//Emil's directional pyramid wavelet
void dirpyr_channel (float ** data_fine, float ** data_coarse, int width, int height, int level, int scale);
void idirpyr_eq_channel (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r);
void idirpyr_eq_channelcam (float ** data_coarse, float ** data_fine, float ** buffer, int width, int height, int level, float multi[6], const double dirpyrThreshold, float ** l_a_h, float ** l_b_c, const double skinprot, float b_l, float t_l, float t_r);
void defringe (LabImage* lab);
void defringecam (CieImage* ncie);
void badpixcam (CieImage* ncie, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad);
void badpixlab (LabImage* lab, double rad, int thr, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom);
void badpixcam (CieImage* ncie, double rad, int thr, int mode, float skinprot, float chrom, int hotbad);
void badpixlab (LabImage* lab, double rad, int thr, int mode, float skinprot, float chrom);
void PF_correct_RT (LabImage * src, LabImage * dst, double radius, int thresh);
void PF_correct_RTcam (CieImage * src, CieImage * dst, double radius, int thresh);
void Badpixelscam (CieImage * src, CieImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom, int hotbad);
void BadpixelsLab (LabImage * src, LabImage * dst, double radius, int thresh, int mode, float b_l, float t_l, float t_r, float b_r, float skinprot, float chrom);
void Badpixelscam (CieImage * src, CieImage * dst, double radius, int thresh, int mode, float skinprot, float chrom, int hotbad);
void BadpixelsLab (LabImage * src, LabImage * dst, double radius, int thresh, int mode, float skinprot, float chrom);
Image8* lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm);
Image16* lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool bw, GammaValues *ga = nullptr);
Image16* lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, GammaValues *ga = nullptr);
// CieImage *ciec;
bool transCoord (int W, int H, int x, int y, int w, int h, int& xv, int& yv, int& wv, int& hv, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr);
bool transCoord (int W, int H, const std::vector<Coord2D> &src, std::vector<Coord2D> &red, std::vector<Coord2D> &green, std::vector<Coord2D> &blue, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr);
static void getAutoExp (const LUTu & histogram, int histcompr, double defgain, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh);
static void getAutoExp (const LUTu & histogram, int histcompr, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh);
static double getAutoDistor (const Glib::ustring& fname, int thumb_size);
double getTransformAutoFill (int oW, int oH, const LensCorrection *pLCPMap = nullptr);
void rgb2lab (const Imagefloat &src, LabImage &dst, const Glib::ustring &workingSpace);

View File

@ -262,7 +262,7 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch,
* If a custom gamma profile can be created, divide by 327.68, convert to xyz and apply the custom gamma transform
* otherwise divide by 327.68, convert to xyz and apply the sRGB transform, before converting with gamma2curve
*/
Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool bw, GammaValues *ga)
Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, GammaValues *ga)
{
if (cx < 0) {

View File

@ -315,7 +315,7 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed,
pLCPMap.reset(
new LCPMapper (pLCPProf, focalLen, focalLen35mm,
focusDist, fNumber, false,
params->lensProf.useDist,
false,
oW, oH, params->coarse, rawRotationDeg
)
);
@ -325,18 +325,31 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed,
if (! (needsCA() || needsDistortion() || needsRotation() || needsPerspective() || needsLCP() || needsLensfun()) && (needsVignetting() || needsPCVignetting() || needsGradient())) {
transformLuminanceOnly (original, transformed, cx, cy, oW, oH, fW, fH);
} else {
TransformMode mode;
bool highQuality;
std::unique_ptr<Imagefloat> tmpimg;
if (!needsCA() && scale != 1) {
mode = TRANSFORM_PREVIEW;
} else if (!fullImage) {
mode = TRANSFORM_HIGH_QUALITY;
highQuality = false;
} else {
mode = TRANSFORM_HIGH_QUALITY_FULLIMAGE;
highQuality = true;
// agriggio: CA correction via the lens profile has to be
// performed before all the other transformations (except for the
// coarse rotation/flipping). In order to not change the code too
// much, I simply introduced a new mode
// TRANSFORM_HIGH_QUALITY_CA, which applies *only*
// profile-based CA correction. So, the correction in this case
// occurs in two steps, using an intermediate temporary
// image. There's room for optimization of course...
if (pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable()) {
tmpimg.reset(new Imagefloat(original->getWidth(), original->getHeight()));
transformLCPCAOnly(original, tmpimg.get(), cx, cy, pLCPMap.get());
original = tmpimg.get();
}
}
transformGeneral(mode, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get());
transformGeneral(highQuality, original, transformed, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get());
}
}
// helper function
void ImProcFunctions::calcVignettingParams (int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul)
{
@ -723,8 +736,17 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat*
}
void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap)
void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap)
{
// set up stuff, depending on the mode we are
bool enableLCPDist = pLCPMap && params->lensProf.useDist;
bool enableCA = highQuality && needsCA();
bool enableGradient = needsGradient();
bool enablePCVignetting = needsPCVignetting();
bool enableVignetting = needsVignetting();
bool enablePerspective = needsPerspective();
bool enableDistortion = needsDistortion();
double w2 = (double) oW / 2.0 - 0.5;
double h2 = (double) oH / 2.0 - 0.5;
@ -733,13 +755,13 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
struct grad_params gp;
if (needsGradient()) {
if (enableGradient) {
calcGradientParams (oW, oH, params->gradient, gp);
}
struct pcv_params pcv;
if (needsPCVignetting()) {
if (enablePCVignetting) {
calcPCVignetteParams (fW, fH, oW, oH, params->pcvignette, params->crop, pcv);
}
@ -755,12 +777,11 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
// auxiliary variables for c/a correction
double chDist[3];
chDist[0] = params->cacorrection.red;
chDist[0] = enableCA ? params->cacorrection.red : 0.0;
chDist[1] = 0.0;
chDist[2] = params->cacorrection.blue;
chDist[2] = enableCA ? params->cacorrection.blue : 0.0;
// auxiliary variables for distortion correction
bool needsDist = needsDistortion(); // for performance
double distAmount = params->distortion.amount;
// auxiliary variables for rotation
@ -783,38 +804,13 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
double ascale = params->commonTrans.autofill ? getTransformAutoFill (oW, oH, pLCPMap) : 1.0;
// smaller crop images are a problem, so only when processing fully
bool enableLCPCA = false;
bool enableLCPDist = false;
bool enableCA = false;
switch (mode) {
case ImProcFunctions::TRANSFORM_HIGH_QUALITY_FULLIMAGE: {
enableLCPCA = pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable();
}
//no break on purpose
case ImProcFunctions::TRANSFORM_HIGH_QUALITY: {
enableLCPDist = pLCPMap && params->lensProf.useDist;
enableCA = enableLCPCA || needsCA();
}
//no break on purpose
default:
case ImProcFunctions::TRANSFORM_PREVIEW: {
enableLCPDist = pLCPMap && params->lensProf.useDist;
break;
}
}
if (enableLCPCA) {
enableLCPDist = false;
}
if (!enableCA) {
chDist[0] = 0.0;
}
#if defined( __GNUC__ ) && __GNUC__ >= 7// silence warning
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
#if defined( __GNUC__ ) && __GNUC__ >= 7
#pragma GCC diagnostic pop
#endif
// main cycle
bool darkening = (params->vignetting.amount <= 0.0);
#pragma omp parallel for if (multiThread)
@ -835,12 +831,12 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
double vig_x_d = 0., vig_y_d = 0.;
if (needsVignetting()) {
if (enableVignetting) {
vig_x_d = ascale * (x + cx - vig_w2); // centering x coord & scale
vig_y_d = ascale * (y + cy - vig_h2); // centering y coord & scale
}
if (needsPerspective()) {
if (enablePerspective) {
// horizontal perspective transformation
y_d *= maxRadius / (maxRadius + x_d * hptanpt);
x_d *= maxRadius * hpcospt / (maxRadius + x_d * hptanpt);
@ -857,14 +853,14 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
// distortion correction
double s = 1;
if (needsDist) {
if (enableDistortion) {
double r = sqrt (Dxc * Dxc + Dyc * Dyc) / maxRadius; // sqrt is slow
s = 1.0 - distAmount + distAmount * r ;
}
double r2 = 0.;
if (needsVignetting()) {
if (enableVignetting) {
double vig_Dx = vig_x_d * cost - vig_y_d * sint;
double vig_Dy = vig_x_d * sint + vig_y_d * cost;
r2 = sqrt (vig_Dx * vig_Dx + vig_Dy * vig_Dy);
@ -878,11 +874,6 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
Dx += w2;
Dy += h2;
// LCP CA
if (enableLCPCA) {
pLCPMap->correctCA (Dx, Dy, c);
}
// Extract integer and fractions of source screen coordinates
int xc = (int)Dx;
Dx -= (double)xc;
@ -897,7 +888,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
// multiplier for vignetting correction
double vignmul = 1.0;
if (needsVignetting()) {
if (enableVignetting) {
if (darkening) {
vignmul /= std::max (v + mul * tanh (b * (maxRadius - s * r2) / maxRadius), 0.001);
} else {
@ -905,11 +896,11 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
}
}
if (needsGradient()) {
if (enableGradient) {
vignmul *= calcGradientFactor (gp, cx + x, cy + y);
}
if (needsPCVignetting()) {
if (enablePCVignetting) {
vignmul *= calcPCVignetteFactor (pcv, cx + x, cy + y);
}
@ -917,7 +908,7 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
// all interpolation pixels inside image
if (enableCA) {
interpolateTransformChannelsCubic (chOrig[c], xc - 1, yc - 1, Dx, Dy, & (chTrans[c][y][x]), vignmul);
} else if (mode == ImProcFunctions::TRANSFORM_PREVIEW) {
} else if (!highQuality) {
transformed->r (y, x) = vignmul * (original->r (yc, xc) * (1.0 - Dx) * (1.0 - Dy) + original->r (yc, xc + 1) * Dx * (1.0 - Dy) + original->r (yc + 1, xc) * (1.0 - Dx) * Dy + original->r (yc + 1, xc + 1) * Dx * Dy);
transformed->g (y, x) = vignmul * (original->g (yc, xc) * (1.0 - Dx) * (1.0 - Dy) + original->g (yc, xc + 1) * Dx * (1.0 - Dy) + original->g (yc + 1, xc) * (1.0 - Dx) * Dy + original->g (yc + 1, xc + 1) * Dx * Dy);
transformed->b (y, x) = vignmul * (original->b (yc, xc) * (1.0 - Dx) * (1.0 - Dy) + original->b (yc, xc + 1) * Dx * (1.0 - Dy) + original->b (yc + 1, xc) * (1.0 - Dx) * Dy + original->b (yc + 1, xc + 1) * Dx * Dy);
@ -955,6 +946,62 @@ void ImProcFunctions::transformGeneral(ImProcFunctions::TransformMode mode, Imag
}
void ImProcFunctions::transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap)
{
assert(pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable());
float** chOrig[3];
chOrig[0] = original->r.ptrs;
chOrig[1] = original->g.ptrs;
chOrig[2] = original->b.ptrs;
float** chTrans[3];
chTrans[0] = transformed->r.ptrs;
chTrans[1] = transformed->g.ptrs;
chTrans[2] = transformed->b.ptrs;
#pragma omp parallel for if (multiThread)
for (int y = 0; y < transformed->getHeight(); y++) {
for (int x = 0; x < transformed->getWidth(); x++) {
for (int c = 0; c < 3; c++) {
double Dx = x;
double Dy = y;
pLCPMap->correctCA(Dx, Dy, cx, cy, c);
// Extract integer and fractions of coordinates
int xc = (int)Dx;
Dx -= (double)xc;
int yc = (int)Dy;
Dy -= (double)yc;
// Convert only valid pixels
if (yc >= 0 && yc < original->getHeight() && xc >= 0 && xc < original->getWidth()) {
// multiplier for vignetting correction
if (yc > 0 && yc < original->getHeight() - 2 && xc > 0 && xc < original->getWidth() - 2) {
// all interpolation pixels inside image
interpolateTransformChannelsCubic (chOrig[c], xc - 1, yc - 1, Dx, Dy, & (chTrans[c][y][x]), 1.0);
} else {
// edge pixels
int y1 = LIM (yc, 0, original->getHeight() - 1);
int y2 = LIM (yc + 1, 0, original->getHeight() - 1);
int x1 = LIM (xc, 0, original->getWidth() - 1);
int x2 = LIM (xc + 1, 0, original->getWidth() - 1);
chTrans[c][y][x] = (chOrig[c][y1][x1] * (1.0 - Dx) * (1.0 - Dy) + chOrig[c][y1][x2] * Dx * (1.0 - Dy) + chOrig[c][y2][x1] * (1.0 - Dx) * Dy + chOrig[c][y2][x2] * Dx * Dy);
}
} else {
// not valid (source pixel x,y not inside source image, etc.)
chTrans[c][y][x] = 0;
}
}
}
}
}
double ImProcFunctions::getTransformAutoFill (int oW, int oH, const LensCorrection *pLCPMap)
{
if (!needsCA() && !needsDistortion() && !needsRotation() && !needsPerspective() && (!params->lensProf.useDist || pLCPMap == nullptr)) {

View File

@ -140,8 +140,7 @@ struct cont_params {
int wavNestedLevels = 1;
SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, bool wavcontlutili, int skip)
SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int kall, const procparams::WaveletParams & waparams, const WavCurve & wavCLVCcurve, const WavOpacityCurveRG & waOpacityCurveRG, const WavOpacityCurveBY & waOpacityCurveBY, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, LUTf &wavclCurve, int skip)
{
#ifdef _DEBUG
@ -883,7 +882,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, in
}
}
int ind = 0;
bool ref = false;
if ((cp.lev0s > 0.f || cp.lev1s > 0.f || cp.lev2s > 0.f || cp.lev3s > 0.f) && cp.noiseena) {
@ -898,8 +896,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, in
}
}
if (cp.val > 0 || ref || contr) { //edge
Evaluate2 (*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL);
if(cp.val > 0 || ref || contr) {//edge
Evaluate2(*Ldecomp, mean, meanN, sigma, sigmaN, MaxP, MaxN);
}
//init for edge and denoise
@ -921,7 +919,6 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, in
WaveletDenoiseAllL (*Ldecomp, noisevarlum, madL, vari, edge, 1);
}
ind = 1;
//Flat curve for Contrast=f(H) in levels
FlatCurve* ChCurve = new FlatCurve(params->wavelet.Chcurve); //curve C=f(H)
bool Chutili = false;
@ -936,10 +933,10 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, in
}
WaveletcontAllL (labco, varhue, varchro, *Ldecomp, cp, skip, mean, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, waOpacityCurveWL, ChCurve, Chutili);
WaveletcontAllL(labco, varhue, varchro, *Ldecomp, cp, skip, mean, sigma, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili);
if (cp.val > 0 || ref || contr || cp.diagcurv) { //edge
Evaluate2 (*Ldecomp, cp, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL);
if(cp.val > 0 || ref || contr || cp.diagcurv) {//edge
Evaluate2(*Ldecomp, mean, meanN, sigma, sigmaN, MaxP, MaxN);
}
WaveletcontAllLfinal (*Ldecomp, cp, mean, sigma, MaxP, waOpacityCurveWL);
@ -1022,10 +1019,10 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, in
wavelet_decomposition* adecomp = new wavelet_decomposition (labco->data + datalen, labco->W, labco->H, levwavab, 1, skip, max (1, wavNestedLevels), DaubLen );
wavelet_decomposition* bdecomp = new wavelet_decomposition (labco->data + 2 * datalen, labco->W, labco->H, levwavab, 1, skip, max (1, wavNestedLevels), DaubLen );
if (!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) {
WaveletcontAllAB (labco, varhue, varchro, *adecomp, waOpacityCurveW, cp, true);
WaveletcontAllAB (labco, varhue, varchro, *bdecomp, waOpacityCurveW, cp, false);
WaveletAandBAllAB (labco, varhue, varchro, *adecomp, *bdecomp, cp, waOpacityCurveW, hhCurve, hhutili );
if(!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) {
WaveletcontAllAB(labco, varhue, varchro, *adecomp, waOpacityCurveW, cp, true);
WaveletcontAllAB(labco, varhue, varchro, *bdecomp, waOpacityCurveW, cp, false);
WaveletAandBAllAB(*adecomp, *bdecomp, cp, hhCurve, hhutili );
adecomp->reconstruct (labco->data + datalen, cp.strength);
bdecomp->reconstruct (labco->data + 2 * datalen, cp.strength);
@ -1365,8 +1362,8 @@ void ImProcFunctions::Sigma ( float * RESTRICT DataList, int datalen, float ave
}
void ImProcFunctions::Evaluate2 (wavelet_decomposition &WaveletCoeffs_L,
const struct cont_params& cp, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float madL[8][3])
void ImProcFunctions::Evaluate2(wavelet_decomposition &WaveletCoeffs_L,
float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN)
{
//StopWatch Stop1("Evaluate2");
int maxlvl = WaveletCoeffs_L.maxlevel();
@ -1376,16 +1373,14 @@ void ImProcFunctions::Evaluate2 (wavelet_decomposition &WaveletCoeffs_L,
int Wlvl_L = WaveletCoeffs_L.level_W (lvl);
int Hlvl_L = WaveletCoeffs_L.level_H (lvl);
int skip_L = WaveletCoeffs_L.level_stride (lvl);
float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs(lvl);
float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs (lvl);
Eval2 (WavCoeffs_L, lvl, cp, Wlvl_L, Hlvl_L, skip_L, ind, mean, meanN, sigma, sigmaN, MaxP, MaxN, madL[lvl]);
Eval2 (WavCoeffs_L, lvl, Wlvl_L, Hlvl_L, mean, meanN, sigma, sigmaN, MaxP, MaxN);
}
}
void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont_params& cp,
int W_L, int H_L, int skip_L, int ind, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, float *madL)
void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level,
int W_L, int H_L, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN)
{
float avLP[4], avLN[4];
@ -1429,7 +1424,7 @@ void ImProcFunctions::Eval2 (float ** WavCoeffs_L, int level, const struct cont
MaxN[level] = maxLN;
}
float *ImProcFunctions::ContrastDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Contrast)
float *ImProcFunctions::ContrastDR(float *Source, int W_L, int H_L, float *Contrast)
{
int n = W_L * H_L;
@ -1449,7 +1444,7 @@ float *ImProcFunctions::ContrastDR (float *Source, int skip, struct cont_params
return Contrast;
}
SSEFUNCTION float *ImProcFunctions::CompressDR (float *Source, int skip, struct cont_params &cp, int W_L, int H_L, float Compression, float DetailBoost, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx, float *Compressed)
SSEFUNCTION float *ImProcFunctions::CompressDR(float *Source, int W_L, int H_L, float Compression, float DetailBoost, float *Compressed)
{
const float eps = 0.000001f;
@ -1485,7 +1480,7 @@ SSEFUNCTION float *ImProcFunctions::CompressDR (float *Source, int skip, struct
#endif
float *ucr = ContrastDR (Source, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx);
float *ucr = ContrastDR(Source, W_L, H_L);
if (Compressed == nullptr) {
Compressed = ucr;
@ -1563,7 +1558,7 @@ SSEFUNCTION float *ImProcFunctions::CompressDR (float *Source, int skip, struct
}
void ImProcFunctions::ContrastResid (float * WavCoeffs_L0, unsigned int Iterates, int skip, struct cont_params &cp, int W_L, int H_L, float max0, float min0, float ave, float ah, float bh, float al, float bl, float factorx)
void ImProcFunctions::ContrastResid(float * WavCoeffs_L0, struct cont_params &cp, int W_L, int H_L, float max0, float min0)
{
float stren = cp.tmstrength;
float gamm = params->wavelet.gamma;
@ -1593,7 +1588,7 @@ void ImProcFunctions::ContrastResid (float * WavCoeffs_L0, unsigned int Iterate
}
CompressDR (WavCoeffs_L0, skip, cp, W_L, H_L, Compression, DetailBoost, max0, min0, ave, ah, bh, al, bl, factorx, WavCoeffs_L0);
CompressDR(WavCoeffs_L0, W_L, H_L, Compression, DetailBoost, WavCoeffs_L0);
#ifdef _RT_NESTED_OPENMP
@ -1678,8 +1673,8 @@ void ImProcFunctions::WaveletcontAllLfinal (wavelet_decomposition &WaveletCoeffs
}
void ImProcFunctions::WaveletcontAllL (LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L,
struct cont_params &cp, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, const WavOpacityCurveWL & waOpacityCurveWL, FlatCurve* ChCurve, bool Chutili)
void ImProcFunctions::WaveletcontAllL(LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_L,
struct cont_params &cp, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili)
{
int maxlvl = WaveletCoeffs_L.maxlevel();
int W_L = WaveletCoeffs_L.level_W (0);
@ -1824,7 +1819,7 @@ void ImProcFunctions::WaveletcontAllL (LabImage * labco, float ** varhue, float
#ifdef _RT_NESTED_OPENMP
#pragma omp single
#endif
ContrastResid (WavCoeffs_L0, 5, skip, cp, W_L, H_L, maxp, minp, ave, ah, bh, al, bl, factorx );
ContrastResid(WavCoeffs_L0, cp, W_L, H_L, maxp, minp);
}
#ifdef _RT_NESTED_OPENMP
@ -2032,7 +2027,7 @@ void ImProcFunctions::WaveletcontAllL (LabImage * labco, float ** varhue, float
float ** WavCoeffs_L = WaveletCoeffs_L.level_coeffs (lvl);
ContAllL (koeLi, maxkoeLi, true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, meanN, sigma, sigmaN, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili);
ContAllL (koeLi, maxkoeLi, true, maxlvl, labco, varhue, varchrom, WavCoeffs_L, WavCoeffs_L0, lvl, dir, cp, Wlvl_L, Hlvl_L, skip, mean, sigma, MaxP, MaxN, wavCLVCcurve, waOpacityCurveW, ChCurve, Chutili);
}
@ -2045,8 +2040,8 @@ void ImProcFunctions::WaveletcontAllL (LabImage * labco, float ** varhue, float
}
}
void ImProcFunctions::WaveletAandBAllAB (LabImage * labco, float ** varhue, float **varchrom, wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b,
struct cont_params &cp, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* hhCurve, bool hhutili)
void ImProcFunctions::WaveletAandBAllAB(wavelet_decomposition &WaveletCoeffs_a, wavelet_decomposition &WaveletCoeffs_b,
struct cont_params &cp, FlatCurve* hhCurve, bool hhutili)
{
// StopWatch Stop1("WaveletAandBAllAB");
if (hhutili && cp.resena) { // H=f(H)
@ -2573,7 +2568,7 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0,
}
void ImProcFunctions::ContAllL (float *koeLi[12], float *maxkoeLi, bool lipschitz, int maxlvl, LabImage * labco, float ** varhue, float **varchrom, float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp,
int W_L, int H_L, int skip, float *mean, float *meanN, float *sigma, float *sigmaN, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili)
int W_L, int H_L, int skip, float *mean, float *sigma, float *MaxP, float *MaxN, const WavCurve & wavCLVCcurve, const WavOpacityCurveW & waOpacityCurveW, FlatCurve* ChCurve, bool Chutili)
{
assert (level >= 0);
assert (maxlvl > level);

View File

@ -1,9 +1,31 @@
/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2017 Gabor Horvath <hgabor@rawtherapee.com>
*
* 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 <cstring>
#include <memory>
#include "labimage.h"
#include <memory.h>
namespace rtengine
{
LabImage::LabImage (int w, int h) : fromImage(false), W(w), H(h)
LabImage::LabImage (int w, int h) : W(w), H(h)
{
allocLab(w, h);
}
@ -42,4 +64,55 @@ void LabImage::getPipetteData (float &v1, float &v2, float &v3, int posX, int po
v3 = n ? accumulator_b / float(n) : 0.f;
}
void LabImage::allocLab(int w, int h)
{
L = new float*[h];
a = new float*[h];
b = new float*[h];
data = new float [w * h * 3];
float * index = data;
for (int i = 0; i < h; i++) {
L[i] = index + i * w;
}
index += w * h;
for (int i = 0; i < h; i++) {
a[i] = index + i * w;
}
index += w * h;
for (int i = 0; i < h; i++) {
b[i] = index + i * w;
}
}
void LabImage::deleteLab()
{
delete [] L;
delete [] a;
delete [] b;
delete [] data;
}
void LabImage::reallocLab()
{
allocLab(W, H);
};
void LabImage::clear(bool multiThread) {
#ifdef _OPENMP
#pragma omp parallel for if(multiThread)
#endif
for(int i = 0; i < H; ++i) {
for(int j = 0; j < W; ++j) {
L[i][j] = a[i][j] = b[i][j] = 0.f;
}
}
}
}

View File

@ -25,32 +25,8 @@ namespace rtengine
class LabImage
{
private:
bool fromImage;
void allocLab(int w, int h)
{
L = new float*[H];
a = new float*[H];
b = new float*[H];
void allocLab(int w, int h);
data = new float [W * H * 3];
float * index = data;
for (int i = 0; i < H; i++) {
L[i] = index + i * W;
}
index += W * H;
for (int i = 0; i < H; i++) {
a[i] = index + i * W;
}
index += W * H;
for (int i = 0; i < H; i++) {
b[i] = index + i * W;
}
};
public:
int W, H;
float * data;
@ -64,31 +40,9 @@ public:
//Copies image data in Img into this instance.
void CopyFrom(LabImage *Img);
void getPipetteData (float &L, float &a, float &b, int posX, int posY, int squareSize);
void deleteLab( )
{
if (!fromImage) {
delete [] L;
delete [] a;
delete [] b;
delete [] data;
}
}
void reallocLab( )
{
allocLab(W, H);
};
void clear(bool multiThread = false) {
#ifdef _OPENMP
#pragma omp parallel for if(multiThread)
#endif
for(int i = 0; i < H; ++i) {
for(int j = 0; j < W; ++j) {
L[i][j] = a[i][j] = b[i][j] = 0.f;
}
}
}
void deleteLab();
void reallocLab();
void clear(bool multiThread = false);
};
}

View File

@ -1023,7 +1023,7 @@ rtengine::LCPMapper::LCPMapper(
bool rtengine::LCPMapper::isCACorrectionAvailable() const
{
return enableCA;
return false /*enableCA*/; // agriggio TODO -- this is currently broken
}
void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy, double scale) const
@ -1077,12 +1077,15 @@ void rtengine::LCPMapper::correctDistortion(double &x, double &y, int cx, int cy
y -= cy * scale;
}
void rtengine::LCPMapper::correctCA(double& x, double& y, int channel) const
void rtengine::LCPMapper::correctCA(double& x, double& y, int cx, int cy, int channel) const
{
if (!enableCA) {
return;
}
x += cx;
y += cy;
double xgreen, ygreen;
// First calc the green channel like normal distortion
@ -1123,6 +1126,9 @@ void rtengine::LCPMapper::correctCA(double& x, double& y, int channel) const
x = (chrom[channel].scale_factor * ( xd * commonSum + xfac * rsqr )) * chrom[channel].fx + chrom[channel].x0;
y = (chrom[channel].scale_factor * ( yd * commonSum + yfac * rsqr )) * chrom[channel].fy + chrom[channel].y0;
}
x -= cx;
x -= cy;
}
SSEFUNCTION void rtengine::LCPMapper::processVignetteLine(int width, int y, float* line) const

View File

@ -164,7 +164,7 @@ public:
virtual ~LensCorrection() {}
virtual void correctDistortion(double &x, double &y, int cx, int cy, double scale) const = 0;
virtual bool isCACorrectionAvailable() const = 0;
virtual void correctCA(double &x, double &y, int channel) const = 0;
virtual void correctCA(double &x, double &y, int cx, int cy, int channel) const = 0;
virtual void processVignetteLine(int width, int y, float *line) const = 0;
virtual void processVignetteLine3Channels(int width, int y, float *line) const = 0;
};
@ -192,7 +192,7 @@ public:
void correctDistortion(double &x, double &y, int cx, int cy, double scale) const; // MUST be the first stage
bool isCACorrectionAvailable() const;
void correctCA(double& x, double& y, int channel) const;
void correctCA(double& x, double& y, int cx, int cy, int channel) const;
void processVignetteLine(int width, int y, float* line) const;
void processVignetteLine3Channels(int width, int y, float* line) const;

View File

@ -36,11 +36,7 @@ InitialImage* InitialImage::load (const Glib::ustring& fname, bool isRaw, int* e
isrc->setProgressListener (pl);
if(isRaw && pl == nullptr) {
*errorCode = isrc->load (fname, true);
} else {
*errorCode = isrc->load (fname);
}
*errorCode = isrc->load (fname);
if (*errorCode) {
delete isrc;

View File

@ -33,6 +33,11 @@
#define PROT_READ 1
#define MAP_FAILED (void *)-1
#ifdef __GNUC__ // silence warning
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
void* mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
{
HANDLE handle = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL, PAGE_WRITECOPY, 0, 0, NULL);
@ -51,6 +56,9 @@ int munmap(void *start, size_t length)
UnmapViewOfFile(start);
return 0;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#else // WIN32

View File

@ -22,6 +22,8 @@
#ifndef OPTHELPER_H
#define OPTHELPER_H
#define pow_F(a,b) (xexpf(b*xlogf(a)))
#ifdef __SSE2__
#include "sleefsseavx.c"
#ifdef __GNUC__

View File

@ -97,7 +97,7 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext
if ((mode == PIM_EmbeddedOrRaw && !tpp) || mode == PIM_ForceRaw) {
RawImageSource rawImage;
int error = rawImage.load(fname, true);
int error = rawImage.load(fname);
if (!error) {
const unsigned char *data = nullptr;
@ -115,7 +115,7 @@ PreviewImage::PreviewImage (const Glib::ustring &fname, const Glib::ustring &ext
rawImage.preprocess(params.raw, params.lensProf, params.coarse);
rawImage.demosaic(params.raw);
Imagefloat image(fw, fh);
rawImage.getImage (wb, TR_NONE, &image, pp, params.toneCurve, params.icm, params.raw);
rawImage.getImage (wb, TR_NONE, &image, pp, params.toneCurve, params.raw);
rtengine::Image8 output(fw, fh);
rawImage.convertColorSpace(&image, params.icm, wb);
#pragma omp parallel for schedule(dynamic, 10)

View File

@ -18,7 +18,6 @@
*/
#include <glib/gstdio.h>
#include "procparams.h"
#include "rt_math.h"
#include "curves.h"
#include "../rtgui/multilangmgr.h"
#include "../rtgui/version.h"
@ -26,6 +25,7 @@
#include "../rtgui/paramsedited.h"
#include "../rtgui/options.h"
#include <locale.h>
#define APPVERSION RTVERSION
using namespace std;
@ -558,7 +558,7 @@ void ColorToningParams::slidersToCurve (std::vector<double> &colorCurve, std::ve
opacityCurve.at (8) = 0.35;
}
void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const
void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], bool &opautili) const
{
float satur = 0.8f;
float lumin = 0.5f; //middle of luminance for optimization of gamut - no real importance...as we work in XYZ and gamut control
@ -584,13 +584,13 @@ void ColorToningParams::getCurves (ColorGradientCurve &colorCurveLUT, OpacityCur
satur = 0.9f;
}
colorCurveLUT.SetXYZ (cCurve, xyz_rgb, rgb_xyz, satur, lumin);
colorCurveLUT.SetXYZ (cCurve, xyz_rgb, satur, lumin);
opacityCurveLUT.Set (oCurve, opautili);
} else if (method == "Splitlr" || method == "Splitco") {
colorCurveLUT.SetXYZ (cCurve, xyz_rgb, rgb_xyz, satur, lumin);
colorCurveLUT.SetXYZ (cCurve, xyz_rgb, satur, lumin);
opacityCurveLUT.Set (oCurve, opautili);
} else if (method.substr (0, 3) == "RGB") {
colorCurveLUT.SetRGB (cCurve, xyz_rgb, rgb_xyz);
colorCurveLUT.SetRGB (cCurve);
opacityCurveLUT.Set (oCurve, opautili);
}
}
@ -10480,7 +10480,7 @@ void PartialProfile::clearGeneral ()
}
}
const void PartialProfile::applyTo (ProcParams *destParams) const
void PartialProfile::applyTo (ProcParams *destParams) const
{
if (destParams && pparams && pedited) {
pedited->combine (*destParams, *pparams, true);

View File

@ -440,7 +440,7 @@ public:
/// @brief Specifically transform the sliders values to their curve equivalences
void slidersToCurve (std::vector<double> &colorCurve, std::vector<double> &opacityCurve) const;
/// @brief Fill the ColorGradientCurve and OpacityCurve LUTf from the control points curve or sliders value
void getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], const double rgb_xyz[3][3], bool &opautili) const;
void getCurves (ColorGradientCurve &colorCurveLUT, OpacityCurve &opacityCurveLUT, const double xyz_rgb[3][3], bool &opautili) const;
static void getDefaultColorCurve (std::vector<double> &curve);
static void getDefaultOpacityCurve (std::vector<double> &curve);
@ -1633,7 +1633,7 @@ public:
void clearGeneral ();
int load (const Glib::ustring &fName);
void set (bool v);
const void applyTo (ProcParams *destParams) const ;
void applyTo (ProcParams *destParams) const ;
};
/**

View File

@ -87,7 +87,7 @@ void transLineStandard (const float* const red, const float* const green, const
rotateLine (blue, image->b, tran, i, imwidth, imheight);
}
void transLineFuji (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imwidth, const int imheight, const int fw)
void transLineFuji (const float* const red, const float* const green, const float* const blue, const int i, rtengine::Imagefloat* const image, const int tran, const int imheight, const int fw)
{
// Fuji SuperCCD rotation + coarse rotation
@ -623,7 +623,7 @@ float calculate_scale_mul (float scale_mul[4], const float pre_mul_[4], const fl
return gain;
}
void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw )
void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw )
{
MyMutex::MyLock lock (getImageMutex);
@ -823,8 +823,8 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima
if (d1x) {
transLineD1x (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, d1xHeightOdd, doClip);
} else if (fuji) {
transLineFuji (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight, fw);
} else if(fuji) {
transLineFuji (line_red, line_grn, line_blue, ix, image, tran, imheight, fw);
} else {
transLineStandard (line_red, line_grn, line_blue, ix, image, tran, imwidth, imheight);
}
@ -910,7 +910,7 @@ void RawImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* ima
}
}
DCPProfile *RawImageSource::getDCP (const ColorManagementParams &cmp, ColorTemp &wb, DCPProfile::ApplyState &as)
DCPProfile *RawImageSource::getDCP(const ColorManagementParams &cmp, DCPProfile::ApplyState &as)
{
DCPProfile *dcpProf = nullptr;
cmsHPROFILE dummy;
@ -1519,7 +1519,7 @@ void RawImageSource::vflip (Imagefloat* image)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int RawImageSource::load (const Glib::ustring &fname, int imageNum, bool batch)
int RawImageSource::load (const Glib::ustring &fname)
{
MyTime t1, t2;
@ -2012,7 +2012,7 @@ void RawImageSource::preprocess (const RAWParams &raw, const LensProfParams &le
double clip = 0;
int brightness, contrast, black, hlcompr, hlcomprthresh;
getAutoExpHistogram (aehist, aehistcompr);
ImProcFunctions::getAutoExp (aehist, aehistcompr, getDefGain(), clip, dirpyrdenoiseExpComp, brightness, contrast, black, hlcompr, hlcomprthresh);
ImProcFunctions::getAutoExp (aehist, aehistcompr, clip, dirpyrdenoiseExpComp, brightness, contrast, black, hlcompr, hlcomprthresh);
}
t2.set();
@ -2041,7 +2041,7 @@ void RawImageSource::demosaic (const RAWParams &raw)
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::vng4] ) {
vng4_demosaic ();
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::ahd] ) {
ahd_demosaic (0, 0, W, H);
ahd_demosaic ();
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::amaze] ) {
amaze_demosaic_RT (0, 0, W, H, rawData, red, green, blue);
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::pixelshift] ) {
@ -2055,7 +2055,7 @@ void RawImageSource::demosaic (const RAWParams &raw)
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::lmmse]) {
lmmse_interpolate_omp (W, H, rawData, red, green, blue, raw.bayersensor.lmmse_iterations);
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::fast] ) {
fast_demosaic (0, 0, W, H);
fast_demosaic();
} else if (raw.bayersensor.method == RAWParams::BayerSensor::methodstring[RAWParams::BayerSensor::mono] ) {
nodemosaic (true);
} else {
@ -2126,8 +2126,8 @@ void RawImageSource::retinexPrepareBuffers(ColorManagementParams cmp, const Reti
std::swap (pwr, gamm);
}
int mode = 0, imax = 0;
Color::calcGamma (pwr, ts, mode, imax, g_a); // call to calcGamma with selected gamma and slope
int mode = 0;
Color::calcGamma(pwr, ts, mode, g_a); // 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;
@ -2393,13 +2393,13 @@ void RawImageSource::retinex(ColorManagementParams cmp, const RetinexParams &deh
double gamm = deh.gam;
double gamm2 = gamm;
double ts = deh.slope;
int mode = 0, imax = 0;
int mode = 0;
if (gamm2 < 1.) {
std::swap (pwr, gamm);
}
Color::calcGamma (pwr, ts, mode, imax, g_a); // call to calcGamma with selected gamma and slope
Color::calcGamma(pwr, ts, mode, g_a); // call to calcGamma with selected gamma and slope
double mul = 1. + g_a[4];
double add;

View File

@ -116,7 +116,7 @@ public:
RawImageSource ();
~RawImageSource ();
int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false);
int load (const Glib::ustring &fname);
void preprocess (const RAWParams &raw, const LensProfParams &lensProf, const CoarseTransformParams& coarse, bool prepareDenoise = true);
void demosaic (const RAWParams &raw);
void retinex (ColorManagementParams cmp, const RetinexParams &deh, ToneCurveParams Tc, LUTf & cdcurve, LUTf & mapcurve, const RetinextransmissionCurve & dehatransmissionCurve, const RetinexgaintransmissionCurve & dehagaintransmissionCurve, multi_array2D<float, 4> &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);
@ -138,7 +138,7 @@ public:
void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW);
void scaleColors (int winx, int winy, int winw, int winh, const RAWParams &raw, array2D<float> &rawData); // raw for cblack
void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw);
void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw);
eSensorType getSensorType () const
{
return ri != nullptr ? ri->getSensorType() : ST_NONE;
@ -185,7 +185,7 @@ public:
}
void getAutoExpHistogram (LUTu & histogram, int& histcompr);
void getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw);
DCPProfile *getDCP(const ColorManagementParams &cmp, ColorTemp &wb, DCPProfile::ApplyState &as);
DCPProfile *getDCP(const ColorManagementParams &cmp, DCPProfile::ApplyState &as);
void convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb);
static bool findInputProfile(Glib::ustring inProfile, cmsHPROFILE embedded, std::string camName, DCPProfile **dcpProf, cmsHPROFILE& in);
@ -245,9 +245,9 @@ protected:
void igv_interpolate(int winw, int winh);
void lmmse_interpolate_omp(int winw, int winh, array2D<float> &rawData, array2D<float> &red, array2D<float> &green, array2D<float> &blue, int iterations);
void amaze_demosaic_RT(int winx, int winy, int winw, int winh, array2D<float> &rawData, array2D<float> &red, array2D<float> &green, array2D<float> &blue);//Emil's code for AMaZE
void fast_demosaic(int winx, int winy, int winw, int winh );//Emil's code for fast demosaicing
void fast_demosaic();//Emil's code for fast demosaicing
void dcb_demosaic(int iterations, bool dcb_enhance);
void ahd_demosaic(int winx, int winy, int winw, int winh);
void ahd_demosaic();
void border_interpolate(unsigned int border, float (*image)[4], unsigned int start = 0, unsigned int end = 0);
void border_interpolate2(int winw, int winh, int lborders);
void dcb_initTileLimits(int &colMin, int &rowMin, int &colMax, int &rowMax, int x0, int y0, int border);

View File

@ -72,14 +72,43 @@ void LFModifier::correctDistortion(double &x, double &y, int cx, int cy, double
bool LFModifier::isCACorrectionAvailable() const
{
return false;
return (flags_ & LF_MODIFY_TCA);
}
#ifdef __GNUC__ // silence warning, can be removed when function is implemented
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
void LFModifier::correctCA(double &x, double &y, int channel) const
void LFModifier::correctCA(double &x, double &y, int cx, int cy, int channel) const
{
assert(channel >= 0 && channel <= 2);
// agriggio: RT currently applies the CA correction per channel, whereas
// lensfun applies it to all the three channels simultaneously. This means
// we do the work 3 times, because each time we discard 2 of the 3
// channels. We could consider caching the info to speed this up
x += cx;
y += cy;
float pos[6];
if (swap_xy_) {
std::swap(x, y);
}
data_->ApplySubpixelDistortion(x, y, 1, 1, pos);
x = pos[2*channel];
y = pos[2*channel+1];
if (swap_xy_) {
std::swap(x, y);
}
x -= cx;
y -= cy;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
void LFModifier::processVignetteLine(int width, int y, float *line) const
{
@ -109,6 +138,11 @@ Glib::ustring LFModifier::getDisplayString() const
ret += "vignetting";
sep = ", ";
}
if (flags_ & LF_MODIFY_TCA) {
ret += sep;
ret += "CA";
sep = ", ";
}
if (flags_ & LF_MODIFY_SCALE) {
ret += sep;
ret += "autoscaling";
@ -254,6 +288,15 @@ bool LFLens::hasDistortionCorrection() const
}
}
bool LFLens::hasCACorrection() const
{
if (data_) {
return data_->CalibTCA;
} else {
return false;
}
}
//-----------------------------------------------------------------------------
// LFDatabase
@ -435,7 +478,7 @@ std::unique_ptr<LFModifier> LFDatabase::getModifier(const LFCamera &camera, cons
if (data_) {
if (camera && lens) {
lfModifier *mod = lfModifier::Create(lens.data_, camera.getCropFactor(), width, height);
int flags = LF_MODIFY_DISTORTION | LF_MODIFY_SCALE;
int flags = LF_MODIFY_DISTORTION | LF_MODIFY_SCALE | LF_MODIFY_TCA;
if (aperture > 0) {
flags |= LF_MODIFY_VIGNETTING;
}

View File

@ -44,7 +44,7 @@ public:
void correctDistortion(double &x, double &y, int cx, int cy, double scale) const override;
bool isCACorrectionAvailable() const override;
void correctCA(double &x, double &y, int channel) const override;
void correctCA(double &x, double &y, int cx, int cy, int channel) const override;
void processVignetteLine(int width, int y, float *line) const override;
void processVignetteLine3Channels(int width, int y, float *line) const override;
@ -91,6 +91,7 @@ public:
float getCropFactor() const;
bool hasVignettingCorrection() const;
bool hasDistortionCorrection() const;
bool hasCACorrection() const;
private:
friend class LFDatabase;

View File

@ -38,7 +38,6 @@
#include "improccoordinator.h"
#include <locale.h>
namespace
{
@ -381,7 +380,7 @@ RawMetaDataLocation Thumbnail::loadMetaDataFromRaw (const Glib::ustring& fname)
return rml;
}
Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, int imageNum)
Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate)
{
RawImage *ri = new RawImage (fname);
unsigned int tempImageNum = 0;
@ -659,69 +658,18 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
tpp->scale = (double) height / (rotate_90 ? w : h);
}
// generate histogram for auto exposure
// generate histogram for auto exposure, also calculate autoWB
tpp->aeHistCompression = 3;
tpp->aeHistogram (65536 >> tpp->aeHistCompression);
tpp->aeHistogram(65536 >> tpp->aeHistCompression);
tpp->aeHistogram.clear();
int radd = 4;
int gadd = 4;
int badd = 4;
if (!filter) {
radd = gadd = badd = 1;
}
const unsigned int add = filter ? 1 : 4 / ri->get_colors();
for (int i = 8; i < height - 8; i++) {
int start, end;
if (ri->get_FujiWidth() != 0) {
int fw = ri->get_FujiWidth();
start = ABS (fw - i) + 8;
end = min (height + width - fw - i, fw + i) - 8;
} else {
start = 8;
end = width - 8;
}
if (ri->get_colors() == 1) {
for (int j = start; j < end; j++) {
tpp->aeHistogram[ ((int) (image[i * width + j][0])) >> tpp->aeHistCompression] += radd;
tpp->aeHistogram[ ((int) (image[i * width + j][0])) >> tpp->aeHistCompression] += gadd;
tpp->aeHistogram[ ((int) (image[i * width + j][0])) >> tpp->aeHistCompression] += badd;
}
} else if (ri->getSensorType() == ST_BAYER) {
for (int j = start; j < end; j++)
if (FISGREEN (filter, i, j)) {
tpp->aeHistogram[ ((int) (tpp->camwbGreen * image[i * width + j][1])) >> tpp->aeHistCompression] += gadd;
} else if (FISRED (filter, i, j)) {
tpp->aeHistogram[ ((int) (tpp->camwbRed * image[i * width + j][0])) >> tpp->aeHistCompression] += radd;
} else if (FISBLUE (filter, i, j)) {
tpp->aeHistogram[ ((int) (tpp->camwbBlue * image[i * width + j][2])) >> tpp->aeHistCompression] += badd;
}
} else if (ri->getSensorType() == ST_FUJI_XTRANS) {
for (int j = start; j < end; j++)
if (ri->ISXTRANSGREEN (i, j)) {
tpp->aeHistogram[ ((int) (tpp->camwbGreen * image[i * width + j][1])) >> tpp->aeHistCompression] += gadd;
} else if (ri->ISXTRANSRED (i, j)) {
tpp->aeHistogram[ ((int) (tpp->camwbRed * image[i * width + j][0])) >> tpp->aeHistCompression] += radd;
} else if (ri->ISXTRANSBLUE (i, j)) {
tpp->aeHistogram[ ((int) (tpp->camwbBlue * image[i * width + j][2])) >> tpp->aeHistCompression] += badd;
}
} else { /* if(ri->getSensorType()==ST_FOVEON) */
for (int j = start; j < end; j++) {
tpp->aeHistogram[ ((int) (image[i * width + j][0] * 2.f)) >> tpp->aeHistCompression] += radd;
tpp->aeHistogram[ ((int) (image[i * width + j][1])) >> tpp->aeHistCompression] += gadd;
tpp->aeHistogram[ ((int) (image[i * width + j][2] * 0.5f)) >> tpp->aeHistCompression] += badd;
}
}
}
// generate autoWB
double avg_r = 0;
double avg_g = 0;
double avg_b = 0;
unsigned int rn = 0, gn = 0, bn = 0;
double pixSum[3] = {0.0};
unsigned int n[3] = {0};
const double compression = pow(2.0, tpp->aeHistCompression);
const double camWb[3] = {tpp->camwbRed / compression, tpp->camwbGreen / compression, tpp->camwbBlue / compression};
const double clipval = 64000.0 / tpp->defGain;
for (int i = 32; i < height - 32; i++) {
int start, end;
@ -735,110 +683,118 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
end = width - 32;
}
if (ri->getSensorType() == ST_BAYER) {
if (ri->get_colors() == 1) {
for (int j = start; j < end; j++) {
if (!filter) {
double d = tpp->defGain * image[i * width + j][0];
if (d > 64000.) {
continue;
}
avg_g += d;
avg_r += d;
avg_b += d;
rn++;
gn++;
bn++;
} else if (FISGREEN (filter, i, j)) {
double d = tpp->defGain * image[i * width + j][1];
if (d > 64000.) {
continue;
}
avg_g += d;
gn++;
} else if (FISRED (filter, i, j)) {
double d = tpp->defGain * image[i * width + j][0];
if (d > 64000.) {
continue;
}
avg_r += d;
rn++;
} else if (FISBLUE (filter, i, j)) {
double d = tpp->defGain * image[i * width + j][2];
if (d > 64000.) {
continue;
}
avg_b += d;
bn++;
tpp->aeHistogram[image[i * width + j][0] >> tpp->aeHistCompression]++;
}
} else if (ri->getSensorType() == ST_BAYER) {
int c0 = ri->FC(i, start);
int c1 = ri->FC(i, start + 1);
int j = start;
int n0 = 0;
int n1 = 0;
double pixSum0 = 0.0;
double pixSum1 = 0.0;
for (; j < end - 1; j+=2) {
double v0 = image[i * width + j][c0];
tpp->aeHistogram[(int)(camWb[c0] * v0)]++;
if (v0 <= clipval) {
pixSum0 += v0;
n0++;
}
double v1 = image[i * width + j + 1][c1];
tpp->aeHistogram[(int)(camWb[c1] * v1)]++;
if (v1 <= clipval) {
pixSum1 += v1;
n1++;
}
}
if (j < end) {
double v0 = image[i * width + j][c0];
tpp->aeHistogram[(int)(camWb[c0] * v0)]++;
if (v0 <= clipval) {
pixSum0 += v0;
n0++;
}
}
n[c0] += n0;
n[c1] += n1;
pixSum[c0] += pixSum0;
pixSum[c1] += pixSum1;
} else if (ri->getSensorType() == ST_FUJI_XTRANS) {
for (int j = start; j < end; j++) {
int c[6];
for(int cc = 0; cc < 6; ++cc) {
c[cc] = ri->XTRANSFC(i, start + cc);
}
int j = start;
for (; j < end - 5; j += 6) {
for(int cc = 0; cc < 6; ++cc) {
double d = image[i * width + j + cc][c[cc]];
tpp->aeHistogram[(int)(camWb[c[cc]] * d)]++;
if (d <= clipval) {
pixSum[c[cc]] += d;
n[c[cc]]++;
}
}
}
for (; j < end; j++) {
if (ri->ISXTRANSGREEN (i, j)) {
double d = tpp->defGain * image[i * width + j][1];
if (d > 64000.) {
continue;
double d = image[i * width + j][1];
tpp->aeHistogram[(int)(camWb[1] * d)]++;
if (d <= clipval) {
pixSum[1] += d;
n[1]++;
}
avg_g += d;
gn++;
} else if (ri->ISXTRANSRED (i, j)) {
double d = tpp->defGain * image[i * width + j][0];
if (d > 64000.) {
continue;
double d = image[i * width + j][0];
tpp->aeHistogram[(int)(camWb[0] * d)]++;
if (d <= clipval) {
pixSum[0] += d;
n[0]++;
}
avg_r += d;
rn++;
} else if (ri->ISXTRANSBLUE (i, j)) {
double d = tpp->defGain * image[i * width + j][2];
if (d > 64000.) {
continue;
double d = image[i * width + j][2];
tpp->aeHistogram[(int)(camWb[2] * d)]++;
if (d <= clipval) {
pixSum[2] += d;
n[2]++;
}
avg_b += d;
bn++;
}
}
} else { /* if(ri->getSensorType()==ST_FOVEON) */
for (int j = start; j < end; j++) {
double d = tpp->defGain * image[i * width + j][0];
if (d <= 64000.) {
avg_r += d;
rn++;
double r = image[i * width + j][0];
if (r <= clipval) {
pixSum[0] += r;
n[0]++;
}
d = tpp->defGain * image[i * width + j][1];
if (d <= 64000.) {
avg_g += d;
gn++;
double g = image[i * width + j][1];
if (g <= clipval) {
pixSum[1] += g;
n[1]++;
}
d = tpp->defGain * image[i * width + j][2];
if (d <= 64000.) {
avg_b += d;
bn++;
tpp->aeHistogram[((int)g) >> tpp->aeHistCompression] += add;
double b = image[i * width + j][2];
if (b <= clipval) {
pixSum[2] += b;
n[2]++;
}
tpp->aeHistogram[((int) (b * 0.5f)) >> tpp->aeHistCompression] += add;
}
}
}
double reds = avg_r / std::max(rn, 1u) * tpp->camwbRed;
double greens = avg_g / std::max(gn, 1u) * tpp->camwbGreen;
double blues = avg_b / std::max(bn, 1u) * tpp->camwbBlue;
if (ri->get_colors() == 1) {
pixSum[0] = pixSum[1] = pixSum[2] = 1.;
n[0] = n[1] = n[2] = 1;
}
pixSum[0] *= tpp->defGain;
pixSum[1] *= tpp->defGain;
pixSum[2] *= tpp->defGain;
double reds = pixSum[0] / std::max(n[0], 1u) * tpp->camwbRed;
double greens = pixSum[1] / std::max(n[1], 1u) * tpp->camwbGreen;
double blues = pixSum[2] / std::max(n[2], 1u) * tpp->camwbBlue;
tpp->redAWBMul = ri->get_rgb_cam (0, 0) * reds + ri->get_rgb_cam (0, 1) * greens + ri->get_rgb_cam (0, 2) * blues;
tpp->greenAWBMul = ri->get_rgb_cam (1, 0) * reds + ri->get_rgb_cam (1, 1) * greens + ri->get_rgb_cam (1, 2) * blues;
@ -929,7 +885,7 @@ Thumbnail::~Thumbnail ()
}
// Simple processing of RAW internal JPGs
IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int rheight, rtengine::TypeInterpolation interp, double& myscale)
IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int rheight, rtengine::TypeInterpolation interp)
{
int rwidth;
@ -1126,8 +1082,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
int hlcomprthresh = params.toneCurve.hlcomprthresh;
if (params.toneCurve.autoexp && aeHistogram) {
double logDefGain = 0.0;
ipf.getAutoExp (aeHistogram, aeHistCompression, logDefGain, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh);
ipf.getAutoExp (aeHistogram, aeHistCompression, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh);
}
LUTf curve1 (65536);
@ -1153,8 +1108,8 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
ToneCurve customToneCurvebw2;
CurveFactory::complexCurve (expcomp, black / 65535.0, hlcompr, hlcomprthresh,
params.toneCurve.shcompr, bright, contr,
params.toneCurve.curveMode, params.toneCurve.curve,
params.toneCurve.curveMode2, params.toneCurve.curve2,
params.toneCurve.curve,
params.toneCurve.curve2,
hist16, curve1, curve2, curve, dummy, customToneCurve1, customToneCurve2, 16);
LUTf rCurve;
@ -1173,13 +1128,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
{wprof[1][0], wprof[1][1], wprof[1][2]},
{wprof[2][0], wprof[2][1], wprof[2][2]}
};
TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params.icm.working);
double wip[3][3] = {
{wiprof[0][0], wiprof[0][1], wiprof[0][2]},
{wiprof[1][0], wiprof[1][1], wiprof[1][2]},
{wiprof[2][0], wiprof[2][1], wiprof[2][2]}
};
params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili);
params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, opautili);
clToningcurve (65536);
CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, scale == 1 ? 1 : 16);
@ -1291,7 +1240,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
customColCurve2,
customColCurve3,
16);
int begh = 0, endh = labView->H;
bool execsharp = false;
float d, dj, yb;
float fnum = fnumber;// F number
@ -1324,7 +1273,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT
CAMMean = NAN;
CAMBrightCurveJ.dirty = true;
CAMBrightCurveQ.dirty = true;
ipf.ciecam_02float (cieView, adap, begh, endh, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, sk, execsharp, d, dj, yb, rtt);
ipf.ciecam_02float (cieView, adap, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, sk, execsharp, d, dj, yb, rtt);
delete cieView;
}
@ -1434,7 +1383,7 @@ void Thumbnail::applyAutoExp (procparams::ProcParams& params)
if (params.toneCurve.autoexp && aeHistogram) {
ImProcFunctions ipf (&params, false);
ipf.getAutoExp (aeHistogram, aeHistCompression, log (defGain) / log (2.0), params.toneCurve.clip, params.toneCurve.expcomp,
ipf.getAutoExp (aeHistogram, aeHistCompression, params.toneCurve.clip, params.toneCurve.expcomp,
params.toneCurve.brightness, params.toneCurve.contrast, params.toneCurve.black, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh);
}
}
@ -1763,7 +1712,7 @@ unsigned char* Thumbnail::getGrayscaleHistEQ (int trim_width)
return tmpdata;
}
bool Thumbnail::writeImage (const Glib::ustring& fname, int format)
bool Thumbnail::writeImage (const Glib::ustring& fname)
{
if (!thumbImg) {

View File

@ -72,12 +72,12 @@ public:
void init ();
IImage8* processImage (const procparams::ProcParams& pparams, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& scale);
IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp, double& scale);
IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp);
int getImageWidth (const procparams::ProcParams& pparams, int rheight, float &ratio);
void getDimensions (int& w, int& h, double& scaleFac);
static Thumbnail* loadQuickFromRaw (const Glib::ustring& fname, rtengine::RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, bool rotate, bool inspectorMode = false);
static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate, int imageNum);
static Thumbnail* loadFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, double wbEq, bool rotate);
static Thumbnail* loadFromImage (const Glib::ustring& fname, int &w, int &h, int fixwh, double wbEq, bool inspectorMode = false);
static RawMetaDataLocation loadMetaDataFromRaw (const Glib::ustring& fname);
@ -88,7 +88,7 @@ public:
void applyAutoExp (procparams::ProcParams& pparams);
unsigned char* getGrayscaleHistEQ (int trim_width);
bool writeImage (const Glib::ustring& fname, int format);
bool writeImage (const Glib::ustring& fname);
bool readImage (const Glib::ustring& fname);
bool readData (const Glib::ustring& fname);

View File

@ -325,7 +325,7 @@ private:
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 );
imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.raw );
//baseImg->getStdImage(currWB, tr, origCropPart, ppP, true, params.toneCurve);
// we only need image reduced to 1/4 here
@ -545,7 +545,7 @@ private:
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);
imgsrc->getImage (currWB, tr, origCropPart, ppP, params.toneCurve, params.raw);
//baseImg->getStdImage(currWB, tr, origCropPart, ppP, true, params.toneCurve);
@ -705,7 +705,7 @@ private:
}
baseImg = new Imagefloat (fw, fh);
imgsrc->getImage (currWB, tr, baseImg, pp, params.toneCurve, params.icm, params.raw);
imgsrc->getImage (currWB, tr, baseImg, pp, params.toneCurve, params.raw);
if (pl) {
pl->setProgress (0.50);
@ -725,7 +725,7 @@ private:
LUTu aehist;
int aehistcompr;
imgsrc->getAutoExpHistogram (aehist, aehistcompr);
ipf.getAutoExp (aehist, aehistcompr, imgsrc->getDefGain(), params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh);
ipf.getAutoExp (aehist, aehistcompr, params.toneCurve.clip, expcomp, bright, contr, black, hlcompr, hlcomprthresh);
}
// at this stage, we can flush the raw data to free up quite an important amount of memory
@ -785,9 +785,9 @@ private:
// CurveFactory::denoiseLL(lldenoiseutili, denoiseParams.lcurve, Noisecurve,1);
//denoiseParams.getCurves(noiseLCurve);
// ipf.RGB_denoise(baseImg, baseImg, calclum, imgsrc->isRAW(), denoiseParams, params.defringe, imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, lldenoiseutili);
float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi;
float 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, nresi, highresi);
}
@ -881,7 +881,7 @@ private:
//if(params.blackwhite.enabled) params.toneCurve.hrenabled=false;
CurveFactory::complexCurve (expcomp, black / 65535.0, hlcompr, hlcomprthresh, params.toneCurve.shcompr, bright, contr,
params.toneCurve.curveMode, params.toneCurve.curve, params.toneCurve.curveMode2, params.toneCurve.curve2,
params.toneCurve.curve, params.toneCurve.curve2,
hist16, curve1, curve2, curve, dummy, customToneCurve1, customToneCurve2 );
CurveFactory::RGBCurve (params.rgbCurves.rcurve, rCurve, 1);
@ -897,13 +897,7 @@ private:
{wprof[1][0], wprof[1][1], wprof[1][2]},
{wprof[2][0], wprof[2][1], wprof[2][2]}
};
TMatrix wiprof = ICCStore::getInstance()->workingSpaceInverseMatrix (params.icm.working);
double wip[3][3] = {
{wiprof[0][0], wiprof[0][1], wiprof[0][2]},
{wiprof[1][0], wiprof[1][1], wiprof[1][2]},
{wiprof[2][0], wiprof[2][1], wiprof[2][2]}
};
params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, wip, opautili);
params.colorToning.getCurves (ctColorCurve, ctOpacityCurve, wp, opautili);
clToningcurve (65536, 0);
CurveFactory::curveToning (params.colorToning.clcurve, clToningcurve, 1);
cl2Toningcurve (65536, 0);
@ -943,7 +937,7 @@ private:
autor = -9000.f; // This will ask to compute the "auto" values for the B&W tool (have to be inferior to -5000)
DCPProfile::ApplyState as;
DCPProfile *dcpProf = imgsrc->getDCP (params.icm, currWB, as);
DCPProfile *dcpProf = imgsrc->getDCP (params.icm, as);
LUTu histToneCurve;
@ -2115,7 +2109,7 @@ private:
CurveFactory::curveWavContL (wavcontlutili, params.wavelet.wavclCurve, wavclCurve,/* hist16C, dummy,*/ 1);
if (params.wavelet.enabled) {
ipf.ip_wavelet (labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, wavcontlutili, 1);
ipf.ip_wavelet (labView, labView, 2, WaveParams, wavCLVCurve, waOpacityCurveRG, waOpacityCurveBY, waOpacityCurveW, waOpacityCurveWL, wavclCurve, 1);
}
wavCLVCurve.Reset();
@ -2123,7 +2117,6 @@ private:
//Colorappearance and tone-mapping associated
int f_w = 1, f_h = 1;
int begh = 0, endh = fh;
if (params.colorappearance.tonecie || params.colorappearance.enabled) {
f_w = fw;
@ -2131,8 +2124,7 @@ private:
}
CieImage *cieView = new CieImage (f_w, (f_h));
begh = 0;
endh = fh;
CurveFactory::curveLightBrightColor (
params.colorappearance.curve,
params.colorappearance.curve2,
@ -2176,18 +2168,18 @@ private:
if (params.sharpening.enabled) {
if (settings->ciecamfloat) {
float d, dj, yb;
ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1);
ipf.ciecam_02float (cieView, float (adap), 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1);
} else {
double dd, dj, yb;
ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, yb, 1);
double dd, dj;
ipf.ciecam_02 (cieView, adap, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, 1);
}
} else {
if (settings->ciecamfloat) {
float d, dj, yb;
ipf.ciecam_02float (cieView, float (adap), begh, endh, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1);
ipf.ciecam_02float (cieView, float (adap), 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, d, dj, yb, 1);
} else {
double dd, dj, yb;
ipf.ciecam_02 (cieView, adap, begh, endh, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, yb, 1);
double dd, dj;
ipf.ciecam_02 (cieView, adap, 1, 2, labView, &params, customColCurve1, customColCurve2, customColCurve3, dummy, dummy, CAMBrightCurveJ, CAMBrightCurveQ, CAMMean, 5, 1, true, dd, dj, 1);
}
}
}
@ -2279,7 +2271,7 @@ private:
GammaValues ga;
// if(params.blackwhite.enabled) params.toneCurve.hrenabled=false;
readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm, bwonly, &ga);
readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm, &ga);
customGamma = true;
//or selected Free gamma
@ -2293,7 +2285,7 @@ private:
// if Default gamma mode: we use the profile selected in the "Output profile" combobox;
// gamma come from the selected profile, otherwise it comes from "Free gamma" tool
readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm, bwonly);
readyImg = ipf.lab2rgb16 (labView, cx, cy, cw, ch, params.icm);
if (settings->verbose) {
printf ("Output profile_: \"%s\"\n", params.icm.output.c_str());

View File

@ -102,7 +102,7 @@ void StdImageSource::getSampleFormat (const Glib::ustring &fname, IIOSampleForma
* and RT's image data type (Image8, Image16 and Imagefloat), then it will
* load the image into it
*/
int StdImageSource::load (const Glib::ustring &fname, int imageNum, bool batch)
int StdImageSource::load (const Glib::ustring &fname)
{
fileName = fname;
@ -187,7 +187,7 @@ int StdImageSource::load (const Glib::ustring &fname, int imageNum, bool batch)
return 0;
}
void StdImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw)
void StdImageSource::getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw)
{
// the code will use OpenMP as of now.

View File

@ -42,8 +42,8 @@ public:
StdImageSource ();
~StdImageSource ();
int load (const Glib::ustring &fname, int imageNum = 0, bool batch = false);
void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const ColorManagementParams &cmp, const RAWParams &raw);
int load (const Glib::ustring &fname);
void getImage (const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw);
ColorTemp getWB () const
{
return wb;

View File

@ -192,7 +192,7 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
ckbUseDist->set_active (pp->lensProf.useDist);
ckbUseVign->set_active (pp->lensProf.useVign && isRaw);
ckbUseCA->set_active (pp->lensProf.useCA && isRaw);
ckbUseCA->set_active(pp->lensProf.useCA && isRaw && ckbUseCA->get_sensitive());
const LFDatabase *db = LFDatabase::getInstance();
LFCamera c;
@ -254,6 +254,16 @@ void LensProfilePanel::updateLensfunWarning()
}
ckbUseVign->set_sensitive(l.hasVignettingCorrection());
ckbUseDist->set_sensitive(l.hasDistortionCorrection());
ckbUseCA->set_sensitive(l.hasCACorrection());
if (!isRaw || !l.hasVignettingCorrection()) {
ckbUseVign->set_active(false);
}
if (!l.hasDistortionCorrection()) {
ckbUseDist->set_active(false);
}
if (!l.hasCACorrection()) {
ckbUseCA->set_active(false);
}
}
}
@ -370,7 +380,8 @@ void LensProfilePanel::updateDisabled(bool enable)
{
ckbUseDist->set_sensitive(enable);
ckbUseVign->set_sensitive(enable && isRaw);
ckbUseCA->set_sensitive(enable && allowFocusDep);
// agriggio TODO -- CA correction via LCP is currently broken
ckbUseCA->set_sensitive(false);//enable && allowFocusDep);
}
void LensProfilePanel::setBatchMode(bool yes)

View File

@ -163,7 +163,7 @@ int main (int argc, char **argv)
return -2;
}
rtengine::setPaths (options);
rtengine::setPaths();
TIFFSetWarningHandler (nullptr); // avoid annoying message boxes

View File

@ -258,7 +258,7 @@ RTWindow *create_rt_window()
Glib::RefPtr<Gtk::IconTheme> defaultIconTheme = Gtk::IconTheme::get_default();
defaultIconTheme->append_search_path (icon_path);
rtengine::setPaths (options);
rtengine::setPaths();
MyExpander::init(); // has to stay AFTER rtengine::setPaths
// ------- loading theme files

View File

@ -2164,7 +2164,7 @@ void Preferences::cancelPressed ()
{
// set the initial theme back
if (themeFNames.at (theme->get_active_row_number ()).longFName != options.theme) {
rtengine::setPaths (options);
rtengine::setPaths();
RTImage::updateImages();
switchThemeTo (options.theme);
}
@ -2222,7 +2222,7 @@ void Preferences::themeChanged ()
{
moptions.theme = themeFNames.at (theme->get_active_row_number ()).longFName;
rtengine::setPaths (moptions);
rtengine::setPaths();
RTImage::updateImages();
switchThemeTo (moptions.theme);
}

View File

@ -141,7 +141,7 @@ void Thumbnail::_generateThumbnailImage ()
if ( tpp == nullptr ) {
quick = false;
tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, tw, th, 1, pparams.wb.equal, TRUE, pparams.raw.bayersensor.imageNum);
tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, sensorType, tw, th, 1, pparams.wb.equal, TRUE);
}
cfs.sensortype = sensorType;
@ -613,7 +613,7 @@ rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::Pro
if ( cfs.thumbImgType == CacheImageData::QUICK_THUMBNAIL ) {
// RAW internal thumbnail, no profile yet: just do some rotation etc.
image = tpp->quickProcessImage (pparams, h, rtengine::TI_Nearest, scale);
image = tpp->quickProcessImage (pparams, h, rtengine::TI_Nearest);
} else {
// Full thumbnail: apply profile
// image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, cfs.getCamera(), cfs.focalLen, cfs.focalLen35mm, cfs.focusDist, cfs.shutter, cfs.fnumber, cfs.iso, cfs.expcomp, scale );
@ -884,7 +884,7 @@ void Thumbnail::_saveThumbnail ()
}
// save thumbnail image
tpp->writeImage (getCacheFileName ("images", ""), 1);
tpp->writeImage (getCacheFileName ("images", ""));
// save aehistogram
tpp->writeAEHistogram (getCacheFileName ("aehistograms", ""));