Patch from issue 927: Clarity and sharpening

on behalf of Jacques Desmis
This commit is contained in:
natureh
2011-08-26 00:55:31 +02:00
parent 4b20c52735
commit 0762ac0703
2 changed files with 1482 additions and 1458 deletions

View File

@@ -330,14 +330,14 @@ HISTORY_MSG_97;'b' curve
HISTORY_MSG_98;Demosaicing method HISTORY_MSG_98;Demosaicing method
HISTORY_MSG_99;Hot/dead pixel filtering HISTORY_MSG_99;Hot/dead pixel filtering
HISTORY_MSG_9;Highlight Compression HISTORY_MSG_9;Highlight Compression
HISTORY_MSG_142;Clarity -passes HISTORY_MSG_142;Edges sharpening - iterations
HISTORY_MSG_143;Clarity -gradient strength HISTORY_MSG_143;Edges sharpening - quantity
HISTORY_MSG_147;Clarity - luminance only HISTORY_MSG_147;Edges sharpening - luminance only
HISTORY_MSG_144;Microcontrast - strength HISTORY_MSG_144;Microcontrast - quantity
HISTORY_MSG_145;Microcontrast - uniformity HISTORY_MSG_145;Microcontrast - uniformity
HISTORY_MSG_146;Clarity Sharpening - enabled HISTORY_MSG_146;Edges Sharpening
HISTORY_MSG_148;Clarity Microcontrast - enabled HISTORY_MSG_148;Microcontrast
HISTORY_MSG_149;Clarity Microcontrast matrix HISTORY_MSG_149;Microcontrast - 3x3 matrix
HISTORY_MSG_150;Post demosaic artifact/noise reduction HISTORY_MSG_150;Post demosaic artifact/noise reduction
HISTORY_NEWSNAPSHOT;Add HISTORY_NEWSNAPSHOT;Add
HISTORY_NEWSNAPSHOTAS;As... HISTORY_NEWSNAPSHOTAS;As...
@@ -512,7 +512,7 @@ PARTIALPASTE_FLATFIELDAUTOSELECT;FF Auto Select
PARTIALPASTE_FLATFIELDBLURRADIUS;FF Blur Radius PARTIALPASTE_FLATFIELDBLURRADIUS;FF Blur Radius
PARTIALPASTE_FLATFIELDBLURTYPE;FF Blur Type PARTIALPASTE_FLATFIELDBLURTYPE;FF Blur Type
PARTIALPASTE_FLATFIELDFILE;Flat field (FF) File PARTIALPASTE_FLATFIELDFILE;Flat field (FF) File
PARTIALPASTE_GRADIENTSHARPEN;Gradient Sharpening (border) PARTIALPASTE_GRADIENTSHARPEN;Local Sharpening
PARTIALPASTE_HLRECONSTRUCTION;Highlight reconstruction PARTIALPASTE_HLRECONSTRUCTION;Highlight reconstruction
PARTIALPASTE_HLRECOVERY;Highlight recovery PARTIALPASTE_HLRECOVERY;Highlight recovery
PARTIALPASTE_HLRECOVERYAMOUNT;Highlight recovery amount PARTIALPASTE_HLRECOVERYAMOUNT;Highlight recovery amount
@@ -571,7 +571,7 @@ PREFERENCES_CACHETHUMBHEIGHT;Maximal Thumbnail Height
PREFERENCES_CLIPPINGIND;Clipping indication PREFERENCES_CLIPPINGIND;Clipping indication
PREFERENCES_CMETRICINTENT;Colorimetric Intent PREFERENCES_CMETRICINTENT;Colorimetric Intent
PREFERENCES_CUSTPROFBUILD;Custom image profile builder PREFERENCES_CUSTPROFBUILD;Custom image profile builder
PREFERENCES_CUSTPROFBUILDHINT;Executable (or script) file called when a new initial profile should be generated an image.\nReceives command line params to allow a rules based .pp3 generation:\n[Path RAW/JPG] [Path default profile] [f-no] [exposure in secs] [focal length in mm] [ISO] [Lens] [Camera] PREFERENCES_CUSTPROFBUILDHINT;Executable (or script) file called when a new initial profile should be generated for an image.\nReceives command line params to allow a rules based .pp3 generation:\n[Path RAW/JPG] [Path default profile] [f-no] [exposure in secs] [focal length in mm] [ISO] [Lens] [Camera]
PREFERENCES_CUSTPROFBUILDPATH;Executable path PREFERENCES_CUSTPROFBUILDPATH;Executable path
PREFERENCES_CUTOVERLAYBRUSH;Crop mask color/transparency PREFERENCES_CUTOVERLAYBRUSH;Crop mask color/transparency
PREFERENCES_DARKFRAME;Dark frame PREFERENCES_DARKFRAME;Dark frame
@@ -737,14 +737,14 @@ TP_CHMIXER_GREEN;Green
TP_CHMIXER_LABEL;Channel Mixer TP_CHMIXER_LABEL;Channel Mixer
TP_CHMIXER_RED;Red TP_CHMIXER_RED;Red
TP_CHROMATABERR_LABEL;Chromatic Aberration TP_CHROMATABERR_LABEL;Chromatic Aberration
TP_CLARITY_LABEL;Clarity and Sharpening TP_CLARITY_LABEL;Local Sharpening
TP_CLARITY_SHARPEN;Border TP_CLARITY_SHARPEN;Edges Sharpening
TP_CLARITY_STRENGTH;Gradient strength TP_CLARITY_STRENGTH;Quantity
TP_CLARITY_PASSES;Gradient passes TP_CLARITY_PASSES;Iterations
TP_CLARITY_MICRO;Texture TP_CLARITY_MICRO;Microcontrast
TP_CLARITY_THREE;Luminance only TP_CLARITY_THREE;Luminance only
TP_CLARITY_MATRIX;3x3 matrix instead of 5x5 TP_CLARITY_MATRIX;3x3 matrix instead of 5x5
TP_MLMICRO_STRENGTH;Strength TP_MLMICRO_STRENGTH;Quantity
TP_MLMICRO_UNIFORMITY;Uniformity TP_MLMICRO_UNIFORMITY;Uniformity
TP_COARSETRAF_DEGREE;degree: TP_COARSETRAF_DEGREE;degree:
TP_COARSETRAF_TOOLTIP_HFLIP;Flip horizontally TP_COARSETRAF_TOOLTIP_HFLIP;Flip horizontally

View File

@@ -34,12 +34,16 @@ namespace rtengine {
#define CMAXVAL 0xffff #define CMAXVAL 0xffff
#define CLIP(a) ((a)>0?((a)<CMAXVAL?(a):CMAXVAL):0) #define CLIP(a) ((a)>0?((a)<CMAXVAL?(a):CMAXVAL):0)
#define ABS(a) ((a)<0?-(a):(a)) #define ABS(a) ((a)<0?-(a):(a))
#define LIM(x,min,max) MAX(min,MIN(x,max))
#define CLIREF(x) LIM(x,-200000.0,200000.0) // avoid overflow : do not act directly on image[] or pix[]
extern Settings* settings; extern Settings* settings;
void ImProcFunctions::dcdamping (float** aI, float** aO, float damping, int W, int H) { void ImProcFunctions::dcdamping (float** aI, float** aO, float damping, int W, int H) {
const float dampingFac=2.0/(damping*damping); const float dampingFac=2.0/(damping*damping);
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp for #pragma omp for
#endif #endif
@@ -73,10 +77,12 @@ void ImProcFunctions::deconvsharpening (LabImage* lab, float** b2) {
} }
float** tmp = (float**)b2; float** tmp = (float**)b2;
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel #pragma omp parallel
#endif #endif
{ {
AlignedBuffer<double>* buffer = new AlignedBuffer<double> (MAX(W,H)); AlignedBuffer<double>* buffer = new AlignedBuffer<double> (MAX(W,H));
float damping = params->sharpening.deconvdamping / 5.0; float damping = params->sharpening.deconvdamping / 5.0;
bool needdamp = params->sharpening.deconvdamping > 0; bool needdamp = params->sharpening.deconvdamping > 0;
@@ -140,8 +146,7 @@ void ImProcFunctions::sharpening (LabImage* lab, float** b2) {
int W = lab->W, H = lab->H; int W = lab->W, H = lab->H;
float** b3; float** b3;
if (params->sharpening.edgesonly) if (params->sharpening.edgesonly) {
{
b3 = new float*[H]; b3 = new float*[H];
for (int i=0; i<H; i++) for (int i=0; i<H; i++)
b3[i] = new float[W]; b3[i] = new float[W];
@@ -181,6 +186,7 @@ void ImProcFunctions::sharpening (LabImage* lab, float** b2) {
} }
else else
sharpenHaloCtrl (lab, b2, base, W, H); sharpenHaloCtrl (lab, b2, base, W, H);
} // end parallel } // end parallel
if (params->sharpening.edgesonly) { if (params->sharpening.edgesonly) {
@@ -232,11 +238,12 @@ void ImProcFunctions::sharpenHaloCtrl (LabImage* lab, float** blurmap, float** b
} }
} }
} }
// To the extent possible under law, Manuel Llorens <manuelllorens@gmail.com>[ // To the extent possible under law, Manuel Llorens <manuelllorens@gmail.com>[
// has waived all copyright and related or neighboring rights to this work. // has waived all copyright and related or neighboring rights to this work.
// This work is published from: Spain. // This work is published from: Spain.
//thanks to Manuel for this excellent job.. (Jacques Desmis JDC or frej83) // Thanks to Manuel for this excellent job (Jacques Desmis JDC or frej83)
void ImProcFunctions::MLsharpen (LabImage* lab) { void ImProcFunctions::MLsharpen (LabImage* lab) {
// JD: this algorithm maximize clarity of images; it does not play on accutance. It can remove (partialy) the effects of the AA filter) // JD: this algorithm maximize clarity of images; it does not play on accutance. It can remove (partialy) the effects of the AA filter)
// I think we can use this algorithm alone in most cases, or first to clarify image and if you want a very little USM (unsharp mask sharpening) after... // I think we can use this algorithm alone in most cases, or first to clarify image and if you want a very little USM (unsharp mask sharpening) after...
@@ -255,9 +262,11 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
width2 = 2*width; width2 = 2*width;
float strength; float strength;
strength = params->clarity.clstrength / 100.0f; strength = params->clarity.clstrength / 100.0f;
if(strength < 0.00001f) return; if (strength < 0.00001f)
return;
if (settings->verbose) printf ("Clarity strength %f\n", strength); if (settings->verbose)
printf ("Clarity strength %f\n", strength);
L = new float[width*height]; L = new float[width*height];
@@ -267,17 +276,19 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
int channels; int channels;
if (params->clarity.clthreechannels) channels=0; else channels=2; if (params->clarity.clthreechannels) channels=0; else channels=2;
if (settings->verbose) printf ("Clarity channels %d\n", channels); if (settings->verbose)
printf ("Clarity channels %d\n", channels);
int passes=params->clarity.clpasses; int passes=params->clarity.clpasses;
if (settings->verbose) printf ("Clarity passes %d\n", passes); if (settings->verbose)
printf ("Clarity passes %d\n", passes);
for (p=0; p<passes; p++) for (p=0; p<passes; p++)
for (c=0; c<=channels; c++) {// c=0 Luminance only for (c=0; c<=channels; c++) {// c=0 Luminance only
#pragma omp parallel for private(offset) shared(L) #pragma omp parallel for private(offset) shared(L)
for(offset=0;offset<width*height;offset++) for (offset=0; offset<width*height; offset++) {
{int ii=offset/width; int ii = offset/width;
int kk = offset-ii*width; int kk = offset-ii*width;
if (c==0) L[offset] = lab->L[ii][kk]/327.68f; // adjust to RT and to 0..100 if (c==0) L[offset] = lab->L[ii][kk]/327.68f; // adjust to RT and to 0..100
else if (c==1) L[offset] = lab->a[ii][kk]/327.68f; else if (c==1) L[offset] = lab->a[ii][kk]/327.68f;
@@ -307,7 +318,8 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
// contrast detection // contrast detection
contrast = sqrt(fabs(L[offset+1]-L[offset-1])*fabs(L[offset+1]-L[offset-1])+fabs(L[offset+width]-L[offset-width])*fabs(L[offset+width]-L[offset-width]))/chmax[c]; contrast = sqrt(fabs(L[offset+1]-L[offset-1])*fabs(L[offset+1]-L[offset-1])+fabs(L[offset+width]-L[offset-width])*fabs(L[offset+width]-L[offset-width]))/chmax[c];
if(contrast>1.0) contrast=1.0; if (contrast>1.0)
contrast=1.0;
// new possible values // new possible values
if ((L[offset]<L[offset-1])&&(L[offset]>L[offset+1])||(L[offset]>L[offset-1])&&(L[offset]<L[offset+1])){ if ((L[offset]<L[offset-1])&&(L[offset]>L[offset+1])||(L[offset]>L[offset-1])&&(L[offset]<L[offset+1])){
@@ -381,7 +393,8 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
s = strength; s = strength;
// avoid sharpening diagonals too much // avoid sharpening diagonals too much
if(((fabs(wH/wV)<0.45f)&&(fabs(wH/wV)>0.05f))||((fabs(wV/wH)<0.45f)&&(fabs(wV/wH)>0.05f))) s=strength/3.0f; if (((fabs(wH/wV)<0.45f)&&(fabs(wH/wV)>0.05f))||((fabs(wV/wH)<0.45f)&&(fabs(wV/wH)>0.05f)))
s = strength/3.0f;
// final mix // final mix
if ((wH!=0.0f)&&(wV!=0.0f)&&(wD1!=0.0f)&&(wD2!=0.0f)) { if ((wH!=0.0f)&&(wV!=0.0f)&&(wD1!=0.0f)&&(wD2!=0.0f)) {
@@ -389,7 +402,7 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
kkk = offset-iii*width; kkk = offset-iii*width;
templab = v*(1-s)+(lumH*wH+lumV*wV+lumD1*wD1+lumD2*wD2)/(wH+wV+wD1+wD2)*s; templab = v*(1-s)+(lumH*wH+lumV*wV+lumD1*wD1+lumD2*wD2)/(wH+wV+wD1+wD2)*s;
if (c==0) lab->L[iii][kkk] = fabs(327.68f*templab); // fabs because lab->L always >0 if (c==0) lab->L[iii][kkk] = fabs(327.68f*templab); // fabs because lab->L always >0
else if (c==1){lab->a[iii][kkk]=327.68f*templab;} else if (c==1) lab->a[iii][kkk] = 327.68f*templab ;
else if (c==2) lab->b[iii][kkk] = 327.68f*templab ; else if (c==2) lab->b[iii][kkk] = 327.68f*templab ;
} }
@@ -401,7 +414,6 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
t2e.set(); t2e.set();
if (settings->verbose) if (settings->verbose)
printf("Clarity gradient %d usec\n", t2e.etime(t1e)); printf("Clarity gradient %d usec\n", t2e.etime(t1e));
} }
// To the extent possible under law, Manuel Llorens <manuelllorens@gmail.com> // To the extent possible under law, Manuel Llorens <manuelllorens@gmail.com>
@@ -426,10 +438,14 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
int unif; int unif;
unif = (int)(uniform/10.0f); //put unif between 0 to 10 unif = (int)(uniform/10.0f); //put unif between 0 to 10
float strength = params->clarity.mlstrength/1500.0f; //strength 2000.0 quasi no artefacts ==> 1500 = maximum, after artefacts float strength = params->clarity.mlstrength/1500.0f; //strength 2000.0 quasi no artefacts ==> 1500 = maximum, after artefacts
if(strength < 0.000001f) return; if (strength < 0.000001f)
if(k==1) strength*=2.7f;//25/9 if 3x3 return;
if (settings->verbose) printf ("Microcontrast strength %f\n", strength); if (k==1)
if (settings->verbose) printf ("Microcontrast uniformity %i\n",unif); strength *= 2.7f; //25/9 if 3x3
if (settings->verbose)
printf ("Microcontrast strength %f\n", strength);
if (settings->verbose)
printf ("Microcontrast uniformity %i\n",unif);
//modulation uniformity in function of luminance //modulation uniformity in function of luminance
float L98[11] = {0.001f,0.0015f,0.002f,0.004f,0.006f,0.008f,0.01f,0.03f,0.05f,0.1f,0.1f}; float L98[11] = {0.001f,0.0015f,0.002f,0.004f,0.006f,0.008f,0.01f,0.03f,0.05f,0.1f,0.1f};
float L95[11] = {0.0012f,0.002f,0.005f,0.01f,0.02f,0.05f,0.1f,0.12f,0.15f,0.2f,0.25f}; float L95[11] = {0.0012f,0.002f,0.005f,0.01f,0.02f,0.05f,0.1f,0.12f,0.15f,0.2f,0.25f};
@@ -477,37 +493,38 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
else if (k==2) contrast = sqrt(fabs(LM[offset+1]-LM[offset-1])*fabs(LM[offset+1]-LM[offset-1])+fabs(LM[offset+width]-LM[offset-width])*fabs(LM[offset+width]-LM[offset-width])\ else if (k==2) contrast = sqrt(fabs(LM[offset+1]-LM[offset-1])*fabs(LM[offset+1]-LM[offset-1])+fabs(LM[offset+width]-LM[offset-width])*fabs(LM[offset+width]-LM[offset-width])\
+fabs(LM[offset+2]-LM[offset-2])*fabs(LM[offset+2]-LM[offset-2])+fabs(LM[offset+2*width]-LM[offset-2*width])*fabs(LM[offset+2*width]-LM[offset-2*width]))/(2*chmax); //for 5x5 +fabs(LM[offset+2]-LM[offset-2])*fabs(LM[offset+2]-LM[offset-2])+fabs(LM[offset+2*width]-LM[offset-2*width])*fabs(LM[offset+2*width]-LM[offset-2*width]))/(2*chmax); //for 5x5
if(contrast>1.0f) contrast=1.0f; if (contrast>1.0f)
contrast=1.0f;
//matrix 5x5 //matrix 5x5
temp=lab->L[j][i]/327.68f; //begin 3x3 temp=lab->L[j][i]/327.68f; //begin 3x3
temp +=(v-LM[offset-width-1])*sqrtf(2.0f)*s; temp += CLIREF(v-LM[offset-width-1])*sqrtf(2.0f)*s;
temp +=(v-LM[offset-width])*s; temp += CLIREF(v-LM[offset-width])*s;
temp +=(v-LM[offset-width+1])*sqrtf(2.0f)*s; temp += CLIREF(v-LM[offset-width+1])*sqrtf(2.0f)*s;
temp +=(v-LM[offset-1])*s; temp += CLIREF(v-LM[offset-1])*s;
temp +=(v-LM[offset+1])*s; temp += CLIREF(v-LM[offset+1])*s;
temp +=(v-LM[offset+width-1])*sqrtf(2.0f)*s; temp += CLIREF(v-LM[offset+width-1])*sqrtf(2.0f)*s;
temp +=(v-LM[offset+width])*s; temp += CLIREF(v-LM[offset+width])*s;
temp +=(v-LM[offset+width+1])*sqrtf(2.0f)*s;//end 3x3 temp += CLIREF(v-LM[offset+width+1])*sqrtf(2.0f)*s;//end 3x3
// add JD continue 5x5 // add JD continue 5x5
if (k==2) { if (k==2) {
temp +=2.0f*(v-LM[offset+2*width])*s; temp += 2.0f*CLIREF(v-LM[offset+2*width])*s;
temp +=2.0f*(v-LM[offset-2*width])*s; temp += 2.0f*CLIREF(v-LM[offset-2*width])*s;
temp +=2.0f*(v-LM[offset-2])*s; temp += 2.0f*CLIREF(v-LM[offset-2 ])*s;
temp +=2.0f*(v-LM[offset+2])*s; temp += 2.0f*CLIREF(v-LM[offset+2 ])*s;
temp +=2.0f*(v-LM[offset+2*width -1])*s*sqrtf(1.25f);// 1.25 = 1*1 + 0.5*0.5 temp += 2.0f*CLIREF(v-LM[offset+2*width-1])*s*sqrtf(1.25f);// 1.25 = 1*1 + 0.5*0.5
temp +=2.0f*(v-LM[offset+2*width -2])*s*sqrtf(2.0f); temp += 2.0f*CLIREF(v-LM[offset+2*width-2])*s*sqrtf(2.00f);
temp +=2.0f*(v-LM[offset+2*width+1])*s*sqrtf(1.25f);; temp += 2.0f*CLIREF(v-LM[offset+2*width+1])*s*sqrtf(1.25f);
temp +=2.0f*(v-LM[offset+2*width+2])*s*sqrtf(2.0f); temp += 2.0f*CLIREF(v-LM[offset+2*width+2])*s*sqrtf(2.00f);
temp +=2.0f*(v-LM[offset+ width+2])*s*sqrtf(1.25f);; temp += 2.0f*CLIREF(v-LM[offset+ width+2])*s*sqrtf(1.25f);
temp +=2.0f*(v-LM[offset+width-2])*s*sqrtf(1.25f);; temp += 2.0f*CLIREF(v-LM[offset+ width-2])*s*sqrtf(1.25f);
temp +=2.0f*(v-LM[offset-2*width -1])*s*sqrtf(1.25f); temp += 2.0f*CLIREF(v-LM[offset-2*width-1])*s*sqrtf(1.25f);
temp +=2.0f*(v-LM[offset-2*width -2])*s*sqrtf(2.0f); temp += 2.0f*CLIREF(v-LM[offset-2*width-2])*s*sqrtf(2.00f);
temp +=2.0f*(v-LM[offset-2*width+1])*s*sqrtf(1.25f);; temp += 2.0f*CLIREF(v-LM[offset-2*width+1])*s*sqrtf(1.25f);
temp +=2.0f*(v-LM[offset-2*width+2])*s*sqrtf(2.0f); temp += 2.0f*CLIREF(v-LM[offset-2*width+2])*s*sqrtf(2.00f);
temp +=2.0f*(v-LM[offset- width+2])*s*sqrtf(1.25f);; temp += 2.0f*CLIREF(v-LM[offset- width+2])*s*sqrtf(1.25f);
temp +=2.0f*(v-LM[offset-width-2])*s*sqrtf(1.25f);; temp += 2.0f*CLIREF(v-LM[offset- width-2])*s*sqrtf(1.25f);
} }
if (temp <0.0f) temp = 0.0f; if (temp <0.0f) temp = 0.0f;
v=temp; v=temp;
@@ -516,25 +533,31 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
for(row=j-k; row<=j+k; row++) for(row=j-k; row<=j+k; row++)
for(col=i-k,offset2=row*width+col; col<=i+k; col++,offset2++){ for(col=i-k,offset2=row*width+col; col<=i+k; col++,offset2++){
if(((v<LM[offset2])&&(signs[n]>0))||((v>LM[offset2])&&(signs[n]<0))) if (((v<LM[offset2])&&(signs[n]>0))||((v>LM[offset2])&&(signs[n]<0))) {
{
temp = v*0.75f+LM[offset2]*0.25f;// 0.75 0.25 temp = v*0.75f+LM[offset2]*0.25f;// 0.75 0.25
n++; n++;
} }
} }
if(LM[offset]>95.0f || LM[offset]<5.0f) contrast*=Cont0[unif]; //+ JD : luminance pyramid to adjust contrast by evaluation of LM[offset] if (LM[offset]>95.0f || LM[offset]<5.0f)
else if(LM[offset]>90.0f || LM[offset]<10.0f) contrast*=Cont1[unif]; contrast *= Cont0[unif]; //+ JD : luminance pyramid to adjust contrast by evaluation of LM[offset]
else if(LM[offset]>80.0f || LM[offset]<20.0f) contrast*=Cont2[unif]; else if (LM[offset]>90.0f || LM[offset]<10.0f)
else if(LM[offset]>70.0f || LM[offset]<30.0f) contrast*=(2.0f/k)*Cont3[unif]; contrast *= Cont1[unif];
else if(LM[offset]>60.0f || LM[offset]<40.0f) contrast*=(2.0f/k)*Cont4[unif]; else if (LM[offset]>80.0f || LM[offset]<20.0f)
contrast *= Cont2[unif];
else if (LM[offset]>70.0f || LM[offset]<30.0f)
contrast *= Cont3[unif];
else if (LM[offset]>60.0f || LM[offset]<40.0f)
contrast *= Cont4[unif];
else else
contrast*=(2.0f/k)*Cont5[unif]; contrast *= Cont5[unif];//(2.0f/k)*Cont5[unif];
if(contrast>1.0f) {contrast=1.0f;}
if (contrast>1.0f)
contrast=1.0f;
tempL = 327.68f*(temp*(1.0f-contrast)+LM[offset]*contrast); tempL = 327.68f*(temp*(1.0f-contrast)+LM[offset]*contrast);
// JD: modulation of microcontrast in function of original Luminance and modulation of luminance // JD: modulation of microcontrast in function of original Luminance and modulation of luminance
temp2 = tempL/(327.68f*LM[offset]);//for highlights temp2 = tempL/(327.68f*LM[offset]);//for highlights
if (temp2>1.0f) { if (temp2>1.0f) {
if(temp2>2.0f) temp2=2.0f;//limit action if (temp2>1.70f) temp2=1.70f;//limit action
if (LM[offset]>98.0f) { lab->L[j][i]=LM[offset]*327.68f; } if (LM[offset]>98.0f) { lab->L[j][i]=LM[offset]*327.68f; }
else if (LM[offset]>95.0f) { temp3=temp2-1.0f; temp=(L95[unif]*temp3)+1.0f; lab->L[j][i]=temp*LM[offset]*327.68f; } else if (LM[offset]>95.0f) { temp3=temp2-1.0f; temp=(L95[unif]*temp3)+1.0f; lab->L[j][i]=temp*LM[offset]*327.68f; }
else if (LM[offset]>92.0f) { temp3=temp2-1.0f; temp=(L92[unif]*temp3)+1.0f; lab->L[j][i]=temp*LM[offset]*327.68f; } else if (LM[offset]>92.0f) { temp3=temp2-1.0f; temp=(L92[unif]*temp3)+1.0f; lab->L[j][i]=temp*LM[offset]*327.68f; }
@@ -559,7 +582,8 @@ void ImProcFunctions::MLsharpen (LabImage* lab) {
} }
temp4 = (327.68f*LM[offset])/tempL;// temp4 = (327.68f*LM[offset])/tempL;//
if (temp4>1.0f) { if (temp4>1.0f) {
if(temp4>2.f) temp4=2.f;//limit action if (temp4>1.7f)
temp4 = 1.7f;//limit action
if (LM[offset]< 2.0f) { temp3=temp4-1.0f; temp=(L98[unif]*temp3)+1.0f; lab->L[j][i]=(LM[offset]*327.68f)/temp; } if (LM[offset]< 2.0f) { temp3=temp4-1.0f; temp=(L98[unif]*temp3)+1.0f; lab->L[j][i]=(LM[offset]*327.68f)/temp; }
else if (LM[offset]< 5.0f) { temp3=temp4-1.0f; temp=(L95[unif]*temp3)+1.0f; lab->L[j][i]=(LM[offset]*327.68f)/temp; } else if (LM[offset]< 5.0f) { temp3=temp4-1.0f; temp=(L95[unif]*temp3)+1.0f; lab->L[j][i]=(LM[offset]*327.68f)/temp; }
else if (LM[offset]< 8.0f) { temp3=temp4-1.0f; temp=(L92[unif]*temp3)+1.0f; lab->L[j][i]=(LM[offset]*327.68f)/temp; } else if (LM[offset]< 8.0f) { temp3=temp4-1.0f; temp=(L92[unif]*temp3)+1.0f; lab->L[j][i]=(LM[offset]*327.68f)/temp; }