ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/macbethcal.c
(Generate patch)

Comparing ray/src/px/macbethcal.c (file contents):
Revision 2.8 by greg, Mon Oct 23 10:19:40 1995 UTC vs.
Revision 2.10 by greg, Wed Nov 1 09:04:16 1995 UTC

# Line 90 | Line 90 | short  mbneu[NMBNEU] = {Black,Neutral35,Neutral5,Neutra
90   #define  REQFLGS        NEUFLGS                 /* need these colors */
91   #define  MODFLGS        (NEUFLGS|UNSFLGS)       /* should be in gamut */
92  
93 < #define  CENTCVG        0.3     /* measured coverage of square sample */
94 < #define  FULLCVG        0.9     /* coverage of entire square */
93 > #define  RG_BORD        0       /* patch border */
94 > #define  RG_CENT        01      /* central region of patch */
95 > #define  RG_ORIG        02      /* original color region */
96 > #define  RG_CORR        04      /* corrected color region */
97  
98   int     xmax, ymax;             /* input image dimensions */
99   int     bounds[4][2];           /* image coordinates of chart corners */
# Line 188 | Line 190 | char   **argv;
190                  getcolors();
191          compute();                      /* compute color mapping */
192                                          /* print comment */
193 <        printf("{ Color correction file computed by:\n\t");
193 >        printf("{\n\tColor correction file computed by:\n\t\t");
194          printargs(argc, argv, stdout);
195 +        printf("\n\tUsage: pcomb -f %s uncorrected.pic > corrected.pic\n",
196 +                        i+1 < argc ? argv[i+1] : "{this_file}");
197          printf("}\n");
198          putmapping();                   /* put out color mapping */
199          if (debugfp != NULL)            /* put out debug picture */
# Line 233 | Line 237 | init()                         /* initialize */
237  
238  
239   int
240 < chartndx(x, y, cvg)                     /* find color number for position */
240 > chartndx(x, y, np)                      /* find color number for position */
241   int     x, y;
242 < double  cvg;
242 > int     *np;
243   {
244          double  ipos[3], cpos[3];
245          int     ix, iy;
246          double  fx, fy;
243        double  cmin, cmax;
247  
248          ipos[0] = x;
249          ipos[1] = y;
# Line 249 | Line 252 | double cvg;
252          cpos[0] /= cpos[2];
253          cpos[1] /= cpos[2];
254          if (cpos[0] < 0. || cpos[0] >= 6. || cpos[1] < 0. || cpos[1] >= 4.)
255 <                return(-1);
255 >                return(RG_BORD);
256          ix = cpos[0];
257          iy = cpos[1];
258          fx = cpos[0] - ix;
259          fy = cpos[1] - iy;
260 <        cmin = .5*(1.-cvg);
261 <        cmax = 1. - cmin;
262 <        if (fx < cmin || fx >= cmax || fy < cmin || fy >= cmax)
263 <                return(-1);
264 <        return(iy*6 + ix);
260 >        *np = iy*6 + ix;
261 >        if (fx >= 0.35 && fx < 0.65 && fy >= 0.35 && fy < 0.65)
262 >                return(RG_CENT);
263 >        if (fx < 0.05 || fx >= 0.95 || fy < 0.05 || fy >= 0.95)
264 >                return(RG_BORD);
265 >        if (fx >= 0.5)                  /* right side is corrected */
266 >                return(RG_CORR);
267 >        return(RG_ORIG);                /* left side is original */
268   }
269  
270  
# Line 268 | Line 274 | getpicture()                           /* load in picture colors */
274          COLOR   pval;
275          int     ccount[24];
276          double  d;
277 <        int     y;
278 <        register int    x, i;
277 >        int     y, i;
278 >        register int    x;
279  
280          scanln = (COLR *)malloc(xmax*sizeof(COLR));
281          if (scanln == NULL) {
# Line 286 | Line 292 | getpicture()                           /* load in picture colors */
292                                          progname);
293                          exit(1);
294                  }
295 <                for (x = 0; x < xmax; x++) {
296 <                        i = chartndx(x, y, CENTCVG);
291 <                        if (i >= 0) {
295 >                for (x = 0; x < xmax; x++)
296 >                        if (chartndx(x, y, &i) == RG_CENT) {
297                                  colr_color(pval, scanln[x]);
298                                  addcolor(inpRGB[i], pval);
299                                  ccount[i]++;
300                          }
296                }
301          }
302          for (i = 0; i < 24; i++) {              /* compute averages */
303                  if (ccount[i] == 0)
# Line 567 | Line 571 | picdebug()                     /* put out debugging picture */
571   {
572          static COLOR    blkcol = BLKCOLOR;
573          COLOR   *scan;
574 <        int     y;
575 <        register int    x, i;
574 >        int     y, i;
575 >        register int    x, rg;
576  
577          if (fseek(stdin, 0L, 0) == EOF) {
578                  fprintf(stderr, "%s: cannot seek on input picture\n", progname);
# Line 594 | Line 598 | picdebug()                     /* put out debugging picture */
598                          exit(1);
599                  }
600                  for (x = 0; x < xmax; x++) {
601 <                        i = chartndx(x, y, CENTCVG);
602 <                        if (i < 0)
601 >                        rg = chartndx(x, y, &i);
602 >                        if (rg == RG_CENT) {
603 >                                if (!(1L<<i & gmtflags) || (x+y)&07)
604 >                                        copycolor(scan[x], mbRGB[i]);
605 >                                else
606 >                                        copycolor(scan[x], blkcol);
607 >                        } else if (rg == RG_CORR)
608                                  cvtcolor(scan[x], scan[x]);
609 <                        else if (!(1L<<i & gmtflags) || (x+y)&07)
601 <                                copycolor(scan[x], mbRGB[i]);
602 <                        else
609 >                        else if (rg != RG_ORIG)
610                                  copycolor(scan[x], blkcol);
611                  }
612                  if (fwritescan(scan, xmax, debugfp) < 0) {
# Line 617 | Line 624 | picdebug()                     /* put out debugging picture */
624   clrdebug()                      /* put out debug picture from color input */
625   {
626          static COLR     blkclr = BLKCOLR;
627 <        COLR    mbclr[24], cvclr[24];
627 >        COLR    mbclr[24], cvclr[24], orclr[24];
628          COLR    *scan;
629          COLOR   ctmp;
630 <        int     y;
631 <        register int    i, x;
630 >        int     y, i;
631 >        register int    x, rg;
632                                                  /* convert colors */
633          for (i = 0; i < 24; i++) {
634                  setcolr(mbclr[i], colval(mbRGB[i],RED),
635                                  colval(mbRGB[i],GRN), colval(mbRGB[i],BLU));
636                  if (inpflags & 1L<<i) {
637 +                        setcolr(orclr[i], colval(inpRGB[i],RED),
638 +                                        colval(inpRGB[i],GRN),
639 +                                        colval(inpRGB[i],BLU));
640                          cvtcolor(ctmp, inpRGB[i]);
641                          setcolr(cvclr[i], colval(ctmp,RED),
642                                          colval(ctmp,GRN), colval(ctmp,BLU));
# Line 644 | Line 654 | clrdebug()                     /* put out debug picture from color input
654          fprtresolu(xmax, ymax, debugfp);
655                                                  /* write debug picture */
656          for (y = ymax-1; y >= 0; y--) {
657 <                for (x = 0; x < xmax; x++)
658 <                        if ((i = chartndx(x, y, CENTCVG)) >= 0) {
657 >                for (x = 0; x < xmax; x++) {
658 >                        rg = chartndx(x, y, &i);
659 >                        if (rg == RG_CENT) {
660                                  if (!(1L<<i & gmtflags) || (x+y)&07)
661                                          copycolr(scan[x], mbclr[i]);
662                                  else
663                                          copycolr(scan[x], blkclr);
664 <                        } else if ((i = chartndx(x, y, FULLCVG)) >= 0 &&
654 <                                        inpflags & 1L<<i)
655 <                                copycolr(scan[x], cvclr[i]);
656 <                        else
664 >                        } else if (rg == RG_BORD || !(1L<<i & inpflags))
665                                  copycolr(scan[x], blkclr);
666 +                        else if (rg == RG_ORIG)
667 +                                copycolr(scan[x], orclr[i]);
668 +                        else /* rg == RG_CORR */
669 +                                copycolr(scan[x], cvclr[i]);
670 +                }
671                  if (fwritecolrs(scan, xmax, debugfp) < 0) {
672                          fprintf(stderr, "%s: error writing debugging picture\n",
673                                          progname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines