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.10 by greg, Wed Nov 1 09:04:16 1995 UTC vs.
Revision 2.11 by greg, Thu Jan 30 17:07:42 1997 UTC

# Line 95 | Line 95 | short  mbneu[NMBNEU] = {Black,Neutral35,Neutral5,Neutra
95   #define  RG_ORIG        02      /* original color region */
96   #define  RG_CORR        04      /* corrected color region */
97  
98 + int     scanning = 1;           /* scanned input (or recorded output)? */
99 +
100   int     xmax, ymax;             /* input image dimensions */
101   int     bounds[4][2];           /* image coordinates of chart corners */
102   double  imgxfm[3][3];           /* coordinate transformation matrix */
# Line 116 | Line 118 | main(argc, argv)
118   int     argc;
119   char    **argv;
120   {
119        int     inpispic = 1;
121          int     i;
122  
123          progname = argv[0];
# Line 147 | Line 148 | char   **argv;
148                          bounds[2][1] = atoi(argv[++i]);
149                          bounds[3][0] = atoi(argv[++i]);
150                          bounds[3][1] = atoi(argv[++i]);
151 <                        inpispic = 2;
151 >                        scanning = 2;
152                          break;
153                  case 'c':                               /* color input */
154 <                        inpispic = 0;
154 >                        scanning = 0;
155                          break;
156                  default:
157                          goto userr;
# Line 164 | Line 165 | char   **argv;
165                  perror(argv[2]);
166                  exit(1);
167          }
168 <        if (inpispic) {                 /* load input picture header */
168 >        if (scanning) {                 /* load input picture header */
169   #ifdef MSDOS
170                  setmode(fileno(stdin), O_BINARY);
171   #endif
# Line 177 | Line 178 | char   **argv;
178                  xmax = 512;
179                  ymax = 2*512/3;
180          }
181 <        if (inpispic != 2) {            /* use default boundaries */
181 >        if (scanning != 2) {            /* use default boundaries */
182                  bounds[0][0] = bounds[2][0] = .029*xmax + .5;
183                  bounds[0][1] = bounds[1][1] = .956*ymax + .5;
184                  bounds[1][0] = bounds[3][0] = .971*xmax + .5;
185                  bounds[2][1] = bounds[3][1] = .056*ymax + .5;
186          }
187          init();                         /* initialize */
188 <        if (inpispic)                   /* get picture colors */
188 >        if (scanning)                   /* get picture colors */
189                  getpicture();
190          else
191                  getcolors();
# Line 194 | Line 195 | char   **argv;
195          printargs(argc, argv, stdout);
196          printf("\n\tUsage: pcomb -f %s uncorrected.pic > corrected.pic\n",
197                          i+1 < argc ? argv[i+1] : "{this_file}");
198 +        if (!scanning)
199 +                printf("\t   Or: pcond [options] -f %s orig.pic > output.pic\n",
200 +                                i+1 < argc ? argv[i+1] : "{this_file}");
201          printf("}\n");
202          putmapping();                   /* put out color mapping */
203          if (debugfp != NULL)            /* put out debug picture */
204 <                if (inpispic)
204 >                if (scanning)
205                          picdebug();
206                  else
207                          clrdebug();
# Line 407 | Line 411 | compute()                      /* compute color mapping */
411                                                  /* check out-of-gamut colors */
412                  for (i = 0; i < 24; i++)
413                          if (cflags & 1L<<i) {
414 <                                cresp(ctmp, mbRGB[i]);
414 >                                cvtcolor(ctmp, mbRGB[i]);
415                                  for (j = 0; j < 3; j++)
416 <                                        if (colval(ctmp,j) <= 0. ||
417 <                                                colval(ctmp,j) >= 1.) {
416 >                                        if (colval(ctmp,j) <= 1e-6 ||
417 >                                                colval(ctmp,j) >= 1.-1e-6) {
418                                                  gmtflags |= 1L<<i;
419                                                  break;
420                                          }
# Line 437 | Line 441 | putmapping()                   /* put out color mapping for pcomb -f *
441                  for (i = 0; i < NMBNEU; i++)
442                          printf(",%g", colval(bramp[i][1],j));
443                  printf(");\n");
440                printf("%c = %ci(1);\n", cchar[j], cchar[j]);
444                  printf("%cfi(n) = if(n-%g, %d, if(%cxa(n+1)-%c, n, %cfi(n+1)));\n",
445                                  cchar[j], NMBNEU-1.5, NMBNEU-1, cchar[j],
446                                  cchar[j], cchar[j]);
447                  printf("%cndx = %cfi(1);\n", cchar[j], cchar[j]);
448 <                printf("%cn = ((%cxa(%cndx+1)-%c)*%cya(%cndx) + ",
449 <                                cchar[j], cchar[j], cchar[j],
450 <                                cchar[j], cchar[j], cchar[j]);
448 >                printf("%c%c = ((%cxa(%cndx+1)-%c)*%cya(%cndx) + ",
449 >                                cchar[j], scanning?'n':'o', cchar[j],
450 >                                cchar[j], cchar[j], cchar[j], cchar[j]);
451                  printf("(%c-%cxa(%cndx))*%cya(%cndx+1)) /\n",
452                                  cchar[j], cchar[j], cchar[j],
453                                  cchar[j], cchar[j]);
# Line 452 | Line 455 | putmapping()                   /* put out color mapping for pcomb -f *
455                                  cchar[j], cchar[j], cchar[j], cchar[j]);
456          }
457                                          /* print color mapping */
458 <        printf("ro = %g*rn + %g*gn + %g*bn ;\n",
459 <                        solmat[0][0], solmat[0][1], solmat[0][2]);
460 <        printf("go = %g*rn + %g*gn + %g*bn ;\n",
461 <                        solmat[1][0], solmat[1][1], solmat[1][2]);
462 <        printf("bo = %g*rn + %g*gn + %g*bn ;\n",
463 <                        solmat[2][0], solmat[2][1], solmat[2][2]);
458 >        if (scanning) {
459 >                printf("r = ri(1); g = gi(1); b = bi(1);\n");
460 >                printf("ro = %g*rn + %g*gn + %g*bn ;\n",
461 >                                solmat[0][0], solmat[0][1], solmat[0][2]);
462 >                printf("go = %g*rn + %g*gn + %g*bn ;\n",
463 >                                solmat[1][0], solmat[1][1], solmat[1][2]);
464 >                printf("bo = %g*rn + %g*gn + %g*bn ;\n",
465 >                                solmat[2][0], solmat[2][1], solmat[2][2]);
466 >        } else {
467 >                printf("r1 = ri(1); g1 = gi(1); b1 = bi(1);\n");
468 >                printf("r = %g*r1 + %g*g1 + %g*b1 ;\n",
469 >                                solmat[0][0], solmat[0][1], solmat[0][2]);
470 >                printf("g = %g*r1 + %g*g1 + %g*b1 ;\n",
471 >                                solmat[1][0], solmat[1][1], solmat[1][2]);
472 >                printf("b = %g*r1 + %g*g1 + %g*b1 ;\n",
473 >                                solmat[2][0], solmat[2][1], solmat[2][2]);
474 >        }
475   }
476  
477  
# Line 526 | Line 540 | COLOR  cout, cin;
540   {
541          COLOR   ctmp;
542  
543 <        bresp(ctmp, cin);
544 <        cresp(cout, ctmp);
543 >        if (scanning) {
544 >                bresp(ctmp, cin);
545 >                cresp(cout, ctmp);
546 >        } else {
547 >                cresp(ctmp, cin);
548 >                bresp(cout, ctmp);
549 >        }
550          if (colval(cout,RED) < 0.)
551                  colval(cout,RED) = 0.;
552          if (colval(cout,GRN) < 0.)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines