diff options
Diffstat (limited to 'target')
-rw-r--r-- | target/Jamfile | 8 | ||||
-rw-r--r-- | target/ifarp.c | 6 | ||||
-rw-r--r-- | target/ofps.c | 162 | ||||
-rw-r--r-- | target/ppoint.c | 5 | ||||
-rw-r--r-- | target/prand.c | 4 | ||||
-rw-r--r-- | target/printtarg.c | 17 | ||||
-rw-r--r-- | target/simdlat.c | 6 | ||||
-rw-r--r-- | target/simplat.c | 6 | ||||
-rw-r--r-- | target/targen.c | 370 |
9 files changed, 342 insertions, 242 deletions
diff --git a/target/Jamfile b/target/Jamfile index 3a3ef28..1ab2da6 100644 --- a/target/Jamfile +++ b/target/Jamfile @@ -28,9 +28,10 @@ Objects alphix.c randix.c ; HDRS += ../plot ../rspl ../cgats ../icc ../gamut ../xicc ../spectro ../render $(TIFFINC) ; LINKLIBS = ../xicc/libxcolorants ../spectro/libconv ../xicc/libxicc ../spectro/libinsttypes + ../spectro/libdisptechs ../gamut/libgamut ../rspl/librspl ../render/librender ../cgats/libcgats - ../plot/libplot ../plot/libvrml ../icc/libicc ../numlib/libnum - $(TIFFLIB) $(JPEGLIB) $(LibWin) ; + ../plot/libplot ../plot/libvrml ../icc/libicc ../numlib/libnum ../numlib/libui + $(TIFFLIB) $(JPEGLIB) $(PNGLIB) $(ZLIB) $(LibWin) ; #target generator @@ -53,9 +54,6 @@ MainVariant ofps : ofps.c : : STANDALONE_TEST ; # Incremental far point class MainVariant ifarp : ifarp.c : : STANDALONE_TEST ; -# Perceptual space simplex lattice -MainVariant ifarp : ifarp.c : : STANDALONE_TEST ; - MainVariant simplat : simplat.c : : STANDALONE_TEST ; # Device space simplex lattice diff --git a/target/ifarp.c b/target/ifarp.c index 7e1117e..544f316 100644 --- a/target/ifarp.c +++ b/target/ifarp.c @@ -62,16 +62,16 @@ #include <float.h> #endif #ifdef DEBUG -#include "plot.h" +# include "plot.h" +# include "ui.h" #endif #include "numlib.h" #include "sort.h" -#include "plot.h" #include "icc.h" #include "xcolorants.h" #include "targen.h" #include "ifarp.h" -#include "../h/sort.h" /* Heap sort */ +#include "sort.h" /* Heap sort */ #ifdef DEBUG static void dump_image(ifarp *s, int pcp); diff --git a/target/ofps.c b/target/ofps.c index e485035..dfcee2e 100644 --- a/target/ofps.c +++ b/target/ofps.c @@ -23,9 +23,13 @@ when ofps is used to evaluate the point distribution of other distribution algorithms. - There is a bug when the ink limit == dimensions-1 (200% for CMYY), and + There is a bug when the ink limit == dimensions-1 (200% for CMY), and the number of bit mask then exceeds > 32. This is not so +/- 0.2% either side of 200%. + (see "Hack to workaround pathalogical") + + There is a bug for CMYK when the ink limit == 100% + (see "Hack to workaround pathalogical") One way of addressing the performance issues would be to use multiple threads to call dnsq. A pool could be setup, one for each CPU. @@ -68,11 +72,18 @@ /* Failings: + The distribution near the gamut surfaces has a characteristic + "buffer zone" layer that is not very nice. This is because + the surface concentrate the sufrace points forming a "force field". + It would be good to add a tweak factor to reduce this surface "gang effect". + + The initial allocation of points to lower dimension surfaces is a bit haphazard. It would be nice to have some mechanism to add or subtract points to/from lower dimensional surfaces if they were over or under sampled compared to everything else. + While the current algorithm meets many goals, such as minimizing the maximum estimated error from any point in the space to the nearest node, and placing nodes on sub dimensional surfaces with distributions @@ -120,7 +131,6 @@ #include "numlib.h" #include "sort.h" #include "counters.h" -#include "plot.h" #include "icc.h" #include "xicc.h" #include "xcolorants.h" @@ -146,6 +156,9 @@ # define INDEP_SURFACE /* Make surface point distribution and optimization independent */ # undef MAXINDEP_2D /* Limit independent surfaces to 2D */ /* Seems to be best for ink limited devices to #undef ? */ +//# define GAMUT_EDGE_FUDGE 1.5 /* Fudge factor to counteract gamut suface barrier effect */ + // This increases edge point density as a side effect ?? + # define KEEP_SURFACE /* Keep surface points on the surface during opt. */ # define INITIAL_SURFACE_PREF 1.50 /* Extra weighting for surface points at start of seeding */ # define FINAL_SURFACE_PREF 0.80 /* Extra weighting for surface points by end of seeding */ @@ -190,6 +203,9 @@ # define DOOPT /* Do optimization */ # define INDEP_SURFACE /* Make surface point distribution and optimization independent */ # define MAXINDEP_2D /* Limit independent surfaces to 2D */ + +//# define GAMUT_EDGE_FUDGE 1.5 /* Fudge factor to counteract gamut suface barrier effect */ + # define KEEP_SURFACE /* Keep surface points on the surface during opt. */ # define INITIAL_SURFACE_PREF 1.60 /* Extra weighting for surface points at start of seeding */ # define FINAL_SURFACE_PREF 0.80 /* Extra weighting for surface points by end of seeding */ @@ -250,7 +266,7 @@ #define TNPAGRIDMINRES 7 /* Perceptual cache grid min resolution */ #define TNPAGRIDMAXRES 33 /* Perceptual cache grid max resolution */ #undef FORCE_INCREMENTAL /* Force incremental update after itteration */ -#undef FORCE_RESEED /* Force reseed after itteration */ +#define FORCE_RESEED /* Force reseed after itteration */ #define MAXTRIES 41 /* Maximum dnsq tries before giving up */ #define CACHE_PERCEPTUAL /* Cache the perceptual lookup function */ #define USE_DISJOINT_SETMASKS /* Reduce INDEP_SURFACE setmask size */ @@ -276,6 +292,11 @@ # include "conv.h" /* System dependent convenience functions */ #endif +#if defined(DEBUG) || defined(DUMP_PLOT_SEED) || defined(DUMP_PLOT) +# include "plot.h" +# include "ui.h" +#endif + #if defined(DUMP_EPERR) || defined(DUMP_FERR) #include "tiffio.h" struct _vopt_cx; @@ -1797,25 +1818,25 @@ static int checkon_gsurf(ofps *s, double *p, pleq **psp, int nsp) { /* followed by add_node2voronoi() 5%, others <= 1% ] */ #ifdef NEVER /* Allow performance trace on eperr usage */ -static double ofps_comp_eperr(ofps *s, double *pddist, double *v, double *p, double *nv, double *np); -static double ofps_comp_eperr1(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr2(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr3(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr4(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr5(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr6(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr7(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr8(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } -static double ofps_comp_eperr9(ofps *s, double *pddist, double *v, double *p, double *nv, double *np) { - return ofps_comp_eperr(s, pddist, v, p, nv, np); } +static double ofps_comp_eperr(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp); +static double ofps_comp_eperr1(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr2(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr3(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr4(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr5(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr6(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr7(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr8(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } +static double ofps_comp_eperr9(ofps *s, double *pddist, double *v, double *p, double *nv, double *np, int nsp) { + return ofps_comp_eperr(s, pddist, v, p, nv, np, nsp); } #else /* Production code */ #define ofps_comp_eperr1 ofps_comp_eperr #define ofps_comp_eperr2 ofps_comp_eperr @@ -1834,7 +1855,8 @@ static double ofps_comp_eperr( double *v, /* Device perceptual value */ double *p, /* Device sample location to be evaluated */ double *nv, /* Other perceptual value */ - double *np /* Other perceptual value */ + double *np, /* Other sample location value */ + int nsp /* Number of surface planes */ ) { int ii, e, f, di = s->di; int isc; @@ -1895,8 +1917,18 @@ static double ofps_comp_eperr( ddist = sqrt(ddist); pdist = sqrt(pdist); + eperr = s->devd_wght * ddist + s->perc_wght * pdist; +#ifdef GAMUT_EDGE_FUDGE + /* Fudge factor to prevent gap at gamut boundaries */ + if (nsp > 0) { +// int nn; +// for (nn = 0; nn < nsp; nn++) + eperr *= GAMUT_EDGE_FUDGE; + } +#endif /* GAMUT_EDGE_FUDGE */ + //printf("~1 Percept distance = %f, perc error = %f\n",pdist,s->perc_wght * pdist); return eperr; } @@ -1924,9 +1956,8 @@ static void ofps_pn_eperr( } /* Uncertaintly error computed from device and perceptual distance */ - for (ii = 0; ii < nnds; ii++) { - ee[ii] = ofps_comp_eperr1(s, NULL, sv, sp, nds[ii]->v, nds[ii]->p); - } + for (ii = 0; ii < nnds; ii++) + ee[ii] = ofps_comp_eperr1(s, NULL, sv, sp, nds[ii]->v, nds[ii]->p, nds[ii]->nsp); if (ce == NULL) return; @@ -1959,6 +1990,15 @@ static void ofps_pn_eperr( ce[ii] += tt * tt; } ce[ii] = s->curv_wght * sqrt(ce[ii]); +#ifdef GAMUT_EDGE_FUDGE + /* Fudge factor to prevent gap at gamut boundaries */ + if (nds[ii]->nsp > 0) { +// int nn; +// for (nn = 0; nn < nds[ii]->nsp; nn++) + ce[ii] *= GAMUT_EDGE_FUDGE; + } +#endif /* GAMUT_EDGE_FUDGE */ + } } else { for (ii = 0; ii < nnds; ii++) @@ -2093,8 +2133,10 @@ int dnsq_solver( /* Return < 0 on abort */ /* Get eperr at each real node */ ofps_cc_percept(s, sv, x); /* We have to compute it */ - for (k = 0; k < cx->nn; k++) - cee[k] = ofps_comp_eperr2(s, NULL, sv, x, cx->nds[k]->v, cx->nds[k]->p); + for (k = 0; k < cx->nn; k++) { + + cee[k] = ofps_comp_eperr2(s, NULL, sv, x, cx->nds[k]->v, cx->nds[k]->p, cx->nds[k]->nsp); + } //fprintf(stderr,"~1 maxeperr = %f\n",cmax); @@ -2270,7 +2312,7 @@ static int position_vtx( for (i = 0; i < (ii-1); i++) { for (j = i+1; j < ii; j++) { double dist; - dist = ofps_comp_eperr3(s, NULL, cx.nds[i]->v, cx.nds[i]->p, cx.nds[j]->v, cx.nds[j]->p); + dist = ofps_comp_eperr3(s, NULL, cx.nds[i]->v, cx.nds[i]->p, cx.nds[j]->v, cx.nds[j]->p, cx.nds[i]->nsp) ; if (dist < ceperr) { ceperr = dist; bi = i; @@ -2599,7 +2641,7 @@ double powell_solver( /* Return < 0 on abort */ /* Get eperr at each real node */ ofps_cc_percept(s, sv, x); /* We have to compute it */ for (k = 0; k < cx->nn; k++) - cee[k] = ofps_comp_eperr2(s, NULL, sv, x, cx->nds[k]->v, cx->nds[k]->p); + cee[k] = ofps_comp_eperr2(s, NULL, sv, x, cx->nds[k]->v, cx->nds[k]->p, cx->nds[k]->nsp); //fprintf(stderr,"~1 maxeperr = %f\n",cmax); @@ -3644,7 +3686,7 @@ ofps_quick_check_hits(ofps *s) { nvxhits++; } } else { - double eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p); + double eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); /* See if the vertex eperr will be improved */ if (eperr < (vx->eperr + 0.0)) { @@ -3779,7 +3821,7 @@ ofps_check_vtx(ofps *s, node *nn, vtx *vx, int dorec, int beyhit) { } else { /* Node rather than boundary plane */ /* nba_eperr is assumed to be valid if vx->cflag == s->flag */ - vx->nba_eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p); + vx->nba_eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); #ifdef DEBUG printf("%d: Computing nba_eperr of %f for vtx no %d\n",dist, vx->nba_eperr, vx->no); #endif @@ -3968,7 +4010,7 @@ ofps_check_vtx_sanity(ofps *s, node *nn, vtx *vx, int fixit) { } else { /* Node rather than boundary plane */ double nba_eperr; - nba_eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p); + nba_eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); /* See if the vertex eperr will be improved */ if (!par && (vx->eperr - nba_eperr) > tol) { @@ -5120,7 +5162,7 @@ ofps_init_acc2(ofps *s) { np = &s->_grid[i + j]; /* eperr from that corner to center of this cell */ - eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, np->v, np->p); + eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, np->v, np->p, 0); eperr_avg += eperr; if (eperr > eperr_max) eperr_max = eperr; @@ -5166,7 +5208,7 @@ ofps_init_acc2(ofps *s) { /* Compose new center point from weighted corner points. */ /* Weighting is proportional to eperr value */ - eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, np->v, np->p); + eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, np->v, np->p, 0); if (eperr < eperr_avg) { /* Move away from corner */ @@ -5272,7 +5314,7 @@ ofps_add_nacc(ofps *s, node *n) { double eperr; /* Check that the eperr to the center of the cell */ /* is less than the worst case for that cell */ - eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, n->v, n->p); + eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, n->v, n->p, n->nsp); if (eperr > cp->eperr) { warning("Sanity check ofps_add_nacc() node ix %d eperr %f > cell eperr %f",n->ix,eperr,cp->eperr); printf("Sanity check ofps_add_nacc() node ix %d eperr %f > cell eperr %f\n",n->ix,eperr,cp->eperr); @@ -5337,7 +5379,7 @@ ofps_add_vacc(ofps *s, vtx *vx) { p[e] = 1.0; } ofps_cc_percept(s, v, p); - eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, v, p); + eperr = ofps_comp_eperr(s, NULL, cp->cv, cp->cp, v, p, 0); if (eperr > cp->eperr) { @@ -5914,9 +5956,10 @@ ofps_seed(ofps *s) { } /* Suceeded in adding the point */ - if (p->fx) { /* Fixed point */ + if (p->fx) { /* Fixed point was added */ fc++; - dofixed--; + if (dofixed > 0) /* May not have been triggered by dofixed */ + dofixed--; if ((s->fnp - fc) >= (s->tinp - i - 1)) { /* No room for moveable points */ dofixed = s->fnp - fc; /* Do all the fixed */ } @@ -6168,7 +6211,7 @@ static int ofps_findhit_vtxs(ofps *s, node *nn) { /* Compute the smallest eperr possible in this cell, by computing the */ /* eperr of the cell center to the node minus the estimated */ /* largest eperr of any point within the cell to the center. */ - ceperr = ofps_comp_eperr(s, NULL, cp->v, cp->p, nn->v, nn->p); + ceperr = ofps_comp_eperr(s, NULL, cp->v, cp->p, nn->v, nn->p, nn->nsp); eperr = ceperr - cp->eperr; //printf("~1 ceperr %f, cp->eperr %f, eperr %f, beperr %f\n",ceperr,cp->eperr,eperr,beperr); @@ -6196,7 +6239,7 @@ static int ofps_findhit_vtxs(ofps *s, node *nn) { par = 1; } - eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p); + eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); if (!par && (vx->eperr - eperr) > 0.0) { //printf("~1 Node ix %d at %s (%s)\n Cell ix %d co %s center %s (%s),\n vtx no %d at %s (%s)\n",nn->ix, ppos(di,nn->p),ppos(di,nn->v),cp - s->grid,pco(s->di,cp->co),ppos(di,cp->cp),ppos(di,cp->cv),vx->no, ppos(di,vx->p),ppos(di,vx->v)); @@ -6262,7 +6305,7 @@ static int ofps_findhit_vtxs(ofps *s, node *nn) { } /* nba_eperr is assumed to be valid if vx->cflag == s->flag */ - vx->nba_eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p); + vx->nba_eperr = ofps_comp_eperr7(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); #ifdef DEBUG printf("Computing nba_eperr of %f for vtx no %d\n",vx->nba_eperr, vx->no); #endif @@ -6401,7 +6444,7 @@ static node *ofps_findclosest_node(ofps *s, double *ceperr, vtx *vx) { /* Compute the eperr of the cell center to the vtx minus the estimated */ /* largest eperr of any point within the cell to the center. */ - ceperr = ofps_comp_eperr(s, NULL, cp->v, cp->p, vx->v, vx->p); + ceperr = ofps_comp_eperr(s, NULL, cp->v, cp->p, vx->v, vx->p, vx->nsp); eperr = ceperr - cp->eperr; /* If the cell is worth searching */ @@ -6421,7 +6464,7 @@ static node *ofps_findclosest_node(ofps *s, double *ceperr, vtx *vx) { #endif /* INDEP_SURFACE */ /* Compute the eperr between the node to the new vtx */ - eperr = ofps_comp_eperr(s, NULL, no->v, no->p, vx->v, vx->p); + eperr = ofps_comp_eperr(s, NULL, no->v, no->p, vx->v, vx->p, vx->nsp); if (eperr < beperr) { bno = no; beperr = eperr; @@ -6475,7 +6518,7 @@ static node *ofps_findclosest_node(ofps *s, double *ceperr, vtx *vx) { #endif /* INDEP_SURFACE */ /* Compute the eperr between the node to the new vtx */ - teperr = ofps_comp_eperr(s, NULL, no->v, no->p, vx->v, vx->p); + teperr = ofps_comp_eperr(s, NULL, no->v, no->p, vx->v, vx->p, vx->nsp); if (teperr < beperr) { warning("Sanity check ofps_findclosest_node() cell skip failed, estimated %f from cellc eperr %f - cell eperr %f, found %f from node ix %d",eperr,ceperr,cp->eperr,teperr,no->ix); printf("Sanity check ofps_findclosest_node() cell skip failed, estimated %f from cellc eperr %f - cell eperr %f, found %f from node ix %d\n",eperr,ceperr,cp->eperr,teperr,no->ix); @@ -6520,7 +6563,7 @@ static node *ofps_findclosest_node(ofps *s, double *ceperr, vtx *vx) { #endif /* INDEP_SURFACE */ /* Compute the eperr between the node and the vertex */ - eperr = ofps_comp_eperr(s, NULL, nn->v, nn->p, vx->v, vx->p); + eperr = ofps_comp_eperr(s, NULL, nn->v, nn->p, vx->v, vx->p, vx->nsp); if (eperr < ch_beperr) { ch_bno = nn; ch_beperr = eperr; @@ -6614,7 +6657,7 @@ static vtx *ofps_findclosest_vtx(ofps *s, double *ceperr, node *nn) { /* Compute the eperr of the cell center to the node minus the estimated */ /* largest eperr of any point within the cell to the center. */ - ceperr = ofps_comp_eperr(s, NULL, cp->v, cp->p, nn->v, nn->p); + ceperr = ofps_comp_eperr(s, NULL, cp->v, cp->p, nn->v, nn->p, nn->nsp); eperr = ceperr - cp->eperr; /* If the cell is worth searching */ @@ -6634,7 +6677,7 @@ static vtx *ofps_findclosest_vtx(ofps *s, double *ceperr, node *nn) { #endif /* INDEP_SURFACE */ /* Compute the eperr between the vertex to the new node */ - eperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p); + eperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); if (eperr < beperr) { bvx = vx; beperr = eperr; @@ -6683,7 +6726,7 @@ static vtx *ofps_findclosest_vtx(ofps *s, double *ceperr, node *nn) { #endif /* INDEP_SURFACE */ /* Compute the eperr between the vertex to the new node */ - teperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p); + teperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); if (teperr < beperr) { warning("Sanity check ofps_findclosest_vtx() cell skip failed, estimated %f from cellc eperr %f - cell eperr %f, found %f from vtx no %d",eperr,ceperr,cp->eperr,teperr,vx->no); printf("Sanity check ofps_findclosest_vtx() cell skip failed, estimated %f from cellc eperr %f - cell eperr %f, found %f from vtx no %d\n",eperr,ceperr,cp->eperr,teperr,vx->no); @@ -6727,7 +6770,7 @@ static vtx *ofps_findclosest_vtx(ofps *s, double *ceperr, node *nn) { #endif /* INDEP_SURFACE */ /* Compute the eperr between the vertex to the new node */ - eperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p); + eperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); if (eperr < ch_beperr) { ch_bvx = vx; ch_beperr = eperr; @@ -6833,7 +6876,7 @@ static vtx *ofps_findhit_vtx(ofps *s, double *ceperr, node *nn) { #endif /* INDEP_SURFACE */ /* Compute the eperr between the vertex to the new node */ - eperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p); + eperr = ofps_comp_eperr(s, NULL, vx->v, vx->p, nn->v, nn->p, nn->nsp); if (eperr < vx->eperr) { bvx = vx; beperr = eperr; @@ -7297,8 +7340,8 @@ int dnsq_mid_solver( /* Return < 0 on abort */ ofps_cc_percept(s, sv, pos); /* Get eperr */ - cee[0] = ofps_comp_eperr8(s, NULL, sv, pos, cx->nds[0]->v, cx->nds[0]->p); - cee[1] = ofps_comp_eperr8(s, NULL, sv, pos, cx->nds[1]->v, cx->nds[1]->p); + cee[0] = ofps_comp_eperr8(s, NULL, sv, pos, cx->nds[0]->v, cx->nds[0]->p, cx->nds[0]->nsp); + cee[1] = ofps_comp_eperr8(s, NULL, sv, pos, cx->nds[1]->v, cx->nds[1]->p, cx->nds[1]->nsp); //printf("~1 error = %f, %f", cee[0], cee[1]); @@ -8063,6 +8106,11 @@ int nopstop /* Debug - number of optimizations until diagnostic stop, -1 = no && ilimit <= (di-2.0 + 2 * ILIMITEPS)) ilimit = di-2.0 - 2 * ILIMITEPS; + /* Hack to workaround pathalogical case. At ilimit == 100% we get a failure */ + /* to add any variable steps */ + if (ilimit > 0.9999 && ilimit < 1.0001) + ilimit = 0.9999; + s->ilimit = ilimit; for (e = 0; e < di; e++) { @@ -8697,7 +8745,7 @@ dump_image( mcols[n3].rgb[1] = 0.85; mcols[n3].rgb[2] = 0.85; - sprintf(mtext[n3],""); + sprintf(mtext[n3],"%s",""); sprintf(mtext[n3],"%d",mp->no); // sprintf(mtext[n3],"%d",(int)(mp->eserr + 0.5)); } @@ -8781,7 +8829,7 @@ dump_image( mcols[n3].rgb[1] = 0.59; mcols[n3].rgb[2] = 0.0; - sprintf(mtext[n3],""); + sprintf(mtext[n3],"%s",""); } } } @@ -8851,7 +8899,7 @@ dump_image( for (i = 0; i < s->np; i++) { node *np = s->n[i]; - eserr = ofps_comp_eperr9(s, NULL, vpos, pos, np->v, np->p); + eserr = ofps_comp_eperr9(s, NULL, vpos, pos, np->v, np->p, np->nsp); if (eserr < beserr) beserr = eserr; } @@ -9201,7 +9249,7 @@ static void check_for_missing_vertexes(ofps *s) { continue; /* Is a parent */ nn = s->n[ix]; - eperr = ofps_comp_eperr(s, NULL, nn->v, nn->p, vv.v, vv.p); + eperr = ofps_comp_eperr(s, NULL, nn->v, nn->p, vv.v, vv.p, 0); printf(" eperr to ix %d is %f\n",nn->ix,eperr); if (eperr < vv.eperr) { diff --git a/target/ppoint.c b/target/ppoint.c index 2a5dd26..217b1e9 100644 --- a/target/ppoint.c +++ b/target/ppoint.c @@ -37,11 +37,14 @@ #include "numlib.h" #include "rspl.h" #include "sort.h" -#include "plot.h" #include "icc.h" #include "xcolorants.h" #include "targen.h" #include "ppoint.h" +#ifdef DUMP_PLOT +# include "plot.h" +# include "ui.h" +#endif #undef DEBUG #define DUMP_PLOT /* Show on screen plot */ diff --git a/target/prand.c b/target/prand.c index 927243a..7ce5760 100644 --- a/target/prand.c +++ b/target/prand.c @@ -26,12 +26,8 @@ #if defined(__IBMC__) #include <float.h> #endif -#ifdef DEBUG -#include "plot.h" -#endif #include "numlib.h" #include "sort.h" -#include "plot.h" #include "icc.h" #include "xicc.h" #include "xcolorants.h" diff --git a/target/printtarg.c b/target/printtarg.c index 3ad3023..313f8d1 100644 --- a/target/printtarg.c +++ b/target/printtarg.c @@ -17,6 +17,12 @@ TTBD: + Add option to return the number of patches that will + exactly fit the given number of pages. + + Add optional device link processing support (same slot + as -K file.cal) to permit a smoother proofing verification workflow. + Add independent w & h patch scaling option. Allow scaling minimum leading/trailing white space. @@ -135,6 +141,7 @@ #include "alphix.h" #include "rspl.h" #include "sort.h" +#include "ui.h" #include <stdarg.h> @@ -907,7 +914,7 @@ static void tiff_del(trend *ss) { tiff_trend *s = (tiff_trend *)ss; if (s->r != NULL) { - s->r->write(s->r, s->fname, s->comp); + s->r->write(s->r, s->fname, s->comp, NULL, NULL, tiff_file); s->r->del(s->r); } if (s->fname != NULL) @@ -925,7 +932,7 @@ static trend *new_tiff_trend( int altrep, /* printer grey/CMY representation type 0..8 */ int ncha, /* flag, use nchannel alpha */ int comp, /* flag, use compression */ - int dith /* flag, use 8 bit dithering */ + int dith /* flag, 1 = use 8 bit stocastic dithering */ ) { tiff_trend *s; color2d c; /* Background color */ @@ -1014,11 +1021,11 @@ static trend *new_tiff_trend( else ma[0] = ma[1] = ma[2] = ma[3] = 0; - if ((s->r = new_render2d(pw, ph, ma, hres, vres, csp, nc, dpth, dith)) == NULL) { + if ((s->r = new_render2d(pw, ph, ma, hres, vres, csp, nc, dpth, dith, NULL, NULL)) == NULL) { error("Failed to create a render2d object for tiff output"); } - /* We're goin to assume this is all printed output, so */ + /* We're going to assume this is all printed output, so */ /* the background should be white. */ if ((nmask & ICX_ADDITIVE) || (nmask == ICX_CMY && altrep == 7)) { /* CMY as inverted RGB */ @@ -2907,7 +2914,7 @@ void usage(char *diag, ...) { fprintf(stderr," -f Create PostScript DeviceN Color fallback\n"); fprintf(stderr," -w g|r|s|n White colorspace encoding DeviceGray (def), DeviceRGB, Separation or DeviceN\n"); fprintf(stderr," -k g|c|s|n Black colorspace encoding DeviceGray (def), DeviceCMYK, Separation or DeviceN\n"); - fprintf(stderr," -o k|r|n CMY colorspace encoding DefiveCMYK (def), inverted DeviceRGB or DeviceN\n"); + fprintf(stderr," -o k|r|n CMY colorspace encoding DeviceCMYK (def), inverted DeviceRGB or DeviceN\n"); fprintf(stderr," -e Output EPS compatible file\n"); fprintf(stderr," -t [res] Output 8 bit TIFF raster file, optional res DPI (default 100)\n"); fprintf(stderr," -T [res] Output 16 bit TIFF raster file, optional res DPI (default 100)\n"); diff --git a/target/simdlat.c b/target/simdlat.c index c5edf36..50f159b 100644 --- a/target/simdlat.c +++ b/target/simdlat.c @@ -41,12 +41,12 @@ #if defined(__IBMC__) #include <float.h> #endif -#ifdef DEBUG -#include "plot.h" +#if defined(DEBUG) || defined(DUMP_PLOT) +# include "plot.h" +# include "ui.h" #endif #include "numlib.h" #include "sort.h" -#include "plot.h" #include "icc.h" #include "xcolorants.h" #include "targen.h" diff --git a/target/simplat.c b/target/simplat.c index 736b0e8..e738ff7 100644 --- a/target/simplat.c +++ b/target/simplat.c @@ -41,12 +41,12 @@ #if defined(__IBMC__) #include <float.h> #endif -#ifdef DEBUG -#include "plot.h" +#if defined(DEBUG) || defined(DUMP_PLOT) +# include "plot.h" +# include "ui.h" #endif #include "numlib.h" #include "sort.h" -#include "plot.h" #include "icc.h" #include "xcolorants.h" #include "targen.h" diff --git a/target/targen.c b/target/targen.c index c868dc4..4d1d7ac 100644 --- a/target/targen.c +++ b/target/targen.c @@ -35,6 +35,10 @@ Using adaptive patch creation for grey colorspace is broken. This should be fixed. + Would be nice to have a generator of "well behaved" device + gamut surface points. Would need a way of creating + a gamut surface from the .ti3 file though. + */ /* NOTE: @@ -101,7 +105,7 @@ #undef DEBUG -#define VRML_DIAG /* Enable option to dump a VRML of the resulting full spread points */ +#define VRML_DIAG /* Enable option to dump a VRML/X3D of the resulting full spread points */ #undef ADDRECCLIPPOINTS /* Add ink limited clipping points to regular grid */ #define EMPH_NEUTRAL /* Emphasise neutral axis, like CIE94 does */ #define NEMPH_DEFAULT 0.5 /* Default neutral axis emphasis == 2 x CIE94 */ @@ -112,10 +116,14 @@ #define MATCH_TOLL 1e-3 /* Tollerance of device value to consider a patch a duplicate */ /* Display rise and fall time delay model. This is CRT like */ -#define DISPLAY_RISE_TIME 0.03 /* Assumed rise time to 90% of target level */ -#define DISPLAY_FALL_TIME 0.12 /* Assumed fall time to 90% of target level */ -#define DISPLAY_SETTLE_AIM 0.01 /* Aim for 1% of true level */ -#define DISPLAY_ABS_AIM 0.0001 /* Aim for .01% of true absolute level */ +#define DISPLAY_RISE_TIME DISPTECH_WORST_RISE /* Assumed rise time to 90% of target level */ +#define DISPLAY_FALL_TIME DISPTECH_WORST_FALL /* Assumed fall time to 90% of target level */ +#define DISPLAY_SETTLE_AIM 0.1 /* Aim for 0.2 Delta E */ + +#ifdef NEVER /* Old delay time code */ +#define DISPLAY_SETTLE_AIM2 0.01 /* Aim for 1% of true level */ +#define DISPLAY_ABS_AIM2 0.0001 /* Aim for .01% of true absolute level */ +#endif #include <stdio.h> #include <stdlib.h> @@ -131,6 +139,7 @@ #include "cgats.h" #include "icc.h" #include "xicc.h" +#include "disptechs.h" #include "targen.h" //#include "ppoint.h" #include "ofps.h" @@ -138,6 +147,7 @@ #include "simplat.h" #include "simdlat.h" #include "prand.h" +#include "ui.h" #include <stdarg.h> @@ -174,7 +184,7 @@ struct _pcpt { /* Tuning parameters */ double nemph; /* neutral emphasis, 0.0 - 1.0. Default 0.35 for == CIE94 */ - double idemph; /* inv. dark emphasis, 1.0 - 4.0. Default 1.0 == none */ + double idemph; /* inv. of dark emphasis, 1.0 - 4.0. Default 1.0 == none */ double ixpow; /* inv. extra power Default 1.0 == none */ /* ICC profile based */ @@ -233,7 +243,7 @@ pcpt_to_XYZ(pcpt *s, double *out, double *in) { /* Relative Lab conversion function */ /* Internal device values 0.0 - 1.0 are converted into Lab values */ -/* (Used for VRML visualisation checking) */ +/* (Used for VRML/X3D visualisation checking) */ static void pcpt_to_rLab(pcpt *s, double *out, double *in) { int e; @@ -663,7 +673,7 @@ double xpow /* Extra device power, default = none */ if (demph < 0.0) demph = DEMPH_DEFAULT; - s->idemph = demph; + s->idemph = 1.0/demph; if (xpow < 0.0) xpow = XPOW_DEFAULT; @@ -866,9 +876,10 @@ usage(int level, char *diag, ...) { fprintf(stderr," -N nemphasis Degree of neutral axis patch concentration 0.0-1.0 (default %.2f)\n",NEMPH_DEFAULT); fprintf(stderr," -V demphasis Degree of dark region patch concentration 1.0-4.0 (default %.2f = none)\n",DEMPH_DEFAULT); fprintf(stderr," -F L,a,b,rad Filter out samples outside Lab sphere.\n"); + fprintf(stderr," -O Don't re-order display RGB patches for minimum delay\n"); #ifdef VRML_DIAG - fprintf(stderr," -w Dump diagnostic outfilel.wrl file (Lab locations)\n"); - fprintf(stderr," -W Dump diagnostic outfiled.wrl file (Device locations)\n"); + fprintf(stderr," -w Dump diagnostic outfilel%s file (Lab locations)\n",vrml_ext()); + fprintf(stderr," -W Dump diagnostic outfiled%s file (Device locations)\n",vrml_ext()); #endif /* VRML_DIAG */ fprintf(stderr," outfile Base name for output(.ti1)\n"); exit(1); @@ -894,6 +905,7 @@ int dofilt( return 0; } + static double disprespt(cgats *pp, int p1, int p2); int main(int argc, char *argv[]) { @@ -901,18 +913,18 @@ int main(int argc, char *argv[]) { int fa, nfa, mfa; /* current argument we're looking at */ int verb = 0; /* Verbose flag */ #ifdef VRML_DIAG - int dumpvrml = 0; /* Dump diagnostic .wrl file */ + int dumpvrml = 0; /* Dump diagnostic VRML/X3D file */ #endif /* VRML_DIAG */ inkmask xmask = 0; /* External ink mask combination */ inkmask nmask = 0; /* Working ink mask combination (ie. CMY for printer external sRGB) */ int di = 0; /* Output dimensions */ char *ident; /* Ink combination identifier (includes possible leading 'i') */ int good = 0; /* 0 - fast, 1 = good */ - int esteps = 4; /* White color patches */ + int esteps = -1; /* White color patches */ int Bsteps = -1; /* Black color patches */ int ssteps = -1; /* Single channel steps */ double xpow = 1.0; /* Power to apply to all device values created */ - int gsteps = 0; /* Composite grey wedge steps */ + int gsteps = -1; /* Composite grey wedge steps */ int msteps = 0; /* Regular grid multidimensional steps */ int bsteps = 0; /* Regular body centered cubic grid multidimensional steps */ int fsteps = -1; /* Fitted Multidimensional patches */ @@ -929,12 +941,13 @@ int main(int argc, char *argv[]) { double uilimit = -1.0; /* Underlying (pre-calibration, scale 1.0) ink limit */ double nemph = NEMPH_DEFAULT; double demph = DEMPH_DEFAULT; + int dontreorder = 0; /* Don't re-order RGB display patches for min delay */ int filter = 0; /* Filter values */ double filt[4] = { 50,0,0,0 }; static char fname[MAXNAMEL+1] = { 0 }; /* Output file base name */ static char pname[MAXNAMEL+1] = { 0 }; /* Device profile name */ - static char wdname[MAXNAMEL+1] = { 0 }; /* Device diagnostic .wrl name */ - static char wlname[MAXNAMEL+1] = { 0 }; /* Lab diagnostic .wrl name */ + static char wdname[MAXNAMEL+1] = { 0 }; /* Device diagnostic .wrl/.x3d name */ + static char wlname[MAXNAMEL+1] = { 0 }; /* Lab diagnostic .wrl/.x3d name */ char buf[500]; /* Genaral use text buffer */ int id = 1; /* Sample ID */ time_t clk = time(0); @@ -1213,6 +1226,11 @@ int main(int argc, char *argv[]) { fa = nfa; } + /* Don't re-order RGB display patches for best speed */ + else if (argv[fa][1] == 'O') { + dontreorder = 1; + } + #ifdef VRML_DIAG else if (argv[fa][1] == 'w') /* Lab */ dumpvrml |= 1; @@ -1232,10 +1250,10 @@ int main(int argc, char *argv[]) { strcat(fname,".ti1"); strncpy(wdname,argv[fa],MAXNAMEL-5); wdname[MAXNAMEL-5] = '\000'; - strcat(wdname,"d.wrl"); + strcat(wdname,"d"); strncpy(wlname,argv[fa],MAXNAMEL-5); wlname[MAXNAMEL-5] = '\000'; - strcat(wlname,"l.wrl"); + strcat(wlname,"l"); /* Set default colorant combination as CMYK */ if (xmask == 0) @@ -1256,6 +1274,11 @@ int main(int argc, char *argv[]) { stime = clock(); /* Implement some defaults */ + if (esteps < 0) + esteps = 4; + if (gsteps < 0) + gsteps = 0; + if (Bsteps < 0) { if (xmask == ICX_W || xmask == ICX_K || xmask == ICX_RGB || xmask == ICX_IRGB) Bsteps = 4; @@ -1284,158 +1307,158 @@ int main(int argc, char *argv[]) { gsteps = 0; } } else if (di == 3) { - if (ssteps == 0 && fsteps == 0 && msteps == 0 && bsteps == 0 && gsteps == 0) - error ("Must have some single or multi dimensional RGB or CMY steps"); - } else { - if (ssteps == 0 && fsteps == 0 && msteps == 0 && bsteps == 0 && gsteps == 0) - error ("Must have some single or multi dimensional steps"); - } + if (ssteps == 0 && fsteps == 0 && msteps == 0 && bsteps == 0 && gsteps == 0) + error ("Must have some single or multi dimensional RGB or CMY steps"); + } else { + if (ssteps == 0 && fsteps == 0 && msteps == 0 && bsteps == 0 && gsteps == 0) + error ("Must have some single or multi dimensional steps"); + } - /* Deal with ICC, MPP or fallback profile */ - if ((pdata = new_pcpt(pname, xmask, nmask, &ilimit, &uilimit, nemph, demph, xpow)) == NULL) { - error("Perceptual lookup object creation failed"); - } + /* Deal with ICC, MPP or fallback profile */ + if ((pdata = new_pcpt(pname, xmask, nmask, &ilimit, &uilimit, nemph, demph, xpow)) == NULL) { + error("Perceptual lookup object creation failed"); + } - /* Set default adapation level */ - if (dadapt < -1.5) { /* Not set by user */ - if (pname[0] != '\000') - dadapt = 1.0; - else - dadapt = 0.1; - } + /* Set default adapation level */ + if (dadapt < -1.5) { /* Not set by user */ + if (pname[0] != '\000') + dadapt = 1.0; + else + dadapt = 0.1; + } - if (verb) { - printf("%s test chart\n",ident); - - if (esteps > 0) - printf("White patches = %d\n",esteps); - if (Bsteps > 0) - printf("Black patches = %d\n",Bsteps); - if (ssteps > 0) - printf("Single channel steps = %d\n",ssteps); - if (gsteps > 0) - printf("Compostie Grey steps = %d\n",gsteps); - if (fsteps > 0) - printf("Full spread patches = %d\n",fsteps); - if (msteps > 0) - printf("Multi-dimention cube steps = %d\n",msteps); - if (bsteps > 0) - printf("Multi-dimention body centered cube steps = %d\n",bsteps); - if (ilimit >= 0.0) - printf("Ink limit = %.1f%% (underlying %.1f%%)\n",ilimit * 100.0, uilimit * 100.0); - if (filter) { - printf("Filtering out samples outside sphere at %f %f %f radius %f\n", - filt[0], filt[1], filt[2], filt[3]); + if (verb) { + printf("%s test chart\n",ident); + + if (esteps > 0) + printf("White patches = %d\n",esteps); + if (Bsteps > 0) + printf("Black patches = %d\n",Bsteps); + if (ssteps > 0) + printf("Single channel steps = %d\n",ssteps); + if (gsteps > 0) + printf("Compostie Grey steps = %d\n",gsteps); + if (fsteps > 0) + printf("Full spread patches = %d\n",fsteps); + if (msteps > 0) + printf("Multi-dimention cube steps = %d\n",msteps); + if (bsteps > 0) + printf("Multi-dimention body centered cube steps = %d\n",bsteps); + if (ilimit >= 0.0) + printf("Ink limit = %.1f%% (underlying %.1f%%)\n",ilimit * 100.0, uilimit * 100.0); + if (filter) { + printf("Filtering out samples outside sphere at %f %f %f radius %f\n", + filt[0], filt[1], filt[2], filt[3]); + } } - } - pp = new_cgats(); /* Create a CGATS structure */ - pp->add_other(pp, "CTI1"); /* our special type is Calibration Target Information 1 */ - - pp->add_table(pp, tt_other, 0); /* Add the first table for target points */ - pp->add_table(pp, tt_other, 0); /* Add the second table for density pre-defined device values */ - pp->add_table(pp, tt_other, 0); /* Add the second table for device pre-defined device values */ - pp->add_kword(pp, 0, "DESCRIPTOR", "Argyll Calibration Target chart information 1",NULL); - pp->add_kword(pp, 1, "DESCRIPTOR", "Argyll Calibration Target chart information 1",NULL); - pp->add_kword(pp, 2, "DESCRIPTOR", "Argyll Calibration Target chart information 1",NULL); - pp->add_kword(pp, 0, "ORIGINATOR", "Argyll targen", NULL); - pp->add_kword(pp, 1, "ORIGINATOR", "Argyll targen", NULL); - pp->add_kword(pp, 2, "ORIGINATOR", "Argyll targen", NULL); - atm[strlen(atm)-1] = '\000'; /* Remove \n from end */ - pp->add_kword(pp, 0, "CREATED",atm, NULL); - - /* Make available the aproximate white point to allow relative */ - /* interpretation of the aproximate XYZ values */ - { - int e; - double val[MXTD], XYZ[3]; + pp = new_cgats(); /* Create a CGATS structure */ + pp->add_other(pp, "CTI1"); /* our special type is Calibration Target Information 1 */ + + pp->add_table(pp, tt_other, 0); /* Add the first table for target points */ + pp->add_table(pp, tt_other, 0); /* Add the second table for density pre-defined device values */ + pp->add_table(pp, tt_other, 0); /* Add the second table for device pre-defined device values */ + pp->add_kword(pp, 0, "DESCRIPTOR", "Argyll Calibration Target chart information 1",NULL); + pp->add_kword(pp, 1, "DESCRIPTOR", "Argyll Calibration Target chart information 1",NULL); + pp->add_kword(pp, 2, "DESCRIPTOR", "Argyll Calibration Target chart information 1",NULL); + pp->add_kword(pp, 0, "ORIGINATOR", "Argyll targen", NULL); + pp->add_kword(pp, 1, "ORIGINATOR", "Argyll targen", NULL); + pp->add_kword(pp, 2, "ORIGINATOR", "Argyll targen", NULL); + atm[strlen(atm)-1] = '\000'; /* Remove \n from end */ + pp->add_kword(pp, 0, "CREATED",atm, NULL); + + /* Make available the aproximate white point to allow relative */ + /* interpretation of the aproximate XYZ values */ + { + int e; + double val[MXTD], XYZ[3]; - /* Setup device white */ - if (nmask & ICX_ADDITIVE) - for (e = 0; e < di; e++) - val[e] = 1.0; - else - for (e = 0; e < di; e++) - val[e] = 0.0; - pdata->dev_to_XYZ(pdata, XYZ, val); /* Lookup white XYZ */ + /* Setup device white */ + if (nmask & ICX_ADDITIVE) + for (e = 0; e < di; e++) + val[e] = 1.0; + else + for (e = 0; e < di; e++) + val[e] = 0.0; + pdata->dev_to_XYZ(pdata, XYZ, val); /* Lookup white XYZ */ - sprintf(buf,"%f %f %f", 100.0 * XYZ[0], 100.0 * XYZ[1], 100.0 * XYZ[2]); - pp->add_kword(pp, 0, "APPROX_WHITE_POINT", buf, NULL); - } + sprintf(buf,"%f %f %f", 100.0 * XYZ[0], 100.0 * XYZ[1], 100.0 * XYZ[2]); + pp->add_kword(pp, 0, "APPROX_WHITE_POINT", buf, NULL); + } - pp->add_field(pp, 0, "SAMPLE_ID", cs_t); - pp->add_field(pp, 1, "INDEX", i_t); /* Index no. 0..7 in second table */ - pp->add_field(pp, 2, "INDEX", i_t); /* Index no. 0..7 in third table */ + pp->add_field(pp, 0, "SAMPLE_ID", cs_t); + pp->add_field(pp, 1, "INDEX", i_t); /* Index no. 0..7 in second table */ + pp->add_field(pp, 2, "INDEX", i_t); /* Index no. 0..7 in third table */ - /* Setup CGATS fields */ - { - int j; - char c_ilimit[20]; - char *bident = icx_inkmask2char(xmask, 0); + /* Setup CGATS fields */ + { + int j; + char c_ilimit[20]; + char *bident = icx_inkmask2char(xmask, 0); - for (j = 0; j < di; j++) { - int imask; - char fname[100]; + for (j = 0; j < di; j++) { + int imask; + char fname[100]; - imask = icx_index2ink(xmask, j); - sprintf(fname,"%s_%s",nmask == ICX_W || nmask == ICX_K ? "GRAY" : bident, - icx_ink2char(imask)); + imask = icx_index2ink(xmask, j); + sprintf(fname,"%s_%s",nmask == ICX_W || nmask == ICX_K ? "GRAY" : bident, + icx_ink2char(imask)); - pp->add_field(pp, 0, fname, r_t); - pp->add_field(pp, 1, fname, r_t); - pp->add_field(pp, 2, fname, r_t); - } + pp->add_field(pp, 0, fname, r_t); + pp->add_field(pp, 1, fname, r_t); + pp->add_field(pp, 2, fname, r_t); + } - pp->add_kword(pp, 0, "COLOR_REP", ident, NULL); + pp->add_kword(pp, 0, "COLOR_REP", ident, NULL); - if (ilimit >= 0.0) { - sprintf(c_ilimit,"%5.1f",ilimit * 100.0); - pp->add_kword(pp, 0, "TOTAL_INK_LIMIT", c_ilimit, NULL); + if (ilimit >= 0.0) { + sprintf(c_ilimit,"%5.1f",ilimit * 100.0); + pp->add_kword(pp, 0, "TOTAL_INK_LIMIT", c_ilimit, NULL); + } + free(bident); } - free(bident); - } - /* ilimit is assumed to be in a valid range from here on */ - if (ilimit < 0.0) { - uilimit = ilimit = di; /* default is no limit */ - } + /* ilimit is assumed to be in a valid range from here on */ + if (ilimit < 0.0) { + uilimit = ilimit = di; /* default is no limit */ + } - /* Add expected XYZ values to aid previews, scan recognition & strip recognition */ - pp->add_field(pp, 0, "XYZ_X", r_t); - pp->add_field(pp, 0, "XYZ_Y", r_t); - pp->add_field(pp, 0, "XYZ_Z", r_t); - pp->add_field(pp, 1, "XYZ_X", r_t); - pp->add_field(pp, 1, "XYZ_Y", r_t); - pp->add_field(pp, 1, "XYZ_Z", r_t); - pp->add_field(pp, 2, "XYZ_X", r_t); - pp->add_field(pp, 2, "XYZ_Y", r_t); - pp->add_field(pp, 2, "XYZ_Z", r_t); - - /* Note if the expected values are expected to be accurate */ - if (pdata->is_specific(pdata)) - pp->add_kword(pp, 0, "ACCURATE_EXPECTED_VALUES", "true", NULL); - - if (xpow != 1.0) { - sprintf(buf,"%f",xpow); - pp->add_kword(pp, 0, "EXTRA_DEV_POW",buf, NULL); - } + /* Add expected XYZ values to aid previews, scan recognition & strip recognition */ + pp->add_field(pp, 0, "XYZ_X", r_t); + pp->add_field(pp, 0, "XYZ_Y", r_t); + pp->add_field(pp, 0, "XYZ_Z", r_t); + pp->add_field(pp, 1, "XYZ_X", r_t); + pp->add_field(pp, 1, "XYZ_Y", r_t); + pp->add_field(pp, 1, "XYZ_Z", r_t); + pp->add_field(pp, 2, "XYZ_X", r_t); + pp->add_field(pp, 2, "XYZ_Y", r_t); + pp->add_field(pp, 2, "XYZ_Z", r_t); + + /* Note if the expected values are expected to be accurate */ + if (pdata->is_specific(pdata)) + pp->add_kword(pp, 0, "ACCURATE_EXPECTED_VALUES", "true", NULL); + + if (xpow != 1.0) { + sprintf(buf,"%f",xpow); + pp->add_kword(pp, 0, "EXTRA_DEV_POW",buf, NULL); + } - if (demph > 1.0) { - sprintf(buf,"%f",demph); - pp->add_kword(pp, 0, "DARK_REGION_EMPHASIS",buf, NULL); - } + if (demph > 1.0) { + sprintf(buf,"%f",demph); + pp->add_kword(pp, 0, "DARK_REGION_EMPHASIS",buf, NULL); + } - /* Only use optimsed full spread if <= 4 dimensions, else use ifarp */ - if (di > 4 - && userand == 0 /* Not other high D useful method */ - && useqrand == 0 - && usedsim == 0 - && usepsim == 0) - uselat = 1; + /* Only use optimsed full spread if <= 4 dimensions, else use ifarp */ + if (di > 4 + && userand == 0 /* Not other high D useful method */ + && useqrand == 0 + && usedsim == 0 + && usepsim == 0) + uselat = 1; - /* Allocate space to record fixed steps */ - { - fxlist_a = 4; - if ((fxlist = (fxpos *)malloc(sizeof(fxpos) * fxlist_a)) == NULL) + /* Allocate space to record fixed steps */ + { + fxlist_a = 4; + if ((fxlist = (fxpos *)malloc(sizeof(fxpos) * fxlist_a)) == NULL) error ("Failed to malloc fxlist"); } @@ -1937,6 +1960,7 @@ int main(int argc, char *argv[]) { #endif /* ADDRECCLIPPOINTS */ } + /* Regular body centered cubic gridded Multi dimension steps */ if (bsteps > 0) { int gc[MXTD]; /* Grid coordinate */ @@ -2279,7 +2303,7 @@ int main(int argc, char *argv[]) { /* If this seems to be for a CRT, optimise the patch order to minimise the */ /* response time delays */ - if (nmask == ICX_RGB && pp->t[0].nsets > 1) { + if (nmask == ICX_RGB && pp->t[0].nsets > 1 && dontreorder == 0) { int npat = pp->t[0].nsets; char *nm; /* Don't move array */ double udelay, *delays, adelay; @@ -2386,7 +2410,7 @@ int main(int argc, char *argv[]) { int p1, p2, bp2; double p1d, p2d, p1d1, p2d1; double p1nd, p2nd, p1nd1, p2nd1; - double tdelay, de; + double tdelay, bdelay, de; int noswapped; chend = chstart + chsize+2; @@ -2396,7 +2420,7 @@ int main(int argc, char *argv[]) { //printf("~1 chstart %d, chend %d, size %d\n",chstart,chend, chend - chstart); /* While we are still improving, and the improvement was significant */ - for (;noswapped > 5;) { + for (;noswapped > 2;) { noswapped = 0; for (p1 = chstart + 1; p1 < chend; p1++) { @@ -2407,6 +2431,7 @@ int main(int argc, char *argv[]) { /* Locate the patch ahead of us that is best to swap with */ bp2 = -1; + bdelay = udelay; for (p2 = p1 + 2; p2 < chend; p2++) { if (nm[p2]) @@ -2429,14 +2454,18 @@ int main(int argc, char *argv[]) { tdelay = udelay - p1d - p2d - p1d1 - p2d1 + p1nd + p2nd + p1nd1 + p2nd1; - if (tdelay < udelay) { + if (tdelay < bdelay) /* Improve it */ +// if (tdelay > bdelay) /* Make it worse */ + { bp2 = p2; + bdelay = tdelay; } } if (bp2 < 0) { continue; } + /* Swap the patches */ noswapped++; p2 = bp2; @@ -2660,7 +2689,7 @@ int main(int argc, char *argv[]) { ttime = clock() - stime; if (verb) { - printf("Total number of patches = %d\n",id-1); + printf("Total number of patches = %d\n",pp->t[0].nsets); if (id < (1 + (1 << di))) printf("WARNING : not enough patches for %d channels, need at least %d\n",di,(1 + (1 << di))); printf("Execution time = %f seconds\n",ttime/(double)CLOCKS_PER_SEC); @@ -2669,14 +2698,16 @@ int main(int argc, char *argv[]) { if (pp->write_name(pp, fname)) error("Write error : %s",pp->err); -#ifdef VRML_DIAG /* Dump a VRML of the resulting points */ +#ifdef VRML_DIAG /* Dump a VRML/X3D of the resulting points */ if (dumpvrml & 1) { /* Lab space */ vrml *wrl; int nsets = pp->t[0].nsets; double rad; double dev[MXTD], Lab[3], col[3]; + int doaxes = 1; /* Do axes */ - wrl = new_vrml(wlname, 1, 0); /* Do axes */ + if ((wrl = new_vrml(wlname, doaxes, 0)) == NULL) + error("new_vrml failed for '%s%s'",wlname,vrml_ext()); /* Fudge sphere diameter */ rad = 15.0/pow(nsets, 1.0/(double)(di <= 3 ? di : 3)); @@ -2747,8 +2778,10 @@ int main(int argc, char *argv[]) { /* - - - - - - - - - - - - - - - - - - - - - - - - - - */ +#ifdef NEVER + /* Compte the display response time */ -static double disprespt(cgats *pp, int p1, int p2) { +static double disprespt2(cgats *pp, int p1, int p2) { double kr, kf; double orgb[3], rgb[3]; double xdelay = 0.0; @@ -2771,9 +2804,9 @@ static double disprespt(cgats *pp, int p1, int p2) { el = pow(rgb[j], 2.2); dl = el - pow(orgb[j], 2.2); /* Change in level */ if (fabs(dl) > 0.01) { /* More than 1% change in level */ - n = DISPLAY_SETTLE_AIM * el; - if (n < DISPLAY_ABS_AIM) - n = DISPLAY_ABS_AIM; + n = DISPLAY_SETTLE_AIM2 * el; + if (n < DISPLAY_ABS_AIM2) + n = DISPLAY_ABS_AIM2; if (dl > 0.0) t = kr * log(n/dl); else @@ -2786,8 +2819,23 @@ static double disprespt(cgats *pp, int p1, int p2) { return xdelay; } +#endif + +/* Compte the display response time */ +static double disprespt(cgats *pp, int p1, int p2) { + double orgb[3], nrgb[3]; + double xdelay = 0.0; + orgb[0] = *((double *)pp->t[0].fdata[p1][1 + 0]) / 100.0; + orgb[1] = *((double *)pp->t[0].fdata[p1][1 + 1]) / 100.0; + orgb[2] = *((double *)pp->t[0].fdata[p1][1 + 2]) / 100.0; + nrgb[0] = *((double *)pp->t[0].fdata[p2][1 + 0]) / 100.0; + nrgb[1] = *((double *)pp->t[0].fdata[p2][1 + 1]) / 100.0; + nrgb[2] = *((double *)pp->t[0].fdata[p2][1 + 2]) / 100.0; + xdelay = disp_settle_time(orgb, nrgb, DISPLAY_RISE_TIME, DISPLAY_FALL_TIME, DISPLAY_SETTLE_AIM); + return xdelay; +} |