add machinable output
This commit is contained in:
parent
3eb2f549ee
commit
60b4181f3c
@ -14,15 +14,33 @@ int verbosity; /* global */
|
||||
int make_csv;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int various_numbers(FloatImg *fimg, int k)
|
||||
int machinable(FloatImg *fimg)
|
||||
{
|
||||
float vals[6];
|
||||
float means[4];
|
||||
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "%s numbers from %p :\n", __func__, fimg);
|
||||
}
|
||||
|
||||
fimg_meanvalues(fimg, means);
|
||||
fimg_get_minmax_rgb(fimg, vals);
|
||||
printf( "%.3f %.3f %.3f %f.3 %.3f %.3f %.3f %.3f %.3f\n",
|
||||
vals[0], means[0], vals[1],
|
||||
vals[2], means[1], vals[3],
|
||||
vals[4], means[2], vals[5]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int various_numbers(FloatImg *fimg)
|
||||
{
|
||||
float moyennes[4];
|
||||
int foo;
|
||||
// float fvalue;
|
||||
float vals[6];
|
||||
|
||||
if (verbosity) {
|
||||
fprintf(stderr, " numbers from %p :\n", fimg);
|
||||
fprintf(stderr, "%s numbers from %p :\n", __func__, fimg);
|
||||
}
|
||||
|
||||
fimg_printhead(fimg);
|
||||
@ -60,7 +78,9 @@ int various_numbers_from_file(char *fname, int k)
|
||||
FloatImg fimg;
|
||||
int foo;
|
||||
|
||||
fprintf(stderr, "------ numbers from '%s' :\n", fname);
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "------ numbers from '%s' :\n", fname);
|
||||
}
|
||||
|
||||
foo = fimg_create_from_dump(fname, &fimg);
|
||||
if (foo) {
|
||||
@ -68,10 +88,17 @@ if (foo) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
various_numbers(&fimg, k);
|
||||
|
||||
if (k) {
|
||||
foo = machinable(&fimg);
|
||||
}
|
||||
else {
|
||||
foo = various_numbers(&fimg);
|
||||
}
|
||||
fimg_destroy(&fimg);
|
||||
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: got a %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
@ -86,7 +113,7 @@ fputs( "usage : fimgstats [options] file.fimg\n"
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
|
||||
int do_machinable = 0;
|
||||
extern char *optarg;
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
@ -95,11 +122,11 @@ if (argc == 1) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
while ((opt = getopt(argc, argv, "chv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "chmv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'c': make_csv++; break;
|
||||
case 'v': verbosity++; break;
|
||||
|
||||
case 'm': do_machinable = 1; break;
|
||||
case 'h': /* tombe dedans */
|
||||
default: help(1); exit(1);
|
||||
}
|
||||
@ -109,7 +136,7 @@ if (NULL==argv[optind]) {
|
||||
fprintf(stderr, "optind %d is wtf\n", optind);
|
||||
return 1;
|
||||
}
|
||||
foo = various_numbers_from_file(argv[optind], 0);
|
||||
foo = various_numbers_from_file(argv[optind], do_machinable);
|
||||
if (foo) {
|
||||
fprintf(stderr, "got a %d ?\n", foo);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user