aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy <Roy.mail.net@gmail.com>2023-01-02 14:22:49 +0200
committerRoy <Roy.mail.net@gmail.com>2023-01-02 14:22:49 +0200
commitbf12cd84a004708b7aa40fae96fd23bae7ed9666 (patch)
treec6d1209bf4a23660b7dce5346aa3f395e1353d61
parent1ceac8f89fa391dabc74fc0e2a1fd747abd0ac97 (diff)
parent55bd0fdfcb323300a8cb20a714ce4b5296205fa3 (diff)
downloadTango-bf12cd84a004708b7aa40fae96fd23bae7ed9666.tar.gz
Tango-bf12cd84a004708b7aa40fae96fd23bae7ed9666.zip
Merged last Mirta Changes.
-rw-r--r--Software/Visual_Studio/ColorLib/Tango.ColorLib_v6/ColorConverter.cpp68
1 files changed, 42 insertions, 26 deletions
diff --git a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v6/ColorConverter.cpp b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v6/ColorConverter.cpp
index a98cc3524..47f0fcfff 100644
--- a/Software/Visual_Studio/ColorLib/Tango.ColorLib_v6/ColorConverter.cpp
+++ b/Software/Visual_Studio/ColorLib/Tango.ColorLib_v6/ColorConverter.cpp
@@ -63,7 +63,7 @@
#define LUMINANCE_PCS 159.16
#define L_A LUMINANCE_PCS / 5.0
#define Y_b 20.0
-#define eps 1e-06
+#define eps 1e-04
#define NegValue -1000
#define WPTol 1.0
#define dETol 0.5
@@ -1568,6 +1568,7 @@ void Tango::ColorLib::ColorConverter::SetMaxNLperCM(double maxNlPerCM, int i)
void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates *inputcoordinates, int n_processRanges,
int colorspace, VectorXd &VolumeNoLI, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion, bool &InGamut)
{
+ // December 25, 2022: this whole function is a mess, should be cleaned up once all the issues are resolved
//July 29 2020
//Limit inks based on m_maxNlpercm
//Inks are limited in their nonlinear form
@@ -1612,7 +1613,7 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates
//Volume should remain unchanged regardless of the thread loaded
if (colorspace == COLOR_SPACE__Catalog)
{
- for (int i = 0; i < m_nInks; ++i) // % to nl/cm
+ for (int i = 0; i < m_nInks; ++i) // % to nl/cm //convert to nl/cm in Color Table space
VolumeNoLI(i) *= (m_CTmaxNlPerCM(i) / 100);
m_currentMaxNLPerCM = m_CTmaxNlPerCM;
for (int iP = 0; iP < m_nProcessRanges; ++iP)
@@ -1622,7 +1623,12 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates
}
int CTUnits = 1; // do not convert to thread units
//Catalogue Volume Values should have InGamut = true
- GetClosestInk(VolumeNoLI, GamutRegion, VolumeNoLI, CTUnits); //Input VolumeNoLI is in [nl/cm] Output VolumeNoLI is in [%]
+ //No rounding for Catalogue inputs - Mirta Dec. 25 2022
+// GetClosestInk(VolumeNoLI, GamutRegion, VolumeNoLI, CTUnits); //Input VolumeNoLI is in [nl/cm] Output VolumeNoLI is in [%]
+
+ // Need to convert volume from nl/cm to %, previously done in the above, commented out call Dec 25, 2022
+ NLcmtoPercentage(VolumeNoLI, VolumeNoLI);
+
for (int i = 0; i < m_nInks; ++i)
FinalVolumeNoLI(i) = VolumeNoLI(i); //VolumeNoLi is in Color Table Units
PercentagetoNLcm(VolumeNoLI, VolumeNoLI); //in [nl/cm] converted in Color Table Space
@@ -1641,10 +1647,10 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates
InkOutP[i] *= tmpval[i]; //scaled to real units, still in %
ApplyCTLinearCurves(InkOutP, LinInkP); //Full Range in Color Table Units %
- LimitInksPercentage(DoubleToVector(LinInkP, m_nInks), InkOut, isBounded, 1); //Limited in Color Table Space
- ColorTable2Threadunits(DoubleToVector(LinInkP, m_nInks), InkOut); //Full Range in Thread units %
+// LimitInksPercentage(DoubleToVector(LinInkP, m_nInks), InkOut, isBounded, 1); //Limited in Color Table Space
+// ColorTable2Threadunits(DoubleToVector(LinInkP, m_nInks), InkOut); //Full Range in Thread units %
//Ink percentages were bounded, there is no problem using the calibration curves
- ConvertToNLInks(InkOut,InkOut); //ful range in Thread units %
+// ConvertToNLInks(InkOut,InkOut); //ful range in Thread units %
}
else if (colorspace == COLOR_SPACE__Volume)
{
@@ -1658,7 +1664,11 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(InputCoordinates
m_CurrentProcessRangesMin[i] = m_ProcessRangesMinP[i];
}
int CTUnits = 0; //to convert to Color Table space
- GetClosestInk(VolumeNoLI, GamutRegion, VolumeNoLI, CTUnits); //VolumenoLi Input is in [nl/cm], VolumeNoLI Output is in [%] in thread space
+ // GetClosestInk(VolumeNoLI, GamutRegion, VolumeNoLI, CTUnits); //VolumenoLi Input is in [nl/cm], VolumeNoLI Output is in [%] in thread space
+
+ // Need to convert volume from nl/cm to %, previously done in the above, commented out call Dec 25, 2022
+ NLcmtoPercentage(VolumeNoLI, VolumeNoLI);
+
VolumeToNLInkP(VolumeNoLI, NLInkP); //NLInkP is in % Full Range
PercentagetoNLcm(VolumeNoLI, VolumeNoLI); //in [nl/cm]
GamutRegion = GetGamutRegion(VolumeNoLI, m_CurrentProcessRangesMax);
@@ -4631,6 +4641,7 @@ void Tango::ColorLib::ColorConverter::LimitNLInks2VolumeThr(VectorXd NLInks, int
void Tango::ColorLib::ColorConverter::GetClosestInk(VectorXd Volume, int &GamutRegion, VectorXd &BestVolume, int CTUnits)
{
+ //Fix CMY only K will fall in the search for feasible solutions - January 2, 2023
//Volume is in[nl/cm]
//BestVolume is in %
VectorXd LabOut(3);
@@ -4644,7 +4655,7 @@ void Tango::ColorLib::ColorConverter::GetClosestInk(VectorXd Volume, int &GamutR
for (int i = 0; i < m_nInks; ++i)
TotalVolume += Volume(i);
DefineSplitLimits(low, high, TotalVolume);
- for (int i = 0; i < m_nInks; ++i)
+ for (int i = 0; i < m_nInks-1; ++i)
{
if (Volume(i) > 1.e-04)
diffVolume[i] = std::abs(Volume(i) - std::max(Volume(i), low));
@@ -5868,7 +5879,7 @@ void Tango::ColorLib::ColorConverter::DirectInversionCalc(double *LabIn, VectorX
{
ValK[0] = (double)k * dK;
DirectInversionCalcSIter(ValK[0], LabOnGamut, VolumeVec, forwardmodel, dECMC[k], isBounded[k], SolVector[k], GamutRegion,
- finalLab[k], nfree, nfixed);
+ finalLab[k], nfree, nfixed); //VolumeVec is in threads units
for (i = 0; i < npars; ++i)
Vol[k][i] = VolumeVec[i];
VecGamutRegion[k] = GamutRegion;
@@ -5876,13 +5887,24 @@ void Tango::ColorLib::ColorConverter::DirectInversionCalc(double *LabIn, VectorX
//find feasible solutions
int nfeas = -1;
-
+ double *TotalVolume = new double[nk];
+ double *low = new double[nk];
+ double *high = new double[nk];
+ double **Vol_nlcm = new double*[nk];
for (k = 0; k < nk; ++k)
{
bool FSInd = true;
+ TotalVolume[k] = 0.0;
+ Vol_nlcm[k] = new double[m_nInks];
+ for (i = 0; i < m_nInks; ++i)
+ {
+ Vol_nlcm[k][i] = Vol[k][i] * m_currentMaxNLPerCM(i) / 100.0;
+ TotalVolume[k] += Vol_nlcm[k][i];
+ }
+ DefineSplitLimits(low[k], high[k], TotalVolume[k]);
for (i = 0; i < npars - 1; ++i)
- FSInd = FSInd & ((Vol[k][i] < 0.01) | (Vol[k][i] > m_LowVolumeThreshold));
- FSInd = FSInd & ((Vol[k][npars - 1] < 0.01) | (Vol[k][npars - 1] > m_LightInksThr));
+ FSInd = FSInd & ((Vol_nlcm[k][i] < 0.01) | (Vol_nlcm[k][i] > low[k]));
+ FSInd = FSInd & (Vol_nlcm[k][npars - 1] < 0.01) | (Vol_nlcm[k][npars - 1] > high[k]);
FSInd = FSInd & (dECMC[k] < 0.5);
if (FSInd)
{
@@ -5909,24 +5931,18 @@ void Tango::ColorLib::ColorConverter::DirectInversionCalc(double *LabIn, VectorX
else
{
//There are no feasible solutions
- //Eliminate all solutions that have a K lower then the uniformity threshold
+ //Eliminate all solutions that have a K lower than the uniformity threshold
//Sacrifiicing accuracy to uniformity
-
for (i = 0; i < nk; ++i)
{
- /* if ((Vol[i][kComponent] > m_LightInksThr) | (Vol[i][kComponent] < 0.01))
+ if ((Vol_nlcm[i][kComponent] > high[i]) | (Vol_nlcm[i][kComponent] < 0.01))
{
if (dECMC[i] < minVal)
{
minVal = dECMC[i];
minInd = i;
}
- } */ //waiting for Program decision Mirta October 27, 2022
- if (dECMC[i] < minVal)
- {
- minVal = dECMC[i];
- minInd = i;
- }
+ }
}
if (isBounded[minInd])
InGamut = false;
@@ -5972,6 +5988,10 @@ void Tango::ColorLib::ColorConverter::DirectInversionCalc(double *LabIn, VectorX
freeVec <double>(LabOutFinal);
freeVec <int>(FeasibleSolutionsInd);
freeVec <bool> (isBounded);
+ freeVec <double>(low);
+ freeVec <double>(high);
+ freeVec <double>(TotalVolume);
+ freeDP <double>(Vol_nlcm, nk);
/* if (RGBOutP != NULL)
{
delete[] RGBOutP;
@@ -6130,11 +6150,6 @@ void Tango::ColorLib::ColorConverter::LimitInksPercentage(VectorXd inInks, Vecto
isBounded = true;
}
freeVec < double >(BoundedInks);
-/* if (BoundedInks != NULL)
- {
- delete[] BoundedInks;
- BoundedInks = NULL;
- }*/
}
void Tango::ColorLib::ColorConverter::LimitNLInks2Volume(VectorXd &NLInks, int &GamutRegion, VectorXd &Volume, int CTUnits,
@@ -6433,6 +6448,7 @@ void Tango::ColorLib::ColorConverter::DirectInversionCalcSIter(double Black, dou
}
for (i = 0; i < npars; ++i)
Vol[i] = VolumeTmp(i);
+ VectorToDouble(InkOut, SolVector);
freeVec <double>(InitCMY);
freeVec <double>(ValK);