IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
CIccPRMG Class Reference

#include <IccPrmg.h>

Public Member Functions

 CIccPRMG ()
 
icStatusCMM EvaluateProfile (CIccProfile *pProfile, icRenderingIntent nIntent=icUnknownIntent, icXformInterp nInterp=icInterpLinear, bool buseMpeTags=true)
 
icStatusCMM EvaluateProfile (const icChar *szProfilePath, icRenderingIntent nIntent=icUnknownIntent, icXformInterp nInterp=icInterpLinear, bool buseMpeTags=true)
 
icFloatNumber GetChroma (icFloatNumber L, icFloatNumber h)
 
bool InGamut (icFloatNumber *Lab)
 
bool InGamut (icFloatNumber L, icFloatNumber c, icFloatNumber h)
 

Data Fields

bool m_bPrmgImplied
 
icUInt32Number m_nDE1
 
icUInt32Number m_nDE10
 
icUInt32Number m_nDE2
 
icUInt32Number m_nDE3
 
icUInt32Number m_nDE5
 
icUInt32Number m_nTotal
 

Detailed Description

Constructor & Destructor Documentation

◆ CIccPRMG()

CIccPRMG::CIccPRMG ( )
133{
135 m_bPrmgImplied = false;
136}
icUInt32Number m_nTotal
Definition IccPrmg.h:96
icUInt32Number m_nDE2
Definition IccPrmg.h:96
icUInt32Number m_nDE1
Definition IccPrmg.h:96
icUInt32Number m_nDE3
Definition IccPrmg.h:96
icUInt32Number m_nDE5
Definition IccPrmg.h:96
bool m_bPrmgImplied
Definition IccPrmg.h:98
icUInt32Number m_nDE10
Definition IccPrmg.h:96

References m_bPrmgImplied, m_nDE1, m_nDE10, m_nDE2, m_nDE3, m_nDE5, and m_nTotal.

Member Function Documentation

◆ EvaluateProfile() [1/2]

icStatusCMM CIccPRMG::EvaluateProfile ( CIccProfile pProfile,
icRenderingIntent  nIntent = icUnknownIntent,
icXformInterp  nInterp = icInterpLinear,
bool  buseMpeTags = true 
)
205{
206 if (!pProfile)
207 {
209 }
210
211 if (pProfile->m_Header.deviceClass!=icSigInputClass &&
212 pProfile->m_Header.deviceClass!=icSigDisplayClass &&
213 pProfile->m_Header.deviceClass!=icSigOutputClass &&
214 pProfile->m_Header.deviceClass!=icSigColorSpaceClass)
215 {
217 }
218
219 m_bPrmgImplied = false;
220 if (nIntent==icPerceptual || nIntent==icSaturation) {
222 CIccTag *pSigTag = pProfile->FindTag(rigSig);
223
224 if (pSigTag && pSigTag->GetType()==icSigSignatureType) {
225 CIccTagSignature *pSig = (CIccTagSignature*)pSigTag;
226
228 m_bPrmgImplied = true;
229 }
230 }
231
232 CIccCmm Lab2Dev2Lab(icSigLabData, icSigLabData, false);
233
234 icStatusCMM result = Lab2Dev2Lab.AddXform(*pProfile, nIntent, nInterp, NULL, icXformLutColorimetric, buseMpeTags);
235 if (result != icCmmStatOk) {
236 return result;
237 }
238
239 result = Lab2Dev2Lab.AddXform(*pProfile, nIntent, nInterp, NULL, icXformLutColorimetric, buseMpeTags);
240 if (result != icCmmStatOk) {
241 return result;
242 }
243
244 result = Lab2Dev2Lab.Begin();
245 if (result != icCmmStatOk) {
246 return result;
247 }
248 icFloatNumber pcs[3], Lab1[3], Lab2[3], dE;
249
251
252 for (pcs[0]=0.0; pcs[0]<=1.0; pcs[0] += (icFloatNumber)0.01) {
253 for (pcs[1]=0.0; pcs[1]<=1.0; pcs[1] += (icFloatNumber)0.01) {
254 for (pcs[2]=0.0; pcs[2]<=1.0; pcs[2] += (icFloatNumber)0.01) {
255 memcpy(Lab1, pcs, 3*sizeof(icFloatNumber));
256 icLabFromPcs(Lab1);
257 if (InGamut(Lab1)) {
258 Lab2Dev2Lab.Apply(Lab2, pcs);
259 icLabFromPcs(Lab2);
260
261 dE = icDeltaE(Lab1, Lab2);
262 m_nTotal++;
263
264 if (dE<=1.0) {
265 m_nDE1++;
266 m_nDE2++;
267 m_nDE3++;
268 m_nDE5++;
269 m_nDE10++;
270 }
271 else if (dE<=2.0) {
272 m_nDE2++;
273 m_nDE3++;
274 m_nDE5++;
275 m_nDE10++;
276 }
277 else if (dE<=3.0) {
278 m_nDE3++;
279 m_nDE5++;
280 m_nDE10++;
281 }
282 else if (dE<=5.0) {
283 m_nDE5++;
284 m_nDE10++;
285 }
286 else if (dE<=10.0) {
287 m_nDE10++;
288 }
289 }
290 }
291 }
292 }
293
294 return icCmmStatOk;
295}
@ icSigDisplayClass
Definition icProfileHeader.h:953
@ icSigOutputClass
Definition icProfileHeader.h:954
@ icSigInputClass
Definition icProfileHeader.h:952
@ icSigColorSpaceClass
Definition icProfileHeader.h:957
@ icSigLabData
Definition icProfileHeader.h:847
unsigned long icUInt32Number
Definition icProfileHeader.h:262
@ icSigSignatureType
Definition icProfileHeader.h:559
@ icSigPerceptualReferenceMediumGamut
Definition icProfileHeader.h:1022
icTagSignature
Definition icProfileHeader.h:341
@ icSigPerceptualRenderingIntentGamutTag
Definition icProfileHeader.h:447
@ icPerceptual
Definition icProfileHeader.h:1143
@ icSaturation
Definition icProfileHeader.h:1146
@ icXformLutColorimetric
Definition IccCmm.h:135
icStatusCMM
CMM return status values.
Definition IccCmm.h:90
@ icCmmStatInvalidProfile
Definition IccCmm.h:95
@ icCmmStatCantOpenProfile
Definition IccCmm.h:93
@ icCmmStatOk
Definition IccCmm.h:92
float icFloatNumber
Definition IccDefs.h:101
ICCPROFLIB_API void icLabFromPcs(icFloatNumber *Lab)
Here are some conversion routines to convert to regular Lab encoding.
Definition IccUtil.cpp:919
ICCPROFLIB_API icFloatNumber icDeltaE(const icFloatNumber *Lab1, const icFloatNumber *Lab2)
Definition IccUtil.cpp:527
Definition IccTagBasic.h:108
virtual icTagTypeSignature GetType() const
Definition IccTagBasic.h:131
Definition IccTagBasic.h:538
icUInt32Number GetValue() const
Definition IccTagBasic.h:554
bool InGamut(icFloatNumber *Lab)
Definition IccPrmg.cpp:195

References icHeader::deviceClass, CIccTag::GetType(), CIccTagSignature::GetValue(), icCmmStatCantOpenProfile, icCmmStatInvalidProfile, icCmmStatOk, icDeltaE(), icLabFromPcs(), icPerceptual, icSaturation, icSigColorSpaceClass, icSigDisplayClass, icSigInputClass, icSigLabData, icSigOutputClass, icSigPerceptualReferenceMediumGamut, icSigPerceptualRenderingIntentGamutTag, icSigSignatureType, icXformLutColorimetric, InGamut(), m_bPrmgImplied, m_nDE1, m_nDE10, m_nDE2, m_nDE3, m_nDE5, and m_nTotal.

Referenced by EvaluateProfile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EvaluateProfile() [2/2]

icStatusCMM CIccPRMG::EvaluateProfile ( const icChar szProfilePath,
icRenderingIntent  nIntent = icUnknownIntent,
icXformInterp  nInterp = icInterpLinear,
bool  buseMpeTags = true 
)
299{
300 CIccProfile *pProfile = ReadIccProfile(szProfilePath);
301
302 if (!pProfile)
304
305 icStatusCMM result = EvaluateProfile(pProfile, nIntent, nInterp, buseMpeTags);
306
307 delete pProfile;
308
309 return result;
310}
class ICCPROFLIB_API CIccProfile
Definition IccPcc.h:80
CIccProfile * ReadIccProfile(const icChar *szFilename, bool bUseSubProfile)
Definition IccProfile.cpp:3274
icStatusCMM EvaluateProfile(CIccProfile *pProfile, icRenderingIntent nIntent=icUnknownIntent, icXformInterp nInterp=icInterpLinear, bool buseMpeTags=true)
Definition IccPrmg.cpp:203

References CIccProfile, EvaluateProfile(), icCmmStatCantOpenProfile, and ReadIccProfile().

Referenced by AnalyzeRoundTrip(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetChroma()

icFloatNumber CIccPRMG::GetChroma ( icFloatNumber  L,
icFloatNumber  h 
)
139{
140 if (L < 3.5 || L > 100.0)
141 return -1;
142
143 int nHIndex, nLIndex;
144 icFloatNumber dHFraction, dLFraction;
145
146 // Normalize h to the range [0, 360)
147 while (h < 0.0)
148 h += 360.0;
149 while (h >= 360.0)
150 h -= 360.0;
151
152 nHIndex = (int)(h / 10.0);
153 dHFraction = (h - nHIndex * 10.0f) / 10.0f;
154
155 if (L < 5) {
156 nLIndex = 0;
157 dLFraction = (L - 3.5f) / (5.0f - 3.5f);
158 } else if (L == 100.0) {
159 nLIndex = 19; // Assuming 19 is a safe index, adapt if necessary
160 dLFraction = 1.0;
161 } else {
162 nLIndex = (int)((L - 5.0) / 5.0) + 1;
163 dLFraction = (L - nLIndex * 5.0f) / 5.0f;
164 }
165
166 // Determine the bounds of the icPRMG_Chroma array (replace with actual bounds)
167 const int maxHIndex = sizeof(icPRMG_Chroma) / sizeof(icPRMG_Chroma[0]) - 1;
168 const int maxLIndex = sizeof(icPRMG_Chroma[0]) / sizeof(icPRMG_Chroma[0][0]) - 1;
169
170 // Clamp indices to prevent out-of-bounds access
171 nHIndex = icClamp(nHIndex, 0, maxHIndex - 1);
172 nLIndex = icClamp(nLIndex, 0, maxLIndex - 1);
173
174 icFloatNumber dInvLFraction = 1.0f - dLFraction;
175
176 // Interpolate chroma values safely
177 icFloatNumber ch1 = icPRMG_Chroma[nHIndex][nLIndex] * dInvLFraction
178 + icPRMG_Chroma[nHIndex][nLIndex+1] * dLFraction;
179 icFloatNumber ch2 = icPRMG_Chroma[nHIndex+1][nLIndex] * dInvLFraction
180 + icPRMG_Chroma[nHIndex+1][nLIndex+1] * dLFraction;
181
182 return ch1 * (1.0f - dHFraction) + ch2 * dHFraction;
183}
static icFloatNumber icPRMG_Chroma[37][20]
Definition IccPrmg.cpp:83
static int icClamp(int val, int minVal, int maxVal)
Definition IccPrmg.cpp:123

References icClamp(), and icPRMG_Chroma.

Referenced by InGamut().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InGamut() [1/2]

bool CIccPRMG::InGamut ( icFloatNumber Lab)
196{
197 icFloatNumber Lch[3];
198
199 icLab2Lch(Lch, Lab);
200 return InGamut(Lch[0], Lch[1], Lch[2]);
201}
ICCPROFLIB_API void icLab2Lch(icFloatNumber *Lch, icFloatNumber *Lab=NULL)
Definition IccUtil.cpp:881

References icLab2Lch(), and InGamut().

Referenced by EvaluateProfile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InGamut() [2/2]

bool CIccPRMG::InGamut ( icFloatNumber  L,
icFloatNumber  c,
icFloatNumber  h 
)
186{
187 icFloatNumber dChroma = GetChroma(L, h);
188
189 if (dChroma<0.0 || c>dChroma)
190 return false;
191
192 return true;
193}
icFloatNumber GetChroma(icFloatNumber L, icFloatNumber h)
Definition IccPrmg.cpp:138

References GetChroma().

Referenced by InGamut().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ m_bPrmgImplied

bool CIccPRMG::m_bPrmgImplied

Referenced by CIccPRMG(), EvaluateProfile(), and main().

◆ m_nDE1

icUInt32Number CIccPRMG::m_nDE1

Referenced by CIccPRMG(), EvaluateProfile(), and main().

◆ m_nDE10

icUInt32Number CIccPRMG::m_nDE10

Referenced by CIccPRMG(), EvaluateProfile(), and main().

◆ m_nDE2

icUInt32Number CIccPRMG::m_nDE2

Referenced by CIccPRMG(), EvaluateProfile(), and main().

◆ m_nDE3

icUInt32Number CIccPRMG::m_nDE3

Referenced by CIccPRMG(), EvaluateProfile(), and main().

◆ m_nDE5

icUInt32Number CIccPRMG::m_nDE5

Referenced by CIccPRMG(), EvaluateProfile(), and main().

◆ m_nTotal

icUInt32Number CIccPRMG::m_nTotal

The documentation for this class was generated from the following files: