diff options
| author | Mirta <mirta@twine-s.com> | 2018-05-27 14:28:19 +0300 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2018-05-27 14:28:19 +0300 |
| commit | aae61aa72d939bee03ea6fd8896bef71e9c09b61 (patch) | |
| tree | 62d185131fca3d2867c3f303870abf342439bb0d /Software/Visual_Studio/Native | |
| parent | 601d959b6d8f84e6a9d2fa64fec92564b980da0d (diff) | |
| download | Tango-aae61aa72d939bee03ea6fd8896bef71e9c09b61.tar.gz Tango-aae61aa72d939bee03ea6fd8896bef71e9c09b61.zip | |
add "throw". Modify absolute colorimetric calculations
Diffstat (limited to 'Software/Visual_Studio/Native')
8 files changed, 258 insertions, 221 deletions
diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp index 4ed93fd1d..b311e0e83 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp +++ b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.cpp @@ -33,7 +33,6 @@ m_CalibCurves(NULL), m_CalibDatasize(NULL), m_maxNlPerCM(NULL), m_nA2BnSepIn(0), m_nA2BnSepOut(0), m_nB2AnSepIn(0), m_nB2AnSepOut(0), m_nInks(0), m_nVolumes(0) { - //// } Tango::ColorLib::ColorConverter::~ColorConverter() @@ -60,7 +59,7 @@ Tango::ColorLib::ColorConverter::~ColorConverter() } } -size_t Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorXd RGB, VectorXd Volume, int InGamutRegion, MatrixXd &ORGBHive, MatrixXd &OVolumeHive, int nHive, int *&OGamutRegion, int *indDataMax) +void Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, VectorXd RGB, VectorXd Volume, int InGamutRegion, MatrixXd &ORGBHive, MatrixXd &OVolumeHive, int nHive, int *&OGamutRegion, int *indDataMax) { size_t retVal = 0; @@ -122,10 +121,9 @@ size_t Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, Vecto VectorXd xyz(3); VectorXd JabTmp(3); C_RGB_XYZ_Lab xyzVal, LabVal; - double *tmpRGB; //= new double[3]; + double *tmpRGB; double *InkOut = new double[m_nInks]; int *GamutRegion = new int[nHive + 2]; - double *LabOutAbs; //= new double[3]; double *Lab1P = new double[3]; VectorXd Vol(m_nVolumes); int j = 0; @@ -144,19 +142,28 @@ size_t Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, Vecto Lab1P[j] = Lab1(i, j); m_B2ATransform->evalLab2InkP(Lab1P, InkOut, GamutRegion[i]); //InkOut is in units of 16 bits m_A2BTransform->evalInkP2Lab(InkOut, Lab1P, GamutRegion[i]); - //Convert to Absolute Colorimetric - LabOutAbs = Conv02->ToAbsoluteLab(Lab1P, m_whitepointXYZ, m_WP); + //Check id whitepoints match + //LabOut is under D65 + double * LabInFinal = Lab1P; + if ((m_whitepointXYZ_Strip.Get_x() != m_whitepointXYZ_CT.Get_x()) || + (m_whitepointXYZ_Strip.Get_y() != m_whitepointXYZ_CT.Get_y()) || + (m_whitepointXYZ_Strip.Get_z() != m_whitepointXYZ_CT.Get_z())) + { + LabInFinal = Conv02->ToAbsoluteLab(LabInFinal, m_WP, m_whitepointXYZ_Strip); + LabInFinal = Conv02->ToAbsoluteLab(LabInFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); + LabInFinal = Conv02->ToAbsoluteLab(LabInFinal, m_whitepointXYZ_CT, m_WP); + } Conv02->SetReferenceWhite(D65); //Convert to RGB - tmpRGB = Conv02->LabtoRGB(LabOutAbs); + tmpRGB = Conv02->LabtoRGB(LabInFinal); for (int j = 0; j < 3; ++j) RGBTmpVec(i, j) = std::min(std::max(tmpRGB[j], 0.0), 255.0); //Use Lab to convert to Linear Inks - m_B2ATransform->evalLab2InkP(LabOutAbs, InkOut, GamutRegion[i]); //InkOut is in units of 16 bits + m_B2ATransform->evalLab2InkP(LabInFinal, InkOut, GamutRegion[i]); //InkOut is in units of 16 bits //convert to [0-100] VectorXd InkOutV = DoubleToVector(InkOut, m_nInks); - retVal = ConvertToNLInks(InkOutV, InkOutV); - retVal = NLInkPToVolume(InkOutV, Vol); + ConvertToNLInks(InkOutV, InkOutV); + NLInkPToVolume(InkOutV, Vol); for (int j = 0; j < 3; ++j) VolumeHive(i, j) = Vol(j); } @@ -180,41 +187,28 @@ size_t Tango::ColorLib::ColorConverter::ProcessHiveNeighbors(VectorXd Lab, Vecto delete Conv02; Conv02 = NULL; } - if (tmpRGB != NULL) - { - delete tmpRGB; - tmpRGB = NULL; - } if (InkOut != NULL) { delete[]InkOut; InkOut = NULL; } - if (GamutRegion != NULL) { delete[] GamutRegion; GamutRegion = NULL; } - - if (LabOutAbs != NULL) - { - delete LabOutAbs; - LabOutAbs = NULL; - } - if (Lab1P != NULL) { delete[] Lab1P; Lab1P = NULL; } - return(retVal); + return; } -size_t Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1, int nHive, int*indDataMax) +void Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1, int nHive, int*indDataMax) { - int retStat = 0; + int vecSize = nHive*(nHive - 1) / 2; double *dECMC = new double[vecSize]; int **indexpairs = new int*[vecSize]; @@ -240,7 +234,7 @@ size_t Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1 int maxInd = 0; for (int i = 1; i < vecSize; ++i) { - if (maxdE < dECMC[i]) + if ((maxdE < dECMC[i]) && (dECMC[i]<5)) { maxdE = dECMC[i]; maxInd = i; @@ -261,7 +255,7 @@ size_t Tango::ColorLib::ColorConverter::FindTriplet(VectorXd Lab, MatrixXd Lab1 delete[] indexpairs; indexpairs = NULL; } - return(retStat); + return; } void Tango::ColorLib::ColorConverter::ArrangeHiveData(MatrixXd RGBTmpVec, MatrixXd VolumeHive, int *GamutRegion, int nHive, MatrixXd &RGBHive, MatrixXd &OVolumeHive, int *&OGamutRegion) @@ -286,10 +280,9 @@ void Tango::ColorLib::ColorConverter::ArrangeHiveData(MatrixXd RGBTmpVec, Matri } } -size_t Tango::ColorLib::ColorConverter::fillVolume(OutputCoordinates *&outputCoords, VectorXd Volume) +void Tango::ColorLib::ColorConverter::fillVolume(OutputCoordinates *&outputCoords, VectorXd Volume) { int i = 0; - int errType = 0; OutputLiquid** outputLiquids = (OutputLiquid**)malloc(sizeof(OutputLiquid*) * m_nVolumes); for (i = 0; i < m_nVolumes; ++i) { @@ -310,11 +303,12 @@ size_t Tango::ColorLib::ColorConverter::fillVolume(OutputCoordinates *&outputCo break; } default: - return(errType); //could not fill all volumes + throw std::exception("could not fill all volumes"); } } outputCoords->outputliquids = outputLiquids; - return(errType); + outputCoords->n_outputliquids = m_nVolumes; + return; } void Tango::ColorLib::ColorConverter::fillRGB(OutputCoordinates *outputCoords, VectorXd RGBOut) @@ -327,10 +321,9 @@ void Tango::ColorLib::ColorConverter::fillRGB(OutputCoordinates *outputCoords, V outputCoords->blue = (int32_t)std::round(RGBOut(2)); } -size_t Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* conversionInput) +void Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput* conversionInput) { - size_t errType = 0; - //Read thread white. Thread White is gioven in CIELab Space + //Read thread white. Thread White is given in CIELab Space if (conversionInput->has_threadl && conversionInput->has_threada && conversionInput->has_threadb) { m_whitepointLab.Set(conversionInput->threadl, conversionInput->threada, conversionInput->threadb); @@ -338,12 +331,14 @@ size_t Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput ColorConvert CConvert(D65, D65); C_RGB_XYZ_Lab tmpW; tmpW = CConvert.LabToXYZ(m_whitepointLab); - m_whitepointXYZ.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z()); + m_whitepointXYZ_Strip.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z()); + //***************This is temporary has to be replaced by the table's white point, once the new Color Table Format is set. + m_whitepointXYZ_CT.Set(tmpW.Get_x(), tmpW.Get_y(), tmpW.Get_z()); } else { - //misssing one of the whitepoint components - return(errType); + throw std::exception("misssing one of the whitepoint components"); + return; } //get ND color inverse LUT uint8_t *B2ALUT; @@ -357,7 +352,8 @@ size_t Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput SetnB2AnSepIn(m_B2ATransform->GetSeparationsIn()); if (m_nB2AnSepIn != 3) { - return(errType);//Wrong input dimensions in B2A transform + throw std::exception("Wrong input dimensions in B2A transform"); + return; } SetnB2AnSepOut(m_B2ATransform->GetSeparationsOut()); } @@ -366,7 +362,8 @@ size_t Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput if ((conversionInput->colorspace == COLOR_SPACE__RGB) || (conversionInput->colorspace == COLOR_SPACE__LAB) || (conversionInput->colorspace == COLOR_SPACE__PANTON)) - return(errType); //missing necessary Lab to Ink Transform + throw std::exception(" Missing necessary Lab to Ink Transform"); + return; } //get ND color forward LUT @@ -383,7 +380,8 @@ size_t Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput SetnA2BnSepOut(m_A2BTransform->GetSeparationsOut()); if (m_nA2BnSepOut != 3) { - return(errType);//Wrong output dimensions in A2B transform + throw std::exception(" Wrong output dimensions in Ink to Lab transform"); + return; } } else @@ -391,12 +389,14 @@ size_t Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput if ((conversionInput->has_colorspace == COLOR_SPACE__CMYK) || (conversionInput->has_colorspace == COLOR_SPACE__LAB) || (conversionInput->colorspace == COLOR_SPACE__PANTON)) - return(errType); //missing necessary Ink to Lab Transform + throw std::exception("Missing necessary Ink to Lab Transform"); + return; } if (m_nB2AnSepIn != m_nA2BnSepOut || m_nA2BnSepIn != m_nB2AnSepOut) { - return(errType); //Tables dimensions do not match + throw std::exception("Forward and InverseTables dimensions do not match"); + return; } if (A2BLUT != NULL) @@ -409,12 +409,11 @@ size_t Tango::ColorLib::ColorConverter::readColorTransformations(ConversionInput delete B2ALUT; B2ALUT = NULL; } - return(errType); // OK + return; // OK } -size_t Tango::ColorLib::ColorConverter::readCalibrationTables(ConversionInput* conversionInput) +void Tango::ColorLib::ColorConverter::readCalibrationTables(ConversionInput* conversionInput) { - size_t errType = 0; SetNumberofInks((int)(conversionInput->inputcoordinates->n_inputliquids)); CalibData *CalibCurves = new CalibData[m_nInks]; m_CalibCurves = new CalibData[m_nInks]; @@ -434,25 +433,29 @@ size_t Tango::ColorLib::ColorConverter::readCalibrationTables(ConversionInput* c { // calibration data. CalibrationData* calibrationData = InkType->calibrationdata; - errType = SetCalibData(calibrationData, i, &m_CalibCurves[i]); - //errType = SetCalibData(calibrationData, i, &CalibCurves[i]); - if (errType > 0) - return(errType); // unsuccessfull calibration table loading + SetCalibData(calibrationData, i, &m_CalibCurves[i]); break; } default: - return(errType); //could not fill all calibration tables + throw std::exception("could not fill all calibration tables"); + return; } } // m_CalibCurves=CalibCurves; - return(errType); + return; } -size_t Tango::ColorLib::ColorConverter::SetCalibData(CalibrationData *calibrationData, int i, CalibData *tmpCurve) +void Tango::ColorLib::ColorConverter::SetCalibData(CalibrationData *calibrationData, int i, CalibData *tmpCurve) { - size_t errType = 0; if (calibrationData->calibrationpoints <= 0) - return(errType); // no Calibration points + { + char msg[100]; + strcpy(msg, "No Calibration points in table "); + char ai[10]; + strcat(msg, itoa(i, ai, 10)); + throw std::exception(msg); + return; + } tmpCurve->SetCalibCurveSize((int)(calibrationData->n_calibrationpoints)); //Iterate over calibration points.. @@ -477,12 +480,11 @@ size_t Tango::ColorLib::ColorConverter::SetCalibData(CalibrationData *calibratio delete[] pointsy; pointsy = NULL; } - return(errType); + return; } -size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion) +void Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion) { - size_t errType = 0; size_t nInks = 0; C_RGB_XYZ_Lab DataLab; @@ -491,7 +493,13 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput { case (COLOR_SPACE__RGB): { - //Convert to Lab via RGB->Lab transformation +Absolute Colorimetric + // 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 + //if Strip whitepoint and Table whitepoint do not match, make the conversion: + // RGB to XYZ (D65) -> Strip Thread (from D65 to Strip) + //Convert from strip to Color table WP + //Convert from Color Table WP to D65 + //Convert to Lab via RGB->Lab transformation //Convert to ink via B2A table //Convert to Lab via A2B table returns the actual Lab which maches the Gamut //Convert to RGB @@ -500,28 +508,44 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput RGBOut(2) = conversionInput->inputcoordinates->blue; //convert to Lab ColorConvert CConvertD65(D65, D65); //Destination, source - double *LabIn; //= new double[3]; + double *LabIn; double *RGBOutP = VectorToDouble(RGBOut); - LabIn = CConvertD65.RGBtoLab(RGBOutP); //Values are in Relative Colorimetric - //Convert to AbsoluteColorimetric - double *LabInAbs;// = new double[3]; - LabInAbs = CConvertD65.ToAbsoluteLab(LabIn, m_WP, m_whitepointXYZ); + LabIn = CConvertD65.RGBtoLab(RGBOutP); //Values are in Relative Colorimetric, D65 + double *LabInFinal = LabIn; + //check if the thread to be used is the same as the one in the color tables + if ((m_whitepointXYZ_Strip.Get_x() != m_whitepointXYZ_CT.Get_x()) || + (m_whitepointXYZ_Strip.Get_y() != m_whitepointXYZ_CT.Get_y()) || + (m_whitepointXYZ_Strip.Get_z() != m_whitepointXYZ_CT.Get_z())) + { + LabInFinal = CConvertD65.ToAbsoluteLab(LabInFinal, m_WP, m_whitepointXYZ_Strip); + LabInFinal = CConvertD65.ToAbsoluteLab(LabInFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); + LabInFinal = CConvertD65.ToAbsoluteLab(LabInFinal, m_whitepointXYZ_CT, m_WP); + } + //convert to inks int GamutRegion; double *InkOutP = new double[m_nB2AnSepOut]; - m_B2ATransform->evalLab2InkP(LabInAbs, InkOutP, GamutRegion); //InkOut is in units of 16 bits + m_B2ATransform->evalLab2InkP(LabInFinal, InkOutP, GamutRegion); //InkOut is in units of 16 bits //convert to Lab to get In-Gamut Lab double *LabInP = new double[3]; m_A2BTransform->evalInkP2Lab(InkOutP, LabInP, GamutRegion); - LabOut = DoubleToVector(LabInP, 3); InkOut = DoubleToVector(InkOutP, m_nInks); - - //Convert to Absolute Colorimetric - double *LabOutAbs; //; - LabOutAbs = CConvertD65.ToAbsoluteLab(LabIn, m_whitepointXYZ, m_WP); + //Convert to Lab to get effective RGB + //Lab is in D65 + double *LabOutFinal; + LabOutFinal = LabInP; + if ((m_whitepointXYZ_Strip.Get_x() != m_whitepointXYZ_CT.Get_x()) || + (m_whitepointXYZ_Strip.Get_y() != m_whitepointXYZ_CT.Get_y()) || + (m_whitepointXYZ_Strip.Get_z() != m_whitepointXYZ_CT.Get_z())) + { + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_WP, m_whitepointXYZ_CT); + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_whitepointXYZ_Strip, m_WP); + } + LabOut = DoubleToVector(LabOutFinal,3); CConvertD65.SetReferenceWhite(D65); //Get the Gamut Mapped RGB Based on Absolute Colorimetric Data - RGBOutP = CConvertD65.LabtoRGB(LabOutAbs); + RGBOutP = CConvertD65.LabtoRGB(LabOutFinal); RGBOut = DoubleToVector(RGBOutP, 3); if (LabInP != NULL) { @@ -533,22 +557,11 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput delete[] InkOutP; InkOutP = NULL; } - if (LabIn != NULL) { delete LabIn; LabIn = NULL; } - if (LabInAbs != NULL) - { - delete LabInAbs; - LabInAbs = NULL; - } - if (LabOutAbs != NULL) - { - delete[] LabOutAbs; - LabOutAbs = NULL; - } if (RGBOutP != NULL) { delete RGBOutP; @@ -562,24 +575,36 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput LabIn[0] = conversionInput->inputcoordinates->l; LabIn[1] = conversionInput->inputcoordinates->a; LabIn[2] = conversionInput->inputcoordinates->b; - //LabIn is in relative . Convert to absolute before converting Lab to CMYK + //the assumption is that the color space has illumination that matches the whitepoint of the strip ColorConvert CConvertD65(D65, D65); //Destination, source - double *LabInAbs = CConvertD65.ToAbsoluteLab(LabIn, m_WP, m_whitepointXYZ); + double *LabInFinal = LabIn; + //Check if Color Tables and Strip whitepoints are the same, otherwiae convert + if ((m_whitepointXYZ_Strip.Get_x() != m_whitepointXYZ_CT.Get_x()) || + (m_whitepointXYZ_Strip.Get_y() != m_whitepointXYZ_CT.Get_y()) || + (m_whitepointXYZ_Strip.Get_z() != m_whitepointXYZ_CT.Get_z())) + { + LabInFinal = CConvertD65.ToAbsoluteLab(LabInFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); + LabInFinal = CConvertD65.ToAbsoluteLab(LabInFinal, m_whitepointXYZ_Strip, m_WP); + } //convert to Inks int GamutRegion; double *InkOutP = new double[m_nB2AnSepOut]; - m_B2ATransform->evalLab2InkP(LabInAbs, InkOutP, GamutRegion); //InkOut is in units of 16 bits - //Convert Inks to Lab to get the Gamut Mapped Lab + m_B2ATransform->evalLab2InkP(LabInFinal, InkOutP, GamutRegion); //InkOut is in units of 16 bits + //Convert Inks to Lab to get the Gamut Mapped Lab m_A2BTransform->evalInkP2Lab(InkOutP, LabIn, GamutRegion); LabOut = DoubleToVector(LabIn, 3); - - //Convert to absolute before converting Lab - double *LabOutAbs;// = new double[3]; - LabOutAbs = CConvertD65.ToAbsoluteLab(LabIn, m_whitepointXYZ, m_WP); + double *LabOutFinal = LabIn; + if ((m_whitepointXYZ_Strip.Get_x() != m_whitepointXYZ_CT.Get_x()) || + (m_whitepointXYZ_Strip.Get_y() != m_whitepointXYZ_CT.Get_y()) || + (m_whitepointXYZ_Strip.Get_z() != m_whitepointXYZ_CT.Get_z())) + { + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_WP, m_whitepointXYZ_CT); + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); + } CConvertD65.SetReferenceWhite(D65); //Convert to RGB double *RGBOutP; //= new double[3]; - RGBOutP = CConvertD65.LabtoRGB(LabOutAbs); + RGBOutP = CConvertD65.LabtoRGB(LabOutFinal); RGBOut = DoubleToVector(RGBOutP, 3); if (LabIn != NULL) @@ -587,21 +612,6 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput delete[] LabIn; LabIn = NULL; } - /* if (LabInAbs != NULL) - { - delete[] LabInAbs; - LabInAbs = NULL; - } */ - /* if (LabOutAbs != NULL) - { - delete[] LabOutAbs; - LabOutAbs = NULL; - }*/ - /* if (RGBOutP != NULL) - { - delete[] RGBOutP; - RGBOutP = NULL; - }*/ break; } case(COLOR_SPACE__CMYK): @@ -621,7 +631,8 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput if (CountSep != m_nA2BnSepIn) { //mismatch between table and sent data - return(errType); + throw std::exception("Mismatch between table and sent data"); + return; } //Convert to RGB int GamutRegion = 0; @@ -631,28 +642,29 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput double *LabOutP = new double[3]; m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); InkOut = DoubleToVector(InkOutP, m_nInks); - //LabOut is in relative colorimetric ColorConvert CConvertD65(D65, D65); - //Convert to absolute colorimetric - double *LabOutAbs = CConvertD65.ToAbsoluteLab(LabOutP, m_whitepointXYZ, m_WP); + double *LabOutFinal = LabOutP; + //Check if white points match + if ((m_whitepointXYZ_Strip.Get_x() != m_whitepointXYZ_CT.Get_x()) || + (m_whitepointXYZ_Strip.Get_y() != m_whitepointXYZ_CT.Get_y()) || + (m_whitepointXYZ_Strip.Get_z() != m_whitepointXYZ_CT.Get_z())) + { + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_WP, m_whitepointXYZ_CT); + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_whitepointXYZ_CT, m_whitepointXYZ_Strip); + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_whitepointXYZ_Strip, m_WP); + } + LabOut = DoubleToVector(LabOutFinal, 3); CConvertD65.SetReferenceWhite(D65); //Get RGB - - double *RGBOutP; // = new double[3]; - RGBOutP = CConvertD65.LabtoRGB(LabOutAbs); + double *RGBOutP; + RGBOutP = CConvertD65.LabtoRGB(LabOutFinal); RGBOut = DoubleToVector(RGBOutP, 3); - - if (LabOutAbs != NULL) + if (LabOutP != NULL) { - delete LabOutAbs; - LabOutAbs = NULL; + delete[] LabOutP; + LabOutP = NULL; } - /* if (RGBOutP != NULL) - { - delete[] RGBOutP; - RGBOutP = NULL; - } */ break; } case(COLOR_SPACE__PANTON): @@ -663,23 +675,24 @@ size_t Tango::ColorLib::ColorConverter::ConvertColorToLinearInks(ConversionInput else { //mismatch between color space and data - return(errType); + throw std::exception("Mismatch between color space and data"); + return; } break; //missing calclulation method and pantone table, either in terms of RGB or CMY or Lab } default: - return(errType);// Unsupported Color Space + throw std::exception(" Unsupported Color Space"); + return; } //all data is now in linear ink format - return(errType); + return; } -size_t Tango::ColorLib::ColorConverter::ConvertToNLInks(VectorXd InkIn, VectorXd &InkOut) +void Tango::ColorLib::ColorConverter::ConvertToNLInks(VectorXd InkIn, VectorXd &InkOut) { Interp LinInterp; - size_t retVal = 0; double *xValues(NULL); double *yValues(NULL); @@ -688,37 +701,29 @@ size_t Tango::ColorLib::ColorConverter::ConvertToNLInks(VectorXd InkIn, VectorX xValues = m_CalibCurves[i].getxCoords(); yValues = m_CalibCurves[i].getyCoords(); LinInterp.Init(xValues, yValues, m_CalibCurves[i].getSize()); - retVal = LinInterp.Eval(InkIn(i), InkOut(i)); - if (retVal > 0) - return(retVal); // could not interpolate + LinInterp.Eval(InkIn(i), InkOut(i)); } - - return(retVal); + return; } -size_t Tango::ColorLib::ColorConverter::ConvertToLinearInks(VectorXd InkIn, VectorXd &InkOut) +void Tango::ColorLib::ColorConverter::ConvertToLinearInks(VectorXd InkIn, VectorXd &InkOut) { Interp LinInterp; - size_t retVal = 0; double *xValues(NULL); double *yValues(NULL); for (int i = 0; i < m_nVolumes; ++i) { - xValues = m_CalibCurves[i].getxCoords(); - yValues = m_CalibCurves[i].getyCoords(); + xValues = m_CalibCurves[i].getyCoords(); + yValues = m_CalibCurves[i].getxCoords(); LinInterp.Init(yValues, xValues, m_CalibCurves[i].getSize()); - retVal = LinInterp.Eval(InkIn(i), InkOut(i)); - if (retVal > 0) - return(retVal); // could not interpolate + LinInterp.Eval(InkIn(i), InkOut(i)); } - - return(retVal); + return; } -size_t Tango::ColorLib::ColorConverter::VolumeToNLInkP(VectorXd Volume, VectorXd &NLInkP) +void Tango::ColorLib::ColorConverter::VolumeToNLInkP(VectorXd Volume, VectorXd &NLInkP) { - size_t retVal = 0; VectorXd InkP(m_nVolumes); int MaxInd = -1; double InkMax = -1.; @@ -772,12 +777,11 @@ size_t Tango::ColorLib::ColorConverter::VolumeToNLInkP(VectorXd Volume, VectorXd NLInkP(i) = Result(ind); } } - return(retVal); + return; } -size_t Tango::ColorLib::ColorConverter::NLInkPToVolume(VectorXd NLInk, VectorXd &Volume) +void Tango::ColorLib::ColorConverter::NLInkPToVolume(VectorXd NLInk, VectorXd &Volume) { - size_t retVal = 0; //Max Ink Component double MaxInk = -1.; VectorXd InkNorm(m_nInks); @@ -798,7 +802,7 @@ size_t Tango::ColorLib::ColorConverter::NLInkPToVolume(VectorXd NLInk, VectorXd InkNorm(i) = MaxInk*NLInk(i) / InkSum; Volume(i) = InkNorm(i) * m_maxNlPerCM(i) / 100; } - return(retVal); + return; } void Tango::ColorLib::ColorConverter::SetMaxNLperCM(double maxNlPerCM, int i) @@ -806,9 +810,8 @@ void Tango::ColorLib::ColorConverter::SetMaxNLperCM(double maxNlPerCM, int i) m_maxNlPerCM(i) = maxNlPerCM; } -size_t Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInput* conversionInput, VectorXd &Volume, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion) +void Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInput* conversionInput, VectorXd &Volume, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion) { - size_t errType = 0; SetNumberOfVolumes((int)(conversionInput->inputcoordinates->n_inputliquids)); // Set Calibration Data LiquidType LQ; @@ -834,7 +837,7 @@ size_t Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInpu // } } else - return(errType);//unsupported volume + std::exception("unsupported volume"); } // if (m_CalibCurves == NULL) // m_CalibCurves = CalibCurves; @@ -844,11 +847,11 @@ size_t Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInpu //Convert to Nonlinear Inks for (int i = 0; i < m_nVolumes; ++i) Volume(i) = conversionInput->inputcoordinates->inputliquids[i]->volume; - errType = VolumeToNLInkP(Volume, NLInkP); - if (errType > 0)// problems with volume to ink conversion - return(errType); - //Convert to LInear Inks - errType = ConvertToLinearInks(NLInkP, InkOut); + VolumeToNLInkP(Volume, NLInkP); + + //Convert to Linear Inks + ConvertToLinearInks(NLInkP, InkOut); + //Convert to RGB GamutRegion = 0; //Convert to Lab @@ -857,29 +860,33 @@ size_t Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInpu for (int i = 0; i < m_nA2BnSepIn; ++i) InkOutP[i] = InkOut(i); m_A2BTransform->evalInkP2Lab(InkOutP, LabOutP, GamutRegion); + //LabOut is in Relative Colorimetric ColorConvert CConvertD65(D65, D65); - double *LabOutAbs; //= new double[3]; - LabOutAbs = CConvertD65.ToAbsoluteLab(LabOutP, m_whitepointXYZ, m_WP); + double *LabOutFinal; //= new double[3]; + LabOutFinal = LabOutP; + if ((m_whitepointXYZ_Strip.Get_x() != m_whitepointXYZ_CT.Get_x()) || + (m_whitepointXYZ_Strip.Get_y() != m_whitepointXYZ_CT.Get_y()) || + (m_whitepointXYZ_Strip.Get_z() != m_whitepointXYZ_CT.Get_z())) + { + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_WP, m_whitepointXYZ_Strip); + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_whitepointXYZ_Strip, m_whitepointXYZ_CT); + LabOutFinal = CConvertD65.ToAbsoluteLab(LabOutFinal, m_whitepointXYZ_CT, m_WP); + } CConvertD65.SetReferenceWhite(D65); double *RGBOutP; // = new double[3]; - RGBOutP = CConvertD65.LabtoRGB(LabOutAbs); + RGBOutP = CConvertD65.LabtoRGB(LabOutFinal); for (int i = 0; i < 3; ++i) { RGBOut(i) = RGBOutP[i]; - LabOut(i) = LabOutAbs[i]; + LabOut(i) = LabOutFinal[i]; } if (InkOutP != NULL) { delete[]InkOutP; InkOutP = NULL; } - if (LabOutAbs != NULL) - { - delete LabOutAbs; - LabOutAbs = NULL; - } if (LabOutP != NULL) { delete[] LabOutP; @@ -890,7 +897,7 @@ size_t Tango::ColorLib::ColorConverter::ConvertVolumeToRGBDisplay(ConversionInpu delete RGBOutP; RGBOutP = NULL; } - return(errType); + return; } @@ -913,9 +920,8 @@ VectorXd Tango::ColorLib::ColorConverter::DoubleToVector(double *doub, int nSize size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer) { - size_t retVal = 0; + //Get Input - ConversionInput* conversionInput = (ConversionInput*)malloc(sizeof(ConversionInput)); conversionInput = conversion_input__unpack(NULL, input_buffer_size, input_buffer); @@ -927,10 +933,14 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i size_t n_elements = 0; m_WP.Set(0.9505, 1.00, 1.0888); //D65 - - retVal = readColorTransformations(conversionInput); + //count number if inks + int numofInks = CountNumberofInks(conversionInput); + readColorTransformations(conversionInput); // SetNumberOfInks(m_nB2AnSepOut); - retVal = readCalibrationTables(conversionInput); + readCalibrationTables(conversionInput); + if(numofInks != m_nB2AnSepOut) + throw std::exception("Number of available inks does not match ink tables"); + VectorXd InkOut(m_nB2AnSepOut); VectorXd RGBOut(3); VectorXd LabOut(3); @@ -946,14 +956,14 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i int GamutRegion = 0; //Convert input data to linear inks if (conversionInput->colorspace == COLOR_SPACE__Volume) - retVal = ConvertVolumeToRGBDisplay(conversionInput, Volume, RGBOut, LabOut, GamutRegion); + ConvertVolumeToRGBDisplay(conversionInput, Volume, RGBOut, LabOut, GamutRegion); else { - retVal = ConvertColorToLinearInks(conversionInput, InkOut, RGBOut, LabOut, GamutRegion); + ConvertColorToLinearInks(conversionInput, InkOut, RGBOut, LabOut, GamutRegion); //Convert to Nonlinear Inks - retVal = ConvertToNLInks(InkOut, NLInkOut); + ConvertToNLInks(InkOut, NLInkOut); //Convert to [nl/cm] - retVal = NLInkPToVolume(NLInkOut, Volume); + NLInkPToVolume(NLInkOut, Volume); //OutputCoordinates outputCoords = OUTPUT_COORDINATES__INIT; } OutputCoordinates *outputCoords = (OutputCoordinates*)malloc(sizeof(OutputCoordinates)); @@ -986,7 +996,7 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i RGBHive.setConstant(NegValue); VolumeHive.setConstant(NegValue); - retVal = ProcessHiveNeighbors(LabOut, RGBOut, Volume, GamutRegion, RGBHive, VolumeHive, nHive, GamutRegionV, indDataMax); + ProcessHiveNeighbors(LabOut, RGBOut, Volume, GamutRegion, RGBHive, VolumeHive, nHive, GamutRegionV, indDataMax); OutputCoordinates** hiveData = (OutputCoordinates**)malloc(sizeof(OutputCoordinates*) * MatHive); conversionOutput->hivecoordinates = hiveData; conversionOutput->n_hivecoordinates = MatHive; @@ -1044,7 +1054,22 @@ size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t i output_buffer = (uint8_t*)malloc(conversion_output__get_packed_size(conversionOutput)); int size = conversion_output__pack(conversionOutput, output_buffer); - return size; + return (size); +} + +int Tango::ColorLib::ColorConverter::CountNumberofInks(ConversionInput* conversionInput) +{ + int nLiquids = conversionInput->inputcoordinates->n_inputliquids; + int numberofInks = 0; + for (int i = 0; i < nLiquids; ++i) + { + if (conversionInput->inputcoordinates->inputliquids[i]->liquidtype == LIQUID_TYPE__Cyan || + conversionInput->inputcoordinates->inputliquids[i]->liquidtype == LIQUID_TYPE__Magenta || + conversionInput->inputcoordinates->inputliquids[i]->liquidtype == LIQUID_TYPE__Yellow || + conversionInput->inputcoordinates->inputliquids[i]->liquidtype == LIQUID_TYPE__Black) + numberofInks++; + } + return(numberofInks); } //size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer) diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.h b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.h index a76b5c751..3331199d7 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.h +++ b/Software/Visual_Studio/Native/Tango.ColorLib/ColorConverter.h @@ -21,19 +21,20 @@ namespace Tango ColorConverter(); ~ColorConverter(); // size_t Convert(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); - size_t ConvertColorToLinearInks(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion); - size_t ConvertVolumeToRGBDisplay(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, + void ConvertColorToLinearInks(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion); + void ConvertVolumeToRGBDisplay(ConversionInput* conversionInput, VectorXd &InkOut, VectorXd &RGBOut, VectorXd &LabOut, int &GamutRegion); size_t Tango::ColorLib::ColorConverter::Convert(uint8_t * input_buffer, size_t input_buffer_size, uint8_t *& output_buffer); - size_t ConvertToNLInks(VectorXd InkIn, VectorXd &InkOut); - size_t ConvertToLinearInks(VectorXd InkIn, VectorXd &InkOut); - size_t VolumeToNLInkP(VectorXd Volume, VectorXd &NLInkP); - size_t NLInkPToVolume(VectorXd NLInkP, VectorXd &Volume); + void ConvertToNLInks(VectorXd InkIn, VectorXd &InkOut); + void ConvertToLinearInks(VectorXd InkIn, VectorXd &InkOut); + void VolumeToNLInkP(VectorXd Volume, VectorXd &NLInkP); + void NLInkPToVolume(VectorXd NLInkP, VectorXd &Volume); private: ColorTransf *m_B2ATransform; ColorTransf *m_A2BTransform; C_RGB_XYZ_Lab m_whitepointLab; - C_RGB_XYZ_Lab m_whitepointXYZ; + C_RGB_XYZ_Lab m_whitepointXYZ_Strip; + C_RGB_XYZ_Lab m_whitepointXYZ_CT; int m_nB2AnSepIn; int m_nB2AnSepOut; int m_nA2BnSepIn; @@ -49,20 +50,21 @@ namespace Tango void SetnB2AnSepOut(int nB2AnSepOut) { m_nB2AnSepOut = nB2AnSepOut; }; void SetnA2BnSepIn(int nA2BnSepIn) { m_nA2BnSepIn = nA2BnSepIn; }; void SetnA2BnSepOut(int nA2BnSepOut) { m_nA2BnSepOut = nA2BnSepOut; }; - size_t readColorTransformations(ConversionInput* conversionInput); - size_t readCalibrationTables(ConversionInput* conversionInput); - size_t SetCalibData(CalibrationData* calibrationData, int i, CalibData *tmpCurve); + void readColorTransformations(ConversionInput* conversionInput); + void readCalibrationTables(ConversionInput* conversionInput); + void SetCalibData(CalibrationData* calibrationData, int i, CalibData *tmpCurve); void SetNumberofInks(int nInks) { m_nInks = nInks; }; void SetMaxNLperCM(double maxNlPerCM, int i); void SetNumberOfVolumes(int nVol) { m_nVolumes = nVol; }; void SetNumberOfInks(int nInks) { m_nInks = nInks; }; void fillRGB(OutputCoordinates *outputCoords, VectorXd RGBOut); - size_t fillVolume(OutputCoordinates *&outputCoords, VectorXd Volume); - size_t ProcessHiveNeighbors(VectorXd LabC, VectorXd RGBC, VectorXd VolumeC, int InGamutRegion, + void fillVolume(OutputCoordinates *&outputCoords, VectorXd Volume); + void ProcessHiveNeighbors(VectorXd LabC, VectorXd RGBC, VectorXd VolumeC, int InGamutRegion, MatrixXd &RGBOut, MatrixXd &VolumeOut, int nHive, int *&GamutRegion, int *indDataMax); void ArrangeHiveData(MatrixXd RGBTmpVec, MatrixXd VolumeHive, int *GamutRegion, int nHive, MatrixXd &RGBHive, MatrixXd &OVolumeHive, int *&OGamutRegion); - size_t FindTriplet(VectorXd Lab, MatrixXd Lab1, int nHive, int*indDataMax); + void FindTriplet(VectorXd Lab, MatrixXd Lab1, int nHive, int*indDataMax); + int CountNumberofInks(ConversionInput* conversionInput); double *VectorToDouble(VectorXd Vec); VectorXd DoubleToVector(double *doub, int nSize); diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorConvert.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorConvert.cpp index 96513f562..1e4b60950 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorConvert.cpp +++ b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorConvert.cpp @@ -395,12 +395,17 @@ const C_RGB_XYZ_Lab &ColorConvert::GetReferenceWhite(void) const Lab.Set(LabIn[0], LabIn[1], LabIn[2]); C_RGB_XYZ_Lab XYZ = LabToXYZ(Lab); SetReferenceWhite(DestWhite); - C_RGB_XYZ_Lab LabOut; - LabOut = XYZToLab(XYZ); + C_RGB_XYZ_Lab LabOut1; + LabOut1 = XYZToLab(XYZ); + SetReferenceWhite(SourceWhite); + C_RGB_XYZ_Lab LabOut2; + LabOut1 = XYZToLab(XYZ); double *LabD = new double[3]; - LabD[0] = LabOut.Get_x(); - LabD[1] = LabOut.Get_y(); - LabD[2] = LabOut.Get_z(); + double x = 100 - Lab.Get_x(); + double f = 100.0 / (100.0 + pow(x, 3) / 100.0); + LabD[0] = f*LabOut1.Get_x() + (1-f) *LabOut2.Get_x(); + LabD[1] = f*LabOut1.Get_y() + (1 - f) *LabOut2.Get_y(); + LabD[2] = f*LabOut1.Get_z() + (1 - f) *LabOut2.Get_z(); return(LabD); } diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.cpp index 055381e32..63958cf2b 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.cpp +++ b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.cpp @@ -37,7 +37,7 @@ using namespace std; } } - int ColorTransf::InitData(unsigned char *colorTransformBuffer, long colorTransformFileSize) + void ColorTransf::InitData(unsigned char *colorTransformBuffer, long colorTransformFileSize) { long lSize, lSizeHalf; @@ -46,7 +46,10 @@ using namespace std; lSizeHalf = lSize / 2; // allocate memory to contain the whole file: unsigned char *buffer = colorTransformBuffer; - if (buffer == NULL) { fputs("Memory error", stderr); exit(2); } + if (buffer == NULL) + { + throw std::exception("Memory Error, ColorTransf::InitData"); + } //convert to usigned short unsigned short *tmpBuffer = new unsigned short[lSizeHalf]; for (int i=0; i<lSizeHalf; ++i) @@ -74,9 +77,7 @@ using namespace std; unsigned short checkMSB = 256 >> (tmp); if (tmpBuffer[2] != (checkMSB + 1)) { - fputs("Wrong Number of MSB's ", stderr); - exit(5); - throw std::invalid_argument("Wrong Number of MSB's "); + throw std::exception("Wrong Number of MSB's, ColorTransf::InitData"); } else SetMSBShift((int)tmp); //Number of MSB's @@ -86,8 +87,7 @@ using namespace std; SetNGamutRegions((int)tmp1); //Number of Gamut Regions else { - fputs("No Gamut Regions", stderr); - exit(6); + throw std::exception("No Gamut Regions in table header, ColorTransf::InitData"); } double *GamutLimitsNlperCM = new double[(int)m_NGamutRegions]; for (int i = 0; i < (int)m_NGamutRegions; ++i) @@ -102,11 +102,9 @@ using namespace std; int totHeader = 5 + m_NGamutRegions; if (tmpSize != lSizeHalf - totHeader) { - fputs("Wrong Size Parameters ", stderr); - exit(4); + throw std::exception("Wrong Parameters in header's table, ColorTransf::InitData"); } - int lsizeH4 = lSizeHalf - totHeader; m_DataBuffer = new unsigned short[lsizeH4]; int lSizeperSep = lsizeH4 / m_SeparationsOut; @@ -127,7 +125,7 @@ using namespace std; tmpBuffer = NULL; } - return(0); + return; } void ColorTransf::SetGamutLimitsNlperCM(double *GamutLimitsNlperCM) @@ -137,7 +135,7 @@ void ColorTransf::SetGamutLimitsNlperCM(double *GamutLimitsNlperCM) m_GamutLimitsNlperCM[i] = GamutLimitsNlperCM[i]; } -int ColorTransf::evalLab2InkP(double *ColorIn, double *&ColorOut, int &GamutRegion) +void ColorTransf::evalLab2InkP(double *ColorIn, double *&ColorOut, int &GamutRegion) { double *tmpColorOut = new double[m_SeparationsOut]; @@ -151,6 +149,8 @@ int ColorTransf::evalLab2InkP(double *ColorIn, double *&ColorOut, int &GamutReg m_InterpColor.ColorMap3(iColorIn, tmpColorOut); else if (m_SeparationsIn == 4) m_InterpColor.ColorMap4(iColorIn, tmpColorOut); + else + throw std::exception("Unsupported Number of Separations in ColorTransf::evalLab2Ink"); //tmpColorOut between 0and 255 //normalize to [0-100] for (int i = 0; i < m_SeparationsOut; ++i) @@ -167,10 +167,10 @@ int ColorTransf::evalLab2InkP(double *ColorIn, double *&ColorOut, int &GamutReg tmpColorOut = NULL; } - return(0); + return; } -int ColorTransf::evalInkP2Lab(double *ColorIn, double *&ColorOut, int &GamutRegion) +void ColorTransf::evalInkP2Lab(double *ColorIn, double *&ColorOut, int &GamutRegion) { double *tmpColorOut = new double[m_SeparationsOut]; @@ -182,6 +182,8 @@ int ColorTransf::evalInkP2Lab(double *ColorIn, double *&ColorOut, int &GamutRegi m_InterpColor.ColorMap3(iColorIn, tmpColorOut); // return Valu is double in units of 16 bits else if (m_SeparationsIn == 4) m_InterpColor.ColorMap4(iColorIn, tmpColorOut); // return value is double in units on 16 bits + else + throw std::exception("Unsupported Number of Separations in ColorTransf::evalInkP2Lab"); //Normalize to Lab Space ColorOut[0] = (double)tmpColorOut[0] * LFactor / Uint16Factor; ColorOut[1] = ((double)tmpColorOut[1] * abFactor) / Uint16Factor - abOffset; @@ -197,7 +199,7 @@ int ColorTransf::evalInkP2Lab(double *ColorIn, double *&ColorOut, int &GamutRegi delete[] tmpColorOut; tmpColorOut = NULL; } - return(0); + return; } /* __declspec(dllexport) int ColorTransf::evalCMY2RGB(double *ColorIn, double *ColorOut) diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.h b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.h index 98ea8e219..cd3f8131a 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.h +++ b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/ColorTransf.h @@ -12,10 +12,10 @@ public: int GetSeparationsIn() { return(m_SeparationsIn); }; int GetSeparationsOut() { return(m_SeparationsOut); }; int GetMSBShift() { return(m_MSBShift); }; - int evalLab2InkP(double *ColorIn, double *&ColorOut, int &GamutRegion); - int evalInkP2Lab(double *ColorIn, double *&ColorOut, int &GamutRegion); + void evalLab2InkP(double *ColorIn, double *&ColorOut, int &GamutRegion); + void evalInkP2Lab(double *ColorIn, double *&ColorOut, int &GamutRegion); // int evalCMY2RGB(double *ColorIn, double *ColorOut); - int InitData(unsigned char* colorTransformBuffer, long colorTransformFileSize); + void InitData(unsigned char* colorTransformBuffer, long colorTransformFileSize); private: int m_MSBShift; int m_SeparationsIn; diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp index 7642794a6..7346a9898 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp +++ b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.cpp @@ -2,6 +2,9 @@ #include <cmath> #include <cstdlib> #include <cstdint> +#include <iostream> +#include <stdio.h> + Interp::Interp(void) { } @@ -17,7 +20,7 @@ void Interp::Init(double *xValues, double *yValues, int nlength) m_length = nlength; } -int Interp::Eval(double InValue, double &OutValue) +void Interp::Eval(double InValue, double &OutValue) { int m, ind; int errType = 0; @@ -33,14 +36,14 @@ int Interp::Eval(double InValue, double &OutValue) } if (ind == -1) { - return(errType);// Could not find value + throw std::exception ("Could not find interpolation interval"); } OutValue = ((InValue - m_xValues[m])*m_yValues[m + 1] + (m_xValues[m + 1] - InValue)*m_yValues[m]) / (m_xValues[m + 1] - m_xValues[m]); - return(errType); + return; } -int Interp::Eval(int InValue, int &OutValue) +void Interp::Eval(int InValue, int &OutValue) { int m; int errType = 0; @@ -59,10 +62,10 @@ int Interp::Eval(int InValue, int &OutValue) } if (ind == -1) { - return(errType); // Could not find value + throw std::exception("Could not find interpolation interval"); } OutValue= (int)round(((d_InValue - m_xValues[m])*m_yValues[m + 1] + (m_xValues[m + 1] - d_InValue)*m_yValues[m]) / (m_xValues[m + 1] - m_xValues[m])); - return(errType); + return; }
\ No newline at end of file diff --git a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.h b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.h index 9aed573e6..6c1128b8a 100644 --- a/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.h +++ b/Software/Visual_Studio/Native/Tango.ColorLib/Utils/Interp.h @@ -6,8 +6,8 @@ class Interp public: Interp(void); Interp(const Interp &rhs); - int Eval(double InValue, double &OutValue); - int Eval(int InValue, int &OutValue); + void Eval(double InValue, double &OutValue); + void Eval(int InValue, int &OutValue); void Init(double *xValues, double *yValues, int nlength); private: double *m_xValues; diff --git a/Software/Visual_Studio/Native/Tester/Tester.cpp b/Software/Visual_Studio/Native/Tester/Tester.cpp index 652008585..2b1659463 100644 --- a/Software/Visual_Studio/Native/Tester/Tester.cpp +++ b/Software/Visual_Studio/Native/Tester/Tester.cpp @@ -22,7 +22,7 @@ size_t InitData(uint8_t *&input_buffer, long &buffersize, char *ForwardName, cha ConversionInput *conversionInput = (ConversionInput*)malloc(sizeof(ConversionInput)); conversion_input__init(conversionInput);//CONVERSION_INPUT__INIT; //fill conversionInput - conversionInput->colorspace = COLOR_SPACE__RGB; + conversionInput->colorspace = COLOR_SPACE__Volume; conversionInput->has_colorspace = true; conversionInput->has_forwarddata = true; conversionInput->has_inversedata = true; |
