25 static char rcs_ident[] =
"$Id: rlehisto.c,v 3.0.1.2 1992/02/11 21:36:13 spencer Exp $";
38 FILE *outfile = stdout;
39 int i, j, bflag=0, cflag=0, tflag=0, oflag=0;
40 int hist_height = 256;
41 rle_hdr in_hdr, out_hdr;
44 long *pixelcount[256];
49 char *infname = NULL, *outfname = NULL;
55 "% b%- c%- t%- h%-height!d o%-outfile!s infile%s",
56 &bflag
, &cflag
, &tflag
,
58 &oflag
, &outfname
, &infname
) == 0 )
73 bflag = (bflag && in_hdr
.bg_color != NULL);
90 out_hdr
.ymax = hist_height - 1;
105 for ( j = 0; j < 256; j++)
109 pixelcount[j] = (
long *) malloc(
sizeof(
long) * nchan);
112 for (chan=0; chan < nchan; chan++)
114 pixelcount[j][chan] = 0;
122 for (chan=0; chan < nchan; chan++)
125 for (i=0; i < in_hdr
.xmax + 1; i++)
126 pixelcount[ *pixptr++ ][ chan ] += 1;
133 for (chan = 0; chan < nchan; chan++)
135 for (j = 1; j < 256; j++)
136 pixelcount[j][chan] += pixelcount[j-1][chan];
137 if (pixelcount[255][chan] > maxcount)
138 maxcount = pixelcount[255][chan];
142 for ( chan = 0; chan < nchan; chan++ )
143 for ( j = 0; j < 256; j++ )
144 if ( bflag && j == in_hdr
.bg_color[chan] )
147 if ( pixelcount[j][chan] > maxcount )
148 maxcount = pixelcount[j][chan];
155 fprintf( outfile,
"\n\n" );
156 for (j = 0; j < 256; j++)
158 for (chan = 0; chan < nchan; chan++)
159 if (j > 0 && cflag) {
160 if (pixelcount[j][chan] != pixelcount[j-1][chan])
163 if (pixelcount[j][chan] != 0)
168 fprintf(outfile,
"%3d.", j);
169 for (chan = 0; chan < nchan; chan++)
170 fprintf(outfile,
"\t%ld", pixelcount[j][chan]);
171 fprintf(outfile,
"\n");
176 for (i = 0; i < hist_height; i++)
178 n = (maxcount * i) / (hist_height - 2);
179 for (chan = 0; chan < nchan; chan++)
181 for (j = 0; j < 256; j++)
183 if (pixelcount[j][chan] > n)
184 rowsout[chan][j] = 255;
186 rowsout[chan][j] = 0;
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
void rle_row_free(rle_hdr *the_hdr, rle_pixel **scanp)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
int rle_getrow(rle_hdr *the_hdr, scanline)
int rle_get_error(int code, const char *pgmname, const char *fname)
int scanargs(int argc, char **argv, const char *format,...)
void rle_puteof(rle_hdr *the_hdr)
void rle_putrow(rows, int rowlen, rle_hdr *the_hdr)
void rle_addhist(argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_put_setup(rle_hdr *the_hdr)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
#define RLE_CHECK_ALLOC(pgm, ptr, name)