Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
iccRoundTrip.cpp
Go to the documentation of this file.
1/*
2 File: iccRoundTrip.cpp
3
4 Contains: Console app to parse and display profile round-trip statistics
5
6 Version: V1
7
8 Copyright: (c) see below
9*/
10
11/*
12 * The ICC Software License, Version 0.2
13 *
14 *
15 * Copyright (c) 2003-2012 The International Color Consortium. All rights
16 * reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in
27 * the documentation and/or other materials provided with the
28 * distribution.
29 *
30 * 3. In the absence of prior written permission, the names "ICC" and "The
31 * International Color Consortium" must not be used to imply that the
32 * ICC organization endorses or promotes products derived from this
33 * software.
34 *
35 *
36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
40 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This software consists of voluntary contributions made by many
51 * individuals on behalf of the The International Color Consortium.
52 *
53 *
54 * Membership in the ICC is encouraged when this software is used for
55 * commercial purposes.
56 *
57 *
58 * For more information on The International Color Consortium, please
59 * see <http://www.color.org/>.
60 *
61 *
62 */
63
64//////////////////////////////////////////////////////////////////////
65// HISTORY:
66//
67// -Initial implementation by Max Derhak 10-1-2007
68//
69//////////////////////////////////////////////////////////////////////
70
71
72#include <stdio.h>
73#include <math.h>
74#include "IccUtil.h"
75#include "IccEval.h"
76#include "IccPrmg.h"
77#include "IccProfLibVer.h"
78
100
102{
103 minDE1 = minDE2 = 10000;
104 maxDE1 = maxDE2 = -1;
105 sum1 = sum2 = 0;
106 num1 = num2 = 0.0;
107 num3 = m_nTotal = 0;
108
109 memset(&maxLab1[0], 0, sizeof(maxLab1));
110 memset(&maxLab2[0], 0, sizeof(maxLab2));
111}
112
114{
115 icFloatNumber DE1 = icDeltaE(deviceLab, lab1);
116 icFloatNumber DE2 = icDeltaE(lab1, lab2);
117
118 if (DE1<minDE1) {
119 minDE1 = DE1;
120 }
121
122 if (DE1>maxDE1) {
123 maxDE1 = DE1;
124 memcpy(&maxLab1[0], deviceLab, sizeof(maxLab1));
125 }
126
127 if (DE2<minDE2) {
128 minDE2 = DE2;
129 }
130
131 if (DE2>maxDE2) {
132 maxDE2 = DE2;
133 memcpy(&maxLab2[0], deviceLab, sizeof(maxLab2));
134 }
135
136 if(DE2 <= 1.0)
137 num3 += 1;
138
139 sum1 += DE1;
140 num1 += 1.0;
141
142 sum2 += DE2;
143 num2 += 1.0;
144
145 m_nTotal += 1;
146}
147
148
149int main(int argc, char* argv[])
150{
151 if (argc<=1) {
152 printf("Usage: iccRoundTrip profile {rendering_intent=1 {use_mpe=0}}\n");
153 printf("Built with IccProfLib version " ICCPROFLIBVER "\n");
154 printf(" where rendering_intent is (0=perceptual, 1=relative, 2=saturation, 3=absolute)\n");
155 return -1;
156 }
157
159 int nUseMPE = 0;
160
161 if (argc>2) {
162 nIntent = (icRenderingIntent)atoi(argv[2]);
163 if (argc>3) {
164 nUseMPE = atoi(argv[3]);
165 }
166 }
167
168 CIccMinMaxEval eval;
169
170 icStatusCMM stat = eval.EvaluateProfile(argv[1], 0, nIntent, icInterpLinear, (nUseMPE!=0));
171
172 if (stat!=icCmmStatOk) {
173 printf("Unable to perform round trip on '%s'\n", argv[1]);
174 return -1;
175 }
176
177 CIccPRMG prmg;
178
179 stat = prmg.EvaluateProfile(argv[1], nIntent, icInterpLinear, (nUseMPE!=0));
180
181 if (stat!=icCmmStatOk) {
182 printf("Unable to perform PRMG analysis on '%s'\n", argv[1]);
183 return -1;
184 }
185
186 CIccInfo info;
187
188 printf("Profile: '%s'\n", argv[1]);
189 printf("Rendering Intent: %s\n", info.GetRenderingIntentName(nIntent));
190 printf("Specified Gamut: %s\n", prmg.m_bPrmgImplied ? "Perceptual Reference Medium Gamut" : "Not Specified");
191
192 printf("\nRound Trip 1\n");
193 printf( "------------\n");
194 printf("Min DeltaE: %8.2" ICFLOATSFX "\n", eval.minDE1);
195 printf("Mean DeltaE: %8.2" ICFLOATSFX "\n", eval.GetMean1());
196 printf("Max DeltaE: %8.2" ICFLOATSFX "\n\n", eval.maxDE1);
197
198 printf("Max L, a, b: " ICFLOATFMT ", " ICFLOATFMT ", " ICFLOATFMT "\n", eval.maxLab1[0], eval.maxLab1[1], eval.maxLab1[2]);
199
200 printf("\nRound Trip 2\n");
201 printf( "------------\n");
202 printf("Min DeltaE: %8.2" ICFLOATSFX "\n", eval.minDE2);
203 printf("Mean DeltaE: %8.2" ICFLOATSFX "\n", eval.GetMean2());
204 printf("Max DeltaE: %8.2" ICFLOATSFX "\n\n", eval.maxDE2);
205
206 printf("Max L, a, b: " ICFLOATFMT ", " ICFLOATFMT ", " ICFLOATFMT "\n", eval.maxLab2[0], eval.maxLab2[1], eval.maxLab2[2]);
207
208 if (prmg.m_nTotal) {
209 printf("\nPRMG Interoperability - Round Trip Results\n");
210 printf( "------------------------------------------------------\n");
211
212 printf("DE <= 1.0 (%8u): %5.1f%%\n", prmg.m_nDE1, (float)prmg.m_nDE1/(float)prmg.m_nTotal*100.0);
213 printf("DE <= 2.0 (%8u): %5.1f%%\n", prmg.m_nDE2, (float)prmg.m_nDE2/(float)prmg.m_nTotal*100.0);
214 printf("DE <= 3.0 (%8u): %5.1f%%\n", prmg.m_nDE3, (float)prmg.m_nDE3/(float)prmg.m_nTotal*100.0);
215 printf("DE <= 5.0 (%8u): %5.1f%%\n", prmg.m_nDE5, (float)prmg.m_nDE5/(float)prmg.m_nTotal*100.0);
216 printf("DE <=10.0 (%8u): %5.1f%%\n", prmg.m_nDE10, (float)prmg.m_nDE10/(float)prmg.m_nTotal*100.0);
217 printf("Total (%8u)\n", prmg.m_nTotal);
218 }
219 return 0;
220}
221
@ icInterpLinear
Definition IccCmm.h:114
icStatusCMM
CMM return status values.
Definition IccCmm.h:90
@ icCmmStatOk
Definition IccCmm.h:92
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
#define ICFLOATFMT
Definition IccDefs.h:106
#define ICFLOATSFX
String formating macros need to match precision of icFloatNumber If precision is double change the "f...
Definition IccDefs.h:105
File: IccEval.h.
File: IccPrmg.h.
#define ICCPROFLIBVER
icFloatNumber icDeltaE(const icFloatNumber *lab1, const icFloatNumber *lab2)
Definition IccUtil.cpp:527
File: IccUtil.h.
int main()
Core and external libraries necessary for the fuzzer functionality.
unsigned int icUInt32Number
icStatusCMM EvaluateProfile(CIccProfile *pProfile, icUInt8Number nGran=0, icRenderingIntent nIntent=((icRenderingIntent) 0x3f3f3f3f), icXformInterp nInterp=icInterpLinear, bool buseMpeTags=true)
Definition IccEval.cpp:82
Type: Class.
Definition IccUtil.h:303
const icChar * GetRenderingIntentName(icRenderingIntent val, bool bIsV5=false)
Definition IccUtil.cpp:2091
icFloatNumber maxLab2[3]
icFloatNumber minDE2
icFloatNumber maxLab1[3]
icUInt32Number num3
icFloatNumber minDE1
icUInt32Number m_nTotal
icFloatNumber num1
icFloatNumber sum1
icFloatNumber num2
icFloatNumber sum2
icFloatNumber maxDE2
icFloatNumber GetMean1()
void Compare(icFloatNumber *pixel, icFloatNumber *deviceLab, icFloatNumber *lab1, icFloatNumber *lab2)
icFloatNumber GetMean2()
icFloatNumber maxDE1
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
icStatusCMM EvaluateProfile(CIccProfile *pProfile, icRenderingIntent nIntent=((icRenderingIntent) 0x3f3f3f3f), icXformInterp nInterp=icInterpLinear, bool buseMpeTags=true)
Definition IccPrmg.cpp:203
icRenderingIntent
Rendering Intents, used in the profile header.
@ icRelativeColorimetric