40 int hist_height = 256;
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;
119 for (j=in_hdr.
ymin; j <= in_hdr.
ymax; j++)
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;
void rle_row_free(rle_hdr *the_hdr, rle_pixel **scanp)
int scanargs(int argc, char **argv, const char *format,...)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_puteof(rle_hdr *the_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
int rle_get_setup(rle_hdr *the_hdr)
int rle_get_error(int code, const char *pgmname, const char *fname)
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
void rle_put_setup(rle_hdr *the_hdr)
char * cmd_name(char **argv)
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
#define RLE_CHECK_ALLOC(pgm, ptr, name)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)