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.15 by greg, Thu Feb 6 11:36:53 1997 UTC vs.
Revision 2.17 by greg, Sat Feb 22 02:07:27 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1997 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Calibrate a scanned MacBeth Color Checker Chart
6   *
# Line 18 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #ifdef MSDOS
16   #include <fcntl.h>
17   #endif
18 + #include  <time.h>
19   #include "color.h"
20   #include "resolu.h"
21   #include "pmap.h"
# Line 100 | Line 98 | short  mbneu[NMBNEU] = {Black,Neutral35,Neutral5,Neutra
98   #define  RG_ORIG        02      /* original color region */
99   #define  RG_CORR        04      /* corrected color region */
100  
101 + #ifndef  DISPCOM
102 + #define  DISPCOM        "ximage -op %s"
103 + #endif
104 +
105   int     scanning = 1;           /* scanned input (or recorded output)? */
106   double  irrad = 1.0;            /* irradiance multiplication factor */
107   int     rawmap = 0;             /* put out raw color mapping? */
# Line 121 | Line 123 | WARP3D *wcor = NULL;           /* color space warp */
123   FILE    *debugfp = NULL;        /* debug output picture */
124   char    *progname;
125  
124 extern char     *malloc();
126  
126
127   main(argc, argv)
128   int     argc;
129   char    **argv;
# Line 160 | Line 160 | char   **argv;
160                          bounds[3][1] = atoi(argv[++i]);
161                          scanning = 2;
162                          break;
163 +                case 'P':                               /* pick position */
164 +                        scanning = 3;
165 +                        break;
166                  case 'i':                               /* irradiance factor */
167                          i++;
168                          if (badarg(argc-i, argv+i, "f"))
# Line 193 | Line 196 | char   **argv;
196                          fprintf(stderr, "%s: bad input picture\n", progname);
197                          exit(1);
198                  }
199 +                if (scanning == 3) {
200 +                        if (i >= argc)
201 +                                goto userr;
202 +                        pickchartpos(argv[i]);
203 +                        scanning = 2;
204 +                }
205          } else {                        /* else set default xmax and ymax */
206                  xmax = 512;
207                  ymax = 2*512/3;
# Line 245 | Line 254 | char   **argv;
254          exit(0);
255   userr:
256          fprintf(stderr,
257 < "Usage: %s [-d dbg.pic][-p xul yul xur yur xll yll xlr ylr][-i irrad][-m] input.pic [output.{cal|cwp}]\n",
257 > "Usage: %s [-d dbg.pic][-P | -p xul yul xur yur xll yll xlr ylr][-i irrad][-m] input.pic [output.{cal|cwp}]\n",
258                          progname);
259          fprintf(stderr, "   or: %s [-d dbg.pic][-i irrad][-m] -c [xyY.dat [output.{cal|cwp}]]\n",
260                          progname);
# Line 349 | Line 358 | getpicture()                           /* load in picture colors */
358                  scalecolor(inpRGB[i], d);
359                  inpflags |= 1L<<i;
360          }
361 <        free((char *)scanln);
361 >        free((void *)scanln);
362   }
363  
364  
# Line 699 | Line 708 | picdebug()                     /* put out debugging picture */
708          }
709                                                  /* clean up */
710          fclose(debugfp);
711 <        free((char *)scan);
711 >        free((void *)scan);
712   }
713  
714  
# Line 769 | Line 778 | clrdebug()                     /* put out debug picture from color input
778          }
779                                                  /* clean up */
780          fclose(debugfp);
781 <        free((char *)scan);
781 >        free((void *)scan);
782 > }
783 >
784 >
785 > getpos(name, bnds, fp)          /* get boundary position */
786 > char    *name;
787 > int     bnds[2];
788 > FILE    *fp;
789 > {
790 >        char    buf[64];
791 >
792 >        fprintf(stderr, "\tSelect corner: %s\n", name);
793 >        if (fgets(buf, sizeof(buf), fp) == NULL ||
794 >                        sscanf(buf, "%d %d", &bnds[0], &bnds[1]) != 2) {
795 >                fprintf(stderr, "%s: read error from display process\n",
796 >                                progname);
797 >                exit(1);
798 >        }
799 > }
800 >
801 >
802 > pickchartpos(pfn)               /* display picture and pick chart location */
803 > char    *pfn;
804 > {
805 >        char    combuf[512];
806 >        FILE    *pfp;
807 >
808 >        sprintf(combuf, DISPCOM, pfn);
809 >        if ((pfp = popen(combuf, "r")) == NULL) {
810 >                perror(combuf);
811 >                exit(1);
812 >        }
813 >        fputs("Use middle mouse button to select chart corners:\n", stderr);
814 >        getpos("upper left (dark skin)", bounds[0], pfp);
815 >        getpos("upper right (bluish green)", bounds[1], pfp);
816 >        getpos("lower left (white)", bounds[2], pfp);
817 >        getpos("lower right (black)", bounds[3], pfp);
818 >        fputs("Got it -- quit display program.\n", stderr);
819 >        pclose(pfp);
820   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines