Changeset 5846 for trunk/Ohana/src/opihi/cmd.data/tv.c
- Timestamp:
- Dec 27, 2005, 5:06:32 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/tv.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/tv.c
r4689 r5846 3 3 int tv (int argc, char **argv) { 4 4 5 int N, j, Npix, Ncolors, size, ISLOG, NNcol; 6 char buffer[1024]; 7 double a1, a2, max, min, zero, range; 8 float *in; 9 char *out, *outbuffer, *root; 10 int Ximage, Nimage; 5 int N, Ximage, Nimage; 11 6 Coords coords; 12 7 Buffer *buf; 8 KiiImage image; 9 KiiDisplayMode mode; 13 10 14 11 Nimage = -1; … … 22 19 /* shell exits on pipe close, FIX */ 23 20 if ((N = get_argument (argc, argv, "-kill"))) { 24 close (Ximage);21 KiiClose (Ximage); 25 22 Ximage = 0; 26 23 return (TRUE); 27 24 } 28 25 29 min = max = 0.0; 30 ISLOG = FALSE; 26 mode.logflux = FALSE; 31 27 if ((N = get_argument (argc, argv, "-log"))) { 32 28 remove_argument (N, &argc, argv); 33 ISLOG= TRUE;29 mode.logflux = TRUE; 34 30 } 35 31 … … 39 35 } 40 36 41 GetImageScale (& zero, &range);37 GetImageScale (&mode.zero, &mode.range); 42 38 if (argc == 4) { 43 zero = atof (argv[2]);44 range = atof (argv[3]);45 if ( range == 0.0)range = 0.001;46 SetImageScale ( zero,range);39 mode.zero = atof (argv[2]); 40 mode.range = atof (argv[3]); 41 if (mode.range == 0.0) mode.range = 0.001; 42 SetImageScale (mode.zero, mode.range); 47 43 } 48 44 49 45 if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE); 50 46 GetCoords (&coords, &buf[0].header); 47 48 image.data1d = (float *) buf[0].matrix.buffer; 49 image.Nx = buf[0].matrix.Naxis[0]; 50 image.Ny = buf[0].matrix.Naxis[1]; 51 image.file = buf[0].file; 52 image.name = buf[0].name; 51 53 52 Npix = buf[0].matrix.Naxis[0]*buf[0].matrix.Naxis[1]; 53 size = Npix * sizeof (char); 54 in = (float *) (buf[0].matrix.buffer); 55 ALLOCATE (outbuffer, char, Npix); 56 out = outbuffer; 57 58 SendGraphCommand (Ximage, 4, "READ"); /* tell Ximage to look for the incoming image */ 59 60 /* convert from (float) internal rep to 1 byte chars -- depends on how many colors Kii owns*/ 61 read (Ximage, buffer, 16); 62 sscanf (buffer, "%*s %d", &Ncolors); 63 64 /* need to invert the logic if range < 0 */ 65 /* define color table, */ 66 NNcol = Ncolors - 1; 67 if (ISLOG) { 68 range = MAX (2, range); 69 a1 = Ncolors / log10 (range); 70 for (j = 0; j < Npix; j++, in++, out++) { 71 *out = (char) MIN (a1 * log10 (MAX (*in - zero, 1.0)), NNcol); 72 } 73 } 74 if (!ISLOG) { 75 a1 = Ncolors / range; 76 a2 = Ncolors * zero / range; 77 for (j = 0; j < Npix; j++, in++, out++) { 78 *out = (char) MIN (MAX (a1 * *in - a2, 0), NNcol); 79 } 80 } 81 82 /* done with the conversion, now send Ximage the converted picture */ 83 SendGraphMessage (Ximage, "%8d %8d 8 1 %f %f", buf[0].matrix.Naxis[0], buf[0].matrix.Naxis[1], 0.0, 1.0); 84 SendGraphMessage (Ximage, "%f %f %f %f %d ", zero, range, min, max, size); 85 SendGraphMessage (Ximage, "%f %f %g %g %g ", coords.crval1, coords.crpix1, coords.cdelt1, coords.pc1_1, coords.pc1_2); 86 SendGraphMessage (Ximage, "%f %f %g %g %g ", coords.crval2, coords.crpix2, coords.cdelt2, coords.pc2_1, coords.pc2_2); 87 88 root = filerootname (buf[0].file); 89 SendGraphMessage (Ximage, "%s %s %s ", coords.ctype, root, buf[0].name); 90 write (Ximage, outbuffer, size); 91 free (outbuffer); 54 KiiNewPicture1D (Ximage, &image, &mode, &coords); 92 55 93 56 SetImageName (argv[1]);
Note:
See TracChangeset
for help on using the changeset viewer.
