aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Native
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-03-18 10:38:56 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-03-18 10:38:56 +0200
commit1b0cc929b5641c58faf5830ec70d3dec4030b1fd (patch)
tree055b3cc8a49eb44ab43349516b72ec349ba2b7fc /Software/Visual_Studio/Native
parentc1bd7fc6d742ce7e1ba1b7a6ce345fb1bd3dd5fa (diff)
downloadTango-1b0cc929b5641c58faf5830ec70d3dec4030b1fd.tar.gz
Tango-1b0cc929b5641c58faf5830ec70d3dec4030b1fd.zip
Fixed issue with gradient generation.
Added SingleMode to conversion Input. Changed default gradient resolution to 50 cm. Updated latest PMR.
Diffstat (limited to 'Software/Visual_Studio/Native')
-rw-r--r--Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp522
-rw-r--r--Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.c19
-rw-r--r--Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.h4
3 files changed, 280 insertions, 265 deletions
diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp
index e99a56d26..d08e851c0 100644
--- a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp
+++ b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp
@@ -22,8 +22,8 @@
#include <sstream>
//#include <vld.h>
-/*#define _CRTDBG_MAP_ALLOC
-#include <stdlib.h>
+/*#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
#include <crtdbg.h>
#include <cstdlib>
@@ -51,7 +51,7 @@
Tango::ColorLib::ColorConverter::ColorConverter() :m_A2BTransform(NULL), m_B2ATransform(NULL),
-m_GBD(NULL), m_CalibCurves(NULL), m_Conv02(NULL),
+m_GBD(NULL), m_CalibCurves(NULL), m_Conv02(NULL),
m_maxNlPerCM(NULL), m_nA2BnSepIn(0), m_nA2BnSepOut(0), m_nB2AnSepIn(0), m_nB2AnSepOut(0),
m_nInks(0), m_nVolumes(0), m_AdaptWP(false), m_LinInterp(NULL), m_InvLinInterp(NULL)
{
@@ -90,12 +90,12 @@ Tango::ColorLib::ColorConverter::~ColorConverter()
}
if (m_LinInterp != NULL)
{
- delete [] m_LinInterp;
+ delete[] m_LinInterp;
m_LinInterp = NULL;
}
if (m_InvLinInterp != NULL)
{
- delete [] m_InvLinInterp;
+ delete[] m_InvLinInterp;
m_InvLinInterp = NULL;
}
}
@@ -125,17 +125,17 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX
for (int i = 0; i < 6; ++i)
{
Jab1(i, 0) = Jab(0);
- Jab1(i, 1) = Jab(1) + dC*cos(hue + i*dH6);
- Jab1(i, 2) = Jab(2) + dC*sin(hue + i*dH6);
+ Jab1(i, 1) = Jab(1) + dC * cos(hue + i * dH6);
+ Jab1(i, 2) = Jab(2) + dC * sin(hue + i * dH6);
}
int j1 = 0, j2 = 0;
- double dC2 = dC*2.0;
+ double dC2 = dC * 2.0;
for (int i = 0; i < 12; ++i)
{
j1 = i + 6;
Jab1(j1, 0) = Jab(0);
- Jab1(j1, 1) = Jab(1) + dC2*cos(hue + i*dH12);
- Jab1(j1, 2) = Jab(2) + dC2*sin(hue + i*dH12);
+ Jab1(j1, 1) = Jab(1) + dC2 * cos(hue + i * dH12);
+ Jab1(j1, 2) = Jab(2) + dC2 * sin(hue + i * dH12);
}
/* for (int i = 0; i < 2; ++i)
{
@@ -165,14 +165,14 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX
//double *tmpRGB = DBG_NEW double[3];
double *InkOut = new double[m_nInks];
//double *InkOut = DBG_NEW double[m_nInks];
-
+
int *GamutRegion = new int[nHive + 1];
//int *GamutRegion = DBG_NEW int[nHive + 1];
double *Lab1P = new double[3];
//double *Lab1P = DBG_NEW double[3];
VectorXd Vol(m_nVolumes);
int j = 0;
- double * LabInFinal1= new double[3];
+ double * LabInFinal1 = new double[3];
//double * LabInFinal1 = DBG_NEW double[3];
double * LabInFinal2; //= new double[3];
for (int i = 0; i < nHive; ++i)
@@ -199,7 +199,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX
if (m_AdaptWP)
{
//Convert to Strip whitepoint
- m_Conv02->ChangeWP(LabInFinal2, LabInFinal2, m_whitepointXYZ_Strip, m_whitepointXYZ_CT);
+ m_Conv02->ChangeWP(LabInFinal2, LabInFinal2, m_whitepointXYZ_Strip, m_whitepointXYZ_CT);
}
m_Conv02->SetReferenceWhite(D65);
//Convert to RGB
@@ -268,7 +268,7 @@ void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorX
void Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1, int nHive, int*indDataMax)
{
- int vecSize = nHive*(nHive - 1) / 2;
+ int vecSize = nHive * (nHive - 1) / 2;
double *dECMC = new double[vecSize];
//double *dECMC = DBG_NEW double[vecSize];
int i, j;
@@ -278,13 +278,13 @@ void Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1,
//int **indexpairs = DBG_NEW int*[vecSize];
for (i = 0; i < vecSize; ++i)
indexpairs[i] = new int[2];
- //indexpairs[i] = DBG_NEW int[2];
+ //indexpairs[i] = DBG_NEW int[2];
int ind = -1;
ColorConvert ColConv(D65, D65);
VectorXd Labi(3);
VectorXd Labj(3);
-
+
for (i = 0; i < nHive; ++i)
{
Labi << Lab1(i, 0), Lab1(i, 1), Lab1(i, 2);
@@ -394,16 +394,16 @@ void Tango::ColorLib::ColorConverter::fillRGB(OutputCoordinates *outputCoords, V
void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* conversionInput)
{
//Read thread white. Thread White is given in CIELab Space
-
- m_whitepointLab.Set(conversionInput->threadl, conversionInput->threada, conversionInput->threadb);
- //White point in XYZ Color Space
- ColorConvert CConvert(D65, D65);
- C_RGB_XYZ_Lab tmpW;
- tmpW = CConvert.LabToXYZ(m_whitepointLab);
- m_whitepointXYZ_Strip.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z());
+
+ m_whitepointLab.Set(conversionInput->threadl, conversionInput->threada, conversionInput->threadb);
+ //White point in XYZ Color Space
+ ColorConvert CConvert(D65, D65);
+ C_RGB_XYZ_Lab tmpW;
+ tmpW = CConvert.LabToXYZ(m_whitepointLab);
+ m_whitepointXYZ_Strip.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z());
+
-
//parse Color Tansformations, placed in forward data
int bytesread = 0;
NumConversions conv;
@@ -570,9 +570,9 @@ void Tango::ColorLib::ColorConverter::readCalibrationTables(ConversionInput* con
for (int i = 0; i < m_nInks; ++i)
{
InputLiquid* InkType = conversionInput->inputcoordinates->inputliquids[i];
-
+
m_CalibCurves[i].SetCalibName((int)(InkType->calibrationdata->liquidtype));
-
+
m_CalibCurves[i].SetMaxNlPerCM(conversionInput->inputcoordinates->inputliquids[i]->maxnanoliterpercentimeter);
switch (InkType->calibrationdata->liquidtype)
{
@@ -669,11 +669,11 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
//double *RGBOutP = DBG_NEW double[3];
VectorToDouble(RGBOut, RGBOutP);
//RGB to Lab
- CConvertD65.RGBtoLab(RGBOutP, LabIn); //Values are in Relative Colorimetric, D65
+ CConvertD65.RGBtoLab(RGBOutP, LabIn); //Values are in Relative Colorimetric, D65
double *LabInFinal = new double[3];
//double *LabInFinal = DBG_NEW double[3];
- memcpy(LabInFinal , LabIn, 3*sizeof(double));
+ memcpy(LabInFinal, LabIn, 3 * sizeof(double));
//Is In Gamut?
InGamut = IsInGamut(LabIn, sur);
//convert to inks
@@ -716,22 +716,22 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
}
if (LabIn != NULL)
{
- delete [] LabIn;
+ delete[] LabIn;
LabIn = NULL;
}
if (RGBOutP != NULL)
{
- delete [] RGBOutP;
+ delete[] RGBOutP;
RGBOutP = NULL;
}
if (RGBOutP1 != NULL)
{
- delete [] RGBOutP1;
+ delete[] RGBOutP1;
RGBOutP1 = NULL;
}
if (LabInFinal != NULL)
{
- delete [] LabInFinal;
+ delete[] LabInFinal;
LabInFinal = NULL;
}
break;
@@ -754,7 +754,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
ColorConvert CConvertD65(D65, D65); //Destination, source
double *LabInFinal1 = new double[3];
//double *LabInFinal1 = DBG_NEW double[3];
- memcpy(LabInFinal1, LabIn, 3*sizeof(double));
+ memcpy(LabInFinal1, LabIn, 3 * sizeof(double));
//LabInFinal1 = LabIn;
// Lab is assumed to match the color of the STRIP, however the tables could have a different WP
//Check if Color Tables and Strip whitepoints are the same, otherwise convert
@@ -778,7 +778,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
InkOut = DoubleToVector(InkOutP, m_nInks);
double *LabOutFinal = new double[3];
//double *LabOutFinal = DBG_NEW double[3];
- memcpy(LabOutFinal , LabIn, 3*sizeof(double));
+ memcpy(LabOutFinal, LabIn, 3 * sizeof(double));
//LabOutFinal is in Relative Colorimetric
//Reverse the conversion process to bring back Lab to STRIP white point
CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_CT, m_WP);
@@ -788,7 +788,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
}
CConvertD65.SetReferenceWhite(D65);
//Convert to RGB
- double *RGBOutP = new double[3];
+ double *RGBOutP = new double[3];
// double *RGBOutP = DBG_NEW double[3];
//CConvertD65.LabtoRGB(LabOutFinal, RGBOutP);
CConvertD65.LabtoRGB(LabIn, RGBOutP);
@@ -825,7 +825,7 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
delete[] RGBOutP;
RGBOutP = NULL;
}
- break;
+ break;
}
case(COLOR_SPACE__CMYK):
@@ -839,8 +839,8 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
outData[1] = (double)(conversionInput->inputcoordinates->magenta);
outData[2] = (double)(conversionInput->inputcoordinates->yellow);
outData[3] = conversionInput->inputcoordinates->key;
- CountSep=4;
-
+ CountSep = 4;
+
if (CountSep != m_nA2BnSepIn)
{
//mismatch between table and sent data
@@ -881,10 +881,10 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
//CConvertD65.LabtoRGB(LabOutFinal1, RGBOutP);
CConvertD65.LabtoRGB(LabOutP, RGBOutP);
RGBOut = DoubleToVector(RGBOutP, 3);
-
+
if (outData != NULL)
{
- delete[] outData;
+ delete[] outData;
outData = NULL;
}
if (LabOutP != NULL)
@@ -904,17 +904,17 @@ void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput*
}
if (LabOutFinal1 != NULL)
{
- delete [] LabOutFinal1;
+ delete[] LabOutFinal1;
LabOutFinal1 = NULL;
}
if (LabOutFinal2 != NULL)
{
- delete [] LabOutFinal2;
+ delete[] LabOutFinal2;
LabOutFinal2 = NULL;
}
if (RGBOutP != NULL)
{
- delete [] RGBOutP;
+ delete[] RGBOutP;
RGBOutP = NULL;
}
break;
@@ -1014,7 +1014,7 @@ void Tango::ColorLib::ColorConverter::VolumeToNLInkP(VectorXd Volume, VectorXd &
//Solve System of Linear Equations
MatrixXd MatNLIInv(m_nVolumes - 1, m_nVolumes - 1);
MatNLIInv = MatNLI.inverse();
- VectorXd Result = MatNLIInv*RHSide;
+ VectorXd Result = MatNLIInv * RHSide;
//VectorXd Result = MatNLI.colPivHouseholderQr().solve(RHSide);
//rearrange solution
ind = -1;
@@ -1049,13 +1049,13 @@ void Tango::ColorLib::ColorConverter::NLInkPToVolume(VectorXd NLInk, VectorXd &V
{
for (i = 0; i < m_nInks; ++i)
{
- InkNorm(i) = MaxInk*NLInk(i) / InkSum;
+ InkNorm(i) = MaxInk * NLInk(i) / InkSum;
Volume(i) = InkNorm(i); // InkNorm(i) * m_maxNlPerCM(i) / 100; // Volume is in %
}
// Round to k decimal digits, verify that sum in within allowed values.
double sumNorm = 0.0;
double RsumNorm = 0.0;
- VectorXd RVolNorm(m_nInks);
+ VectorXd RVolNorm(m_nInks);
double ROUNDINGTol = pow(10, ROUNDINGDigits);
for (i = 0; i < m_nInks; ++i)
@@ -1102,7 +1102,7 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInput*
// Set Calibration Data
LiquidType LQ;
if (m_CalibCurves == NULL)
- {
+ {
m_CalibCurves = new CalibData[m_nInks];
//m_CalibCurves = DBG_NEW CalibData[m_nInks];
for (int i = 0; i < m_nVolumes; ++i)
@@ -1150,13 +1150,13 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInput*
LabOutFinal = LabOutFinal1;
if (m_AdaptWP)
{
- CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT);
+ CConvertD65.ChangeWP(LabOutFinal, LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT);
}
CConvertD65.SetReferenceWhite(D65);
double *RGBOutP = new double[3];
//double *RGBOutP = DBG_NEW double[3];
//CConvertD65.LabtoRGB(LabOutFinal, RGBOutP);
- CConvertD65.LabtoRGB(LabOutP, RGBOutP);
+ CConvertD65.LabtoRGB(LabOutP, RGBOutP);
for (int i = 0; i < 3; ++i)
{
RGBOut(i) = RGBOutP[i];
@@ -1175,12 +1175,12 @@ void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInput*
}
if (RGBOutP != NULL)
{
- delete [] RGBOutP;
+ delete[] RGBOutP;
RGBOutP = NULL;
}
if (LabOutFinal1 != NULL)
{
- delete [] LabOutFinal1;
+ delete[] LabOutFinal1;
LabOutFinal1 = NULL;
}
return;
@@ -1218,9 +1218,9 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i
//Filter and arrange colors (Should change from 3 to 4 if black ink is included)
-
+
int numofInks = CountNumberofInks(conversionInput);
- if(numofInks <0)
+ if (numofInks < 0)
throw std::exception("Duplicate inks");
int expected_liquids = numofInks;
original_input_liquids_count = conversionInput->inputcoordinates->n_inputliquids;
@@ -1268,32 +1268,32 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i
// int numofInks = CountNumberofInks(conversionInput);
readColorTransformations(conversionInput);
- //read calibration tables and store them in m_CalibCurves
-
- readCalibrationTables(conversionInput);
- m_LinInterp = new Interp[numofInks];
- //m_LinInterp = DBG_NEW Interp[numofInks];
- m_InvLinInterp = new Interp[numofInks];
- //m_InvLinInterp = DBG_NEW Interp[numofInks];
- InitInterpolations(numofInks, m_LinInterp, m_InvLinInterp);
+ //read calibration tables and store them in m_CalibCurves
- //Initialize CIECAM02 transformation
- Illum IL = D65;
- SURROUND sur = average;
- CAM02CS CS = UCS;
- m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS);
- //m_Conv02 = DBG_NEW ColorConvert(IL, IL, Y_b, L_A, sur, CS);
- SetnA2BnSepIn(m_A2BTransform->GetSeparationsIn());
- SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut());
- SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn());
- SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut());
-
- SetNumberOfInks(m_nB2AnSepOut);
- // Compare Strip White point to Color Table White Point
- CompareWhitePoints();
+ readCalibrationTables(conversionInput);
+ m_LinInterp = new Interp[numofInks];
+ //m_LinInterp = DBG_NEW Interp[numofInks];
+ m_InvLinInterp = new Interp[numofInks];
+ //m_InvLinInterp = DBG_NEW Interp[numofInks];
+ InitInterpolations(numofInks, m_LinInterp, m_InvLinInterp);
- if (numofInks != m_nB2AnSepOut)
- throw std::exception("Number of available inks does not match ink tables");
+ //Initialize CIECAM02 transformation
+ Illum IL = D65;
+ SURROUND sur = average;
+ CAM02CS CS = UCS;
+ m_Conv02 = new ColorConvert(IL, IL, Y_b, L_A, sur, CS);
+ //m_Conv02 = DBG_NEW ColorConvert(IL, IL, Y_b, L_A, sur, CS);
+ SetnA2BnSepIn(m_A2BTransform->GetSeparationsIn());
+ SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut());
+ SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn());
+ SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut());
+
+ SetNumberOfInks(m_nB2AnSepOut);
+ // Compare Strip White point to Color Table White Point
+ CompareWhitePoints();
+
+ if (numofInks != m_nB2AnSepOut)
+ throw std::exception("Number of available inks does not match ink tables");
VectorXd InkOut(m_nB2AnSepOut);
VectorXd RGBOut(3);
@@ -1332,86 +1332,88 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i
conversionOutput->singlecoordinates = outputCoords;
- //input was processed.
- //process neighboring values
- //nhive includes 2 outer neighbors of the central Lab value, chroma + delta, chroma + 2delta
- // and variation in L positioned on the side of the beehive.
- //The set is arrange in a 5x6 matrix, where the 5x5 contains the variation in (Hue, chroma)
- // and the last 5 contain the variation in L
- int nHive = 18; //22; // 18;
- int MatHive = 25;// 30; //25;
+ if (!conversionInput->singlemode) //Skip if input requests single result only.
+ {
+ //input was processed.
+ //process neighboring values
+ //nhive includes 2 outer neighbors of the central Lab value, chroma + delta, chroma + 2delta
+ // and variation in L positioned on the side of the beehive.
+ //The set is arrange in a 5x6 matrix, where the 5x5 contains the variation in (Hue, chroma)
+ // and the last 5 contain the variation in L
+ int nHive = 18; //22; // 18;
+ int MatHive = 25;// 30; //25;
- MatrixXd RGBHive(MatHive, 3);
- VectorXd RGBHive1(3);
- VectorXd VolumeHive1(m_nVolumes);
- MatrixXd VolumeHive(MatHive, m_nVolumes);
- int *GamutRegionV = new int[MatHive];
- //int *GamutRegionV = DBG_NEW int[MatHive];
- for (int i = 0; i < MatHive ; ++i)
- GamutRegionV[i] = -1;
+ MatrixXd RGBHive(MatHive, 3);
+ VectorXd RGBHive1(3);
+ VectorXd VolumeHive1(m_nVolumes);
+ MatrixXd VolumeHive(MatHive, m_nVolumes);
+ int *GamutRegionV = new int[MatHive];
+ //int *GamutRegionV = DBG_NEW int[MatHive];
+ for (int i = 0; i < MatHive; ++i)
+ GamutRegionV[i] = -1;
- int indDataMax[2];
- int j = 0;
- // Matrix values are initially set to -1;
- RGBHive.setConstant(NegValue);
- VolumeHive.setConstant(NegValue);
-
- ProcessHiveNeighbors(LabOut, RGBOut, Volume, GamutRegion, RGBHive, VolumeHive, nHive, GamutRegionV, indDataMax);
- OutputCoordinates** hiveData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * MatHive);
- conversionOutput->hivecoordinates = hiveData;
- conversionOutput->n_hivecoordinates = MatHive;
- conversionOutput->n_triplecoordinates = 3;
- for (int i = 0; i < MatHive; i++)
- {
- // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT;
- hiveData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates));
- output_coordinates__init(hiveData[i]);
- if (RGBHive(i, 0) != NegValue)
- {
- for (j = 0; j < 3; ++j)
- RGBHive1(j) = RGBHive(i, j);
- fillRGB(hiveData[i], RGBHive1);
- for (j = 0; j < m_nVolumes; ++j)
- VolumeHive1(j) = VolumeHive(i, j);
- fillVolume(hiveData[i], VolumeHive1);
- hiveData[i]->has_processparameterstableindex = true;
- hiveData[i]->processparameterstableindex = GamutRegionV[i];
- hiveData[i]->n_outputliquids = m_nInks;
- }
- conversionOutput->hivecoordinates[i] = hiveData[i];
- }
+ int indDataMax[2];
+ int j = 0;
+ // Matrix values are initially set to -1;
+ RGBHive.setConstant(NegValue);
+ VolumeHive.setConstant(NegValue);
+ ProcessHiveNeighbors(LabOut, RGBOut, Volume, GamutRegion, RGBHive, VolumeHive, nHive, GamutRegionV, indDataMax);
+ OutputCoordinates** hiveData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * MatHive);
+ conversionOutput->hivecoordinates = hiveData;
+ conversionOutput->n_hivecoordinates = MatHive;
+ conversionOutput->n_triplecoordinates = 3;
+ for (int i = 0; i < MatHive; i++)
+ {
+ // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT;
+ hiveData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates));
+ output_coordinates__init(hiveData[i]);
+ if (RGBHive(i, 0) != NegValue)
+ {
+ for (j = 0; j < 3; ++j)
+ RGBHive1(j) = RGBHive(i, j);
+ fillRGB(hiveData[i], RGBHive1);
+ for (j = 0; j < m_nVolumes; ++j)
+ VolumeHive1(j) = VolumeHive(i, j);
+ fillVolume(hiveData[i], VolumeHive1);
+ hiveData[i]->has_processparameterstableindex = true;
+ hiveData[i]->processparameterstableindex = GamutRegionV[i];
+ hiveData[i]->n_outputliquids = m_nInks;
+ }
+ conversionOutput->hivecoordinates[i] = hiveData[i];
+ }
- //Triplet
- OutputCoordinates** TripletData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * 3);
- conversionOutput->triplecoordinates = TripletData;
- int tripletIndex[3] = { indDataMax[0] , (int)(12), indDataMax[1] };
- for (int i = 0; i < 3; ++i)
- {
- // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT;
- TripletData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates));
- output_coordinates__init(TripletData[i]);
- for (j = 0; j < 3; ++j)
- RGBHive1(j) = RGBHive(tripletIndex[i], j);
- fillRGB(TripletData[i], RGBHive1);
- for (j = 0; j < m_nVolumes; ++j)
- VolumeHive1(j) = VolumeHive(tripletIndex[i], j);
- fillVolume(TripletData[i], VolumeHive1);
- TripletData[i]->has_processparameterstableindex = true;
- TripletData[i]->processparameterstableindex = GamutRegionV[tripletIndex[i]];
- TripletData[i]->n_outputliquids = m_nInks;
- conversionOutput->triplecoordinates[i] = TripletData[i];
- }
- //Clean up
- if (GamutRegionV != NULL)
- {
- delete [] GamutRegionV;
- GamutRegionV = NULL;
- }
+ //Triplet
+ OutputCoordinates** TripletData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * 3);
+ conversionOutput->triplecoordinates = TripletData;
+ int tripletIndex[3] = { indDataMax[0] , (int)(12), indDataMax[1] };
+ for (int i = 0; i < 3; ++i)
+ {
+ // OutputCoordinates SingleCell = OUTPUT_COORDINATES__INIT;
+ TripletData[i] = (OutputCoordinates*)malloc(sizeof(OutputCoordinates));
+ output_coordinates__init(TripletData[i]);
+ for (j = 0; j < 3; ++j)
+ RGBHive1(j) = RGBHive(tripletIndex[i], j);
+ fillRGB(TripletData[i], RGBHive1);
+ for (j = 0; j < m_nVolumes; ++j)
+ VolumeHive1(j) = VolumeHive(tripletIndex[i], j);
+ fillVolume(TripletData[i], VolumeHive1);
+ TripletData[i]->has_processparameterstableindex = true;
+ TripletData[i]->processparameterstableindex = GamutRegionV[tripletIndex[i]];
+ TripletData[i]->n_outputliquids = m_nInks;
+ conversionOutput->triplecoordinates[i] = TripletData[i];
+ }
+ //Clean up
+ if (GamutRegionV != NULL)
+ {
+ delete[] GamutRegionV;
+ GamutRegionV = NULL;
+ }
+ }
- //Pack output...
+ //Pack output...
output_buffer = (uint8_t*)malloc(conversion_output__get_packed_size(conversionOutput));
int size = conversion_output__pack(conversionOutput, output_buffer);
@@ -1437,7 +1439,7 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i
conversionOutput->has_haserror = true;
conversionOutput->haserror = true;
- const char* what = e.what();
+ const char* what = e.what();
conversionOutput->errormessage = (char*)malloc(strlen(what));
strcpy(conversionOutput->errormessage, e.what());
@@ -1458,13 +1460,11 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i
}
}
-
-
void Tango::ColorLib::ColorConverter::InitInterpolations(int numofInks, Interp *linearInterp, Interp *InvLinearInterp)
{
double *xCoords;
double *yCoords;
-
+
for (int i = 0; i < numofInks; ++i)
{
xCoords = m_CalibCurves[i].getxCoords();
@@ -1534,7 +1534,7 @@ int Tango::ColorLib::ColorConverter::CountNumberofInks(ConversionInput* conversi
bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur)
{
- int nInLab =3;
+ int nInLab = 3;
double *xCoord = new double[nInLab];
//double *xCoord = DBG_NEW double[nInLab];
//Convert InLab to CIECam02 coordinates
@@ -1557,7 +1557,7 @@ bool Tango::ColorLib::ColorConverter::IsInGamut(double *InLab, SURROUND sur)
VectorXd V1(3);
VectorXd V2(3);
V1 << JLab[0], JLab[1], JLab[2];
- V2<< xCoord[0], xCoord[1], xCoord[2];
+ V2 << xCoord[0], xCoord[1], xCoord[2];
double dECMC;
m_Conv02->SymmetricaldECMC(V1, V2, dECMC);
if (dECMC < dETol)
@@ -1602,12 +1602,12 @@ Tango::CT_Header Tango::ColorLib::ColorConverter::read_header(ConversionInput* c
Header.Version[2] = versionBCT[1] & 15;
bytesread += 1;
uint32_t tmp = Conv.ByteToInt(ColorTable, bytesread);
- int n = sizeof((char*)&tmp);
+ int n = sizeof((char*)&tmp);
//char *tmpC = DBG_NEW char[n];
char *tmpC = new char[n];
- Conv.getchar(tmp, n, tmpC);
+ Conv.getchar(tmp, n, tmpC);
//Header.ColorSpace = DBG_NEW char[n];
- Header.ColorSpace = new char[n];
+ Header.ColorSpace = new char[n];
memcpy_s(Header.ColorSpace, n + 1, tmpC, n);
// strncpy_s(Header->ColorSpace, n+1, tmpC, n);
//Header->ColorSpace = tmpC;
@@ -1625,8 +1625,8 @@ Tango::CT_Header Tango::ColorLib::ColorConverter::read_header(ConversionInput* c
//Header.DeviceManufacturer = DBG_NEW char[n];
Header.DeviceManufacturer = new char[n];
memcpy_s(Header.DeviceManufacturer, n + 1, tmpC, n);
-// strncpy_s(Header->DeviceManufacturer, n + 1, tmpC, n);
- //Header->DeviceManufacturer = tmpC;
+ // strncpy_s(Header->DeviceManufacturer, n + 1, tmpC, n);
+ //Header->DeviceManufacturer = tmpC;
delete[]tmpC;
bytesread += 4;
//read illuminant
@@ -1689,7 +1689,7 @@ void Tango::ColorLib::ColorConverter::read_xyz_type(int offset, int data_size, C
NumConversions Conv;
int bytesread = 0;
int tmpxyz = Conv.ByteToInt(buff, bytesread);
-
+
int n = sizeof(tmpxyz);
//char* tmpC = DBG_NEW char[n];
char* tmpC = new char[n];
@@ -2042,7 +2042,7 @@ size_t Tango::ColorLib::ColorConverter::P_IsInGamut(uint8_t * input_buffer, size
//read calibration tables and store them in m_CalibCurves
readCalibrationTables(conversionInput);
-
+
//Initialize CIECAM02 transformation
Illum IL = D65;
SURROUND sur = average;
@@ -2066,120 +2066,120 @@ size_t Tango::ColorLib::ColorConverter::P_IsInGamut(uint8_t * input_buffer, size
VectorXd LabOut(3);
VectorXd NLInkOut(m_nB2AnSepOut);
VectorXd Volume(m_nB2AnSepOut);
-
+
C_RGB_XYZ_Lab DataLab;
//SURROUND sur = m_Conv02->getSurround();
switch (conversionInput->colorspace)
{
case (COLOR_SPACE__RGB):
{
- // Basic assumption: if data is given in RGB space, conversion should be in relative colorimetric,
- //We expect that [255,255,255](white) will be mapped to the thread white, meaning all inks should be zero
- // and the coverted RGB will refect the color of the thread
- //The workflow is a follows:
- //1. Convert RGB to Lab (Whitepoint is D65, same as tables)
- //2.Fiond if Lab is InGamut
-
- RGBOut(0) = conversionInput->inputcoordinates->red;
- RGBOut(1) = conversionInput->inputcoordinates->green;
- RGBOut(2) = conversionInput->inputcoordinates->blue;
- //convert to Lab
- ColorConvert CConvertD65(D65, D65); //Destination, source
- //double *LabIn = DBG_NEW double[3];
- //double *RGBOutP = DBG_NEW double[3];
- double *LabIn = new double[3];
- double *RGBOutP = new double[3];
- VectorToDouble(RGBOut, RGBOutP);
- //RGB to Lab
- CConvertD65.RGBtoLab(RGBOutP, LabIn); //Values are in Relative Colorimetric, D65
-
- //Is In Gamut?
- InGamut = IsInGamut(LabIn, sur);
-
- if (LabIn != NULL)
- {
- delete [] LabIn;
- LabIn = NULL;
- }
- if (RGBOutP != NULL)
- {
- delete [] RGBOutP;
- RGBOutP = NULL;
- }
- break;
+ // Basic assumption: if data is given in RGB space, conversion should be in relative colorimetric,
+ //We expect that [255,255,255](white) will be mapped to the thread white, meaning all inks should be zero
+ // and the coverted RGB will refect the color of the thread
+ //The workflow is a follows:
+ //1. Convert RGB to Lab (Whitepoint is D65, same as tables)
+ //2.Fiond if Lab is InGamut
+
+ RGBOut(0) = conversionInput->inputcoordinates->red;
+ RGBOut(1) = conversionInput->inputcoordinates->green;
+ RGBOut(2) = conversionInput->inputcoordinates->blue;
+ //convert to Lab
+ ColorConvert CConvertD65(D65, D65); //Destination, source
+ //double *LabIn = DBG_NEW double[3];
+ //double *RGBOutP = DBG_NEW double[3];
+ double *LabIn = new double[3];
+ double *RGBOutP = new double[3];
+ VectorToDouble(RGBOut, RGBOutP);
+ //RGB to Lab
+ CConvertD65.RGBtoLab(RGBOutP, LabIn); //Values are in Relative Colorimetric, D65
+
+ //Is In Gamut?
+ InGamut = IsInGamut(LabIn, sur);
+
+ if (LabIn != NULL)
+ {
+ delete[] LabIn;
+ LabIn = NULL;
}
- case (COLOR_SPACE__LAB):
+ if (RGBOutP != NULL)
{
- // Basic assumption: Lab data has the same whitepoint as the STRIP thread.
- //The workflow is a follows:
- //1. Convert Lab to Relative colorimetric. check if there is a match between STRIP and Color Tables
- //2. Find if Lab is InGamut
+ delete[] RGBOutP;
+ RGBOutP = NULL;
+ }
+ break;
+ }
+ case (COLOR_SPACE__LAB):
+ {
+ // Basic assumption: Lab data has the same whitepoint as the STRIP thread.
+ //The workflow is a follows:
+ //1. Convert Lab to Relative colorimetric. check if there is a match between STRIP and Color Tables
+ //2. Find if Lab is InGamut
- double *LabIn = new double[3];
- //double *LabIn = DBG_NEW double[3];
- LabIn[0] = conversionInput->inputcoordinates->l;
- LabIn[1] = conversionInput->inputcoordinates->a;
- LabIn[2] = conversionInput->inputcoordinates->b;
- //the assumption is that the color space has illumination that matches the whitepoint of the Strip
- ColorConvert CConvertD65(D65, D65); //Destination, source
- double *LabInFinal1 = new double[3];
- //double *LabInFinal1 = DBG_NEW double[3];
- memcpy(LabInFinal1, LabIn, 3*sizeof(double));
- // Lab is assumed to match the color of the STRIP, however the tables could have a different WP
- //Check if Color Tables and Strip whitepoints are the same, otherwise convert
- if (m_AdaptWP)
- {
- CConvertD65.ChangeWP(LabInFinal1, LabInFinal1, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); //to Color Tables
- LabIn = LabInFinal1;
- }
- double *LabInFinal2 = new double[3];
- //double *LabInFinal2 = DBG_NEW double[3];
- CConvertD65.ChangeWP(LabIn, LabInFinal2, m_WP, m_whitepointXYZ_CT); //to Relative
- InGamut = IsInGamut(LabInFinal2, sur);
-
- if (LabIn != NULL)
- {
- delete[] LabIn;
- LabIn = NULL;
- }
- if (LabInFinal1 != NULL)
- {
- delete[]LabInFinal1;
- LabInFinal1 = NULL;
- }
- if (LabInFinal2 != NULL)
- {
- delete[]LabInFinal2;
- LabInFinal2 = NULL;
- }
- break;
+ double *LabIn = new double[3];
+ //double *LabIn = DBG_NEW double[3];
+ LabIn[0] = conversionInput->inputcoordinates->l;
+ LabIn[1] = conversionInput->inputcoordinates->a;
+ LabIn[2] = conversionInput->inputcoordinates->b;
+ //the assumption is that the color space has illumination that matches the whitepoint of the Strip
+ ColorConvert CConvertD65(D65, D65); //Destination, source
+ double *LabInFinal1 = new double[3];
+ //double *LabInFinal1 = DBG_NEW double[3];
+ memcpy(LabInFinal1, LabIn, 3 * sizeof(double));
+ // Lab is assumed to match the color of the STRIP, however the tables could have a different WP
+ //Check if Color Tables and Strip whitepoints are the same, otherwise convert
+ if (m_AdaptWP)
+ {
+ CConvertD65.ChangeWP(LabInFinal1, LabInFinal1, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); //to Color Tables
+ LabIn = LabInFinal1;
}
- case(COLOR_SPACE__CMYK):
- {//no conversion
- //missing from structure light inks or special colors
- // just convert Lab for rgb display
- InGamut = true;
+ double *LabInFinal2 = new double[3];
+ //double *LabInFinal2 = DBG_NEW double[3];
+ CConvertD65.ChangeWP(LabIn, LabInFinal2, m_WP, m_whitepointXYZ_CT); //to Relative
+ InGamut = IsInGamut(LabInFinal2, sur);
+
+ if (LabIn != NULL)
+ {
+ delete[] LabIn;
+ LabIn = NULL;
}
- case(COLOR_SPACE__PANTON):
+ if (LabInFinal1 != NULL)
{
- int32_t inData;
- if (conversionInput->inputcoordinates->has_pantoncode)
- inData = conversionInput->inputcoordinates->pantoncode;
- else
- {
- //mismatch between color space and data
- throw std::exception("Mismatch between color space and data");
- return(0);
- }
- break;
- //missing calclulation method and pantone table, either in terms of RGB or CMY or Lab
+ delete[]LabInFinal1;
+ LabInFinal1 = NULL;
}
- default:
+ if (LabInFinal2 != NULL)
{
- throw std::exception(" Unsupported Color Space");
- return(0);
+ delete[]LabInFinal2;
+ LabInFinal2 = NULL;
}
+ break;
+ }
+ case(COLOR_SPACE__CMYK):
+ {//no conversion
+ //missing from structure light inks or special colors
+ // just convert Lab for rgb display
+ InGamut = true;
+ }
+ case(COLOR_SPACE__PANTON):
+ {
+ int32_t inData;
+ if (conversionInput->inputcoordinates->has_pantoncode)
+ inData = conversionInput->inputcoordinates->pantoncode;
+ else
+ {
+ //mismatch between color space and data
+ throw std::exception("Mismatch between color space and data");
+ return(0);
}
+ break;
+ //missing calclulation method and pantone table, either in terms of RGB or CMY or Lab
+ }
+ default:
+ {
+ throw std::exception(" Unsupported Color Space");
+ return(0);
+ }
+ }
//Pack data
OutputCoordinates *outputCoords = (OutputCoordinates*)malloc(sizeof(OutputCoordinates));
diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.c b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.c
index d71d3ac3b..5c4a964e6 100644
--- a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.c
+++ b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.c
@@ -52,7 +52,7 @@ void conversion_input__free_unpacked
assert(message->base.descriptor == &conversion_input__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
-static const ProtobufCFieldDescriptor conversion_input__field_descriptors[11] =
+static const ProtobufCFieldDescriptor conversion_input__field_descriptors[12] =
{
{
"ThreadL",
@@ -186,6 +186,18 @@ static const ProtobufCFieldDescriptor conversion_input__field_descriptors[11] =
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
+ {
+ "SingleMode",
+ 12,
+ PROTOBUF_C_LABEL_OPTIONAL,
+ PROTOBUF_C_TYPE_BOOL,
+ offsetof(ConversionInput, has_singlemode),
+ offsetof(ConversionInput, singlemode),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
};
static const unsigned conversion_input__field_indices_by_name[] = {
3, /* field[3] = ColorSpace */
@@ -196,6 +208,7 @@ static const unsigned conversion_input__field_indices_by_name[] = {
6, /* field[6] = InverseData */
10, /* field[10] = ProcessRanges */
7, /* field[7] = SegmentLength */
+ 11, /* field[11] = SingleMode */
1, /* field[1] = ThreadA */
2, /* field[2] = ThreadB */
0, /* field[0] = ThreadL */
@@ -203,7 +216,7 @@ static const unsigned conversion_input__field_indices_by_name[] = {
static const ProtobufCIntRange conversion_input__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 11 }
+ { 0, 12 }
};
const ProtobufCMessageDescriptor conversion_input__descriptor =
{
@@ -213,7 +226,7 @@ const ProtobufCMessageDescriptor conversion_input__descriptor =
"ConversionInput",
"",
sizeof(ConversionInput),
- 11,
+ 12,
conversion_input__field_descriptors,
conversion_input__field_indices_by_name,
1, conversion_input__number_ranges,
diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.h b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.h
index eac601d16..1dd3b5e85 100644
--- a/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.h
+++ b/Software/Visual_Studio/Native/Tango.ColorLib/PMR/ColorLab/ConversionInput.pb-c.h
@@ -50,10 +50,12 @@ struct _ConversionInput
double deltal;
size_t n_processranges;
ProcessRange **processranges;
+ protobuf_c_boolean has_singlemode;
+ protobuf_c_boolean singlemode;
};
#define CONVERSION_INPUT__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&conversion_input__descriptor) \
- , 0, 0, 0, 0, 0, 0, 0, COLOR_SPACE__Volume, NULL, 0, {0,NULL}, 0, {0,NULL}, 0, 0, 0, 0, 0, 0, 0,NULL }
+ , 0, 0, 0, 0, 0, 0, 0, COLOR_SPACE__Volume, NULL, 0, {0,NULL}, 0, {0,NULL}, 0, 0, 0, 0, 0, 0, 0,NULL, 0, 0 }
/* ConversionInput methods */