[Lprof-devel] lprof/src/liblprof cmspcoll.c,1.12,1.13
Brought to you by:
hvengel
|
From: Gerhard F. <gf...@us...> - 2012-08-23 15:29:49
|
Update of /cvsroot/lprof/lprof/src/liblprof
In directory vz-cvs-4.sog:/tmp/cvs-serv3583
Modified Files:
cmspcoll.c
Log Message:
Changed search strategy for cmsxPCollPatchesNearNeutral
in order to get patches covering the whole L* range.
Did a few formatting cleanups.
Index: cmspcoll.c
===================================================================
RCS file: /cvsroot/lprof/lprof/src/liblprof/cmspcoll.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** cmspcoll.c 3 Oct 2007 21:00:38 -0000 1.12
--- cmspcoll.c 23 Aug 2012 15:29:46 -0000 1.13
***************
*** 975,1022 ****
}
- int cmsxPCollPatchesNearNeutralNeeded(LPMEASUREMENT m)
- {
- int needed;
-
- if (m -> nPatches <= 24) /* ColorChecker 24 */
- needed = 5;
- else if (m -> nPatches > 24 && m -> nPatches < 141) /* ColorChecker SG */
- needed = 11;
- else if (m -> nPatches == 237) /* ColorChecker DC */
- needed = 17;
- else if (m -> nPatches > 140 && m -> nPatches < 289) /* IT8 targets */
- needed = 15;
- else if (m -> nPatches > 288 && m -> nPatches < 639 ) /* HCT targets */
- needed = 36;
- else
- needed = (int) ((double) m -> nPatches * 0.06); /* anything with more than 638 patches */
- /* printf("Number of near grays needed = %i \n", needed); */
- return needed;
- }
int cmsxPCollPatchesNearNeutral(LPMEASUREMENT m, SETOFPATCHES Valids,
! int need, SETOFPATCHES Result)
{
! int nGrays;
! double Cmax;
! Cmax = 1.0;
!
! need = cmsxPCollPatchesNearNeutralNeeded(m);
! do
! {
! PatchesOfLowC(m, Valids, Cmax, Result);
! nGrays = cmsxPCollCountSet(m, Result);
! /* printf("Number of gray patches = %i \n", nGrays); */
! if (nGrays <= need)
! {
! Cmax += 0.1;
! }
! } while (nGrays <= need && Cmax < 10.);
! return nGrays;
}
--- 975,1021 ----
}
int cmsxPCollPatchesNearNeutral(LPMEASUREMENT m, SETOFPATCHES Valids,
! int need, SETOFPATCHES Result)
{
! double d, L;
! int i, nFound = 0;
! for (i = 0; i < m->nPatches; i++)
! Result[i] = FALSE;
! /*
! * Find nearest patch to each point on gray axis
! * and eventually return the union of all these points.
! */
! for (L = 0.0; L <= 100.0; L += 0.5)
! {
! int best = -1;
! double best_d = 99999999;
! for (i = 0; i < m->nPatches; i++)
! {
! if (Valids && !Valids[i])
! continue;
! d = m->Patches[i].Lab.L - L;
! d = d * d;
! d += m->Patches[i].Lab.a * m->Patches[i].Lab.a;
! d += m->Patches[i].Lab.b * m->Patches[i].Lab.b;
!
! if (d < best_d) {
! best = i;
! best_d = d;
! }
! }
!
! if (best >= 0 && !Result[best]) {
! Result[best] = TRUE;
! nFound++;
! }
! }
!
! return nFound;
}
***************
*** 1064,1069 ****
-
-
int cmsxPCollPatchesNearPrimary(LPMEASUREMENT m,
SETOFPATCHES Valids,
--- 1063,1066 ----
***************
*** 1094,1099 ****
! static
! void AddOneGray(LPMEASUREMENT m, int n, SETOFPATCHES Grays)
{
LPPATCH p;
--- 1091,1095 ----
! static void AddOneGray(LPMEASUREMENT m, int n, SETOFPATCHES Grays)
{
LPPATCH p;
***************
*** 1114,1118 ****
-
void cmsxPCollPatchesGS(LPMEASUREMENT m, SETOFPATCHES Result)
{
--- 1110,1113 ----
***************
*** 1125,1129 ****
-
/* Refresh RGB of all patches after prelinearization */
--- 1120,1123 ----
***************
*** 1138,1142 ****
LPPATCH p = m -> Patches + i;
! cmsxApplyLinearizationTable(p -> Colorant.RGB, Gamma, p -> Colorant.RGB);
}
}
--- 1132,1136 ----
LPPATCH p = m -> Patches + i;
! cmsxApplyLinearizationTable(p->Colorant.RGB, Gamma, p->Colorant.RGB);
}
}
***************
*** 1146,1150 ****
int cmsxPCollPatchesInGamutLUT(LPMEASUREMENT m, SETOFPATCHES Valids,
! LPLUT Gamut, SETOFPATCHES Result)
{
int i;
--- 1140,1144 ----
int cmsxPCollPatchesInGamutLUT(LPMEASUREMENT m, SETOFPATCHES Valids,
! LPLUT Gamut, SETOFPATCHES Result)
{
int i;
***************
*** 1210,1231 ****
}
! for (i=0; i < m -> nPatches; i++) {
! if (Valids[i]) {
! LPPATCH p = m -> Patches + i;
! dR = fabs(255.0 - p -> Colorant.RGB[0]) / 255.0;
! dG = fabs(255.0 - p -> Colorant.RGB[1]) / 255.0;
! dB = fabs(255.0 - p -> Colorant.RGB[2]) / 255.0;
! Distance = sqrt(dR*dR + dG*dG + dB*dB);
! if (Distance < CandidateDistance) {
! Candidate = p;
! CandidateDistance = Distance;
}
! }
! }
if (TheDistance)
--- 1204,1225 ----
}
! for (i=0; i < m -> nPatches; i++) {
! if (Valids[i]) {
! LPPATCH p = m -> Patches + i;
! dR = fabs(255.0 - p -> Colorant.RGB[0]) / 255.0;
! dG = fabs(255.0 - p -> Colorant.RGB[1]) / 255.0;
! dB = fabs(255.0 - p -> Colorant.RGB[2]) / 255.0;
! Distance = sqrt(dR*dR + dG*dG + dB*dB);
! if (Distance < CandidateDistance) {
! Candidate = p;
! CandidateDistance = Distance;
! }
}
! }
if (TheDistance)
***************
*** 1242,1246 ****
double dR, dG, dB;
-
Candidate = cmsxPCollGetPatchByName(m, "DMAX", NULL);
if (Candidate) {
--- 1236,1239 ----
***************
*** 1250,1271 ****
}
! for (i=0; i < m -> nPatches; i++) {
! if (Valids[i]) {
! LPPATCH p = m -> Patches + i;
! dR = (p -> Colorant.RGB[0]) / 255.0;
! dG = (p -> Colorant.RGB[1]) / 255.0;
! dB = (p -> Colorant.RGB[2]) / 255.0;
! Distance = sqrt(dR*dR + dG*dG + dB*dB);
! if (Distance < CandidateDistance) {
! Candidate = p;
! CandidateDistance = Distance;
}
! }
! }
if (TheDistance)
--- 1243,1264 ----
}
! for (i=0; i < m -> nPatches; i++) {
! if (Valids[i]) {
! LPPATCH p = m -> Patches + i;
! dR = (p -> Colorant.RGB[0]) / 255.0;
! dG = (p -> Colorant.RGB[1]) / 255.0;
! dB = (p -> Colorant.RGB[2]) / 255.0;
! Distance = sqrt(dR*dR + dG*dG + dB*dB);
! if (Distance < CandidateDistance) {
! Candidate = p;
! CandidateDistance = Distance;
! }
}
! }
if (TheDistance)
***************
*** 1283,1325 ****
double dR, dG, dB;
const struct
! {
! double r, g, b;
} RGBPrimaries[3] =
! {
! { 255.0, 0, 0},
! { 0, 255.0, 0},
! { 0, 0, 255.0}
! };
!
! if (Channel == 0)
! Candidate = cmsxPCollGetPatchByName(m, "RPRIM", NULL);
! else if (Channel == 1)
! Candidate = cmsxPCollGetPatchByName(m, "GPRIM", NULL);
! else
! Candidate = cmsxPCollGetPatchByName(m, "BPRIM", NULL);
! if (Candidate) {
! if (TheDistance) *TheDistance = 0.0;
! return Candidate;
! }
! for (i=0; i < m -> nPatches; i++) {
! if (Valids[i]) {
! LPPATCH p = m -> Patches + i;
! dR = fabs(RGBPrimaries[Channel].r - p -> Colorant.RGB[0]) / 255.0;
! dG = fabs(RGBPrimaries[Channel].g - p -> Colorant.RGB[1]) / 255.0;
! dB = fabs(RGBPrimaries[Channel].b - p -> Colorant.RGB[2]) / 255.0;
! Distance = sqrt(dR*dR + dG*dG + dB*dB);
! if (Distance < CandidateDistance) {
! Candidate = p;
! CandidateDistance = Distance;
}
! }
! }
if (TheDistance)
--- 1276,1317 ----
double dR, dG, dB;
const struct
! {
! double r, g, b;
} RGBPrimaries[3] =
! {
! { 255.0, 0, 0},
! { 0, 255.0, 0},
! { 0, 0, 255.0}
! };
+ if (Channel == 0)
+ Candidate = cmsxPCollGetPatchByName(m, "RPRIM", NULL);
+ else if (Channel == 1)
+ Candidate = cmsxPCollGetPatchByName(m, "GPRIM", NULL);
+ else
+ Candidate = cmsxPCollGetPatchByName(m, "BPRIM", NULL);
+ if (Candidate) {
+ if (TheDistance) *TheDistance = 0.0;
+ return Candidate;
+ }
! for (i=0; i < m -> nPatches; i++) {
! if (Valids[i]) {
! LPPATCH p = m -> Patches + i;
! dR = fabs(RGBPrimaries[Channel].r - p -> Colorant.RGB[0]) / 255.0;
! dG = fabs(RGBPrimaries[Channel].g - p -> Colorant.RGB[1]) / 255.0;
! dB = fabs(RGBPrimaries[Channel].b - p -> Colorant.RGB[2]) / 255.0;
! Distance = sqrt(dR*dR + dG*dG + dB*dB);
! if (Distance < CandidateDistance) {
! Candidate = p;
! CandidateDistance = Distance;
! }
}
! }
if (TheDistance)
|