Merge branch 'master' of ssh://tetalab.org:2213/tTh/FloatImg

attaque du raspi en cours
This commit is contained in:
tonton th 2021-02-28 18:19:20 +01:00
commit 10c92cc212
2 changed files with 22 additions and 19 deletions

View File

@ -8,7 +8,6 @@
#include "../floatimg.h"
int verbosity;
int g_width, g_height;
/* --------------------------------------------------------------------- */
@ -18,9 +17,7 @@ int foo, numbers[3];
foo = fimg_fileinfos(path, numbers);
if (foo) {
#if DEBUG_LEVEL
fprintf(stderr, "fileinfo of '%s' -> err %d\n", path, foo);
#endif
return foo;
}

View File

@ -16,7 +16,8 @@ int verbosity;
int export_as_machinable(FloatImg *src, char *fname, int steps, int flags)
{
FILE *fp;
int x, y, idx;
int x, y;
float rgb[3];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %25s ( %p '%s' %d )\n", __func__,
@ -25,22 +26,19 @@ fprintf(stderr, ">>> %25s ( %p '%s' %d )\n", __func__,
fp = NULL; /* molly guard */
if (strcmp("-", fname)) { /* real file */
fprintf(stderr, "real file\n");
fprintf(stderr, "real file '%s'\n", fname);
}
else {
fprintf(stderr, "kitchen sink\n");
// fprintf(stderr, "kitchen sink\n");
}
idx = 0;
fp = stdout; /* XXX */
for (y=0; y<src->height; y+=steps) {
for (x=0; x<src->width; x+=steps) {
fimg_get_rgb(src, x, y, rgb);
fprintf(fp, "%d %d ", x, y);
fprintf(fp, " %f %f %f\n",
src->R[idx], src->G[idx], src->B[idx]);
idx++;
fprintf(fp, "%f %f %f\n", rgb[0], rgb[1], rgb[2]);
}
}
@ -57,13 +55,19 @@ fprintf(stderr, ">>> %s ( %p %g )\n", __func__, pimg, vmax);
#endif
foo = fimg_get_minmax_rgb(pimg, mmv);
// fimg_print_minmax(mmv, "norm it ?");
if (foo) {
fprintf(stderr, "%s: ABEND\n", __func__);
abort();
}
maxi = mmv[1];
if (mmv[3] > maxi) maxi = mmv[3];
if (mmv[5] > maxi) maxi = mmv[5];
// fprintf(stderr, "maximum = %f\n", maxi);
coef = vmax / maxi;
// fprintf(stderr, "coef = %f\n", coef);
if (verbosity) {
fprintf(stderr, "mins %f %f %f\n", mmv[0], mmv[2], mmv[4]);
fprintf(stderr, "maxs %f %f %f\n", mmv[1], mmv[3], mmv[5]);
fprintf(stderr, "coef = %f\n", coef);
}
sz = pimg->width * pimg->height;
@ -108,9 +112,10 @@ if (foo) {
if (verbosity) {
fimg_describe(&fimg, srcname);
fprintf(stderr, "normalize to %f\n", norm);
}
if (norm > 0.0) {
fprintf(stderr, "normalize %p\n", &fimg);
// fprintf(stderr, "normalize %p\n", &fimg);
foo = normalize(&fimg, norm);
}
@ -139,7 +144,7 @@ int foo, opt;
int steps = 16;
float norm_val = 222.0; /* < 0 : don't normalize */
while ((opt = getopt(argc, argv, "hs:v")) != -1) {
while ((opt = getopt(argc, argv, "hn:s:v")) != -1) {
switch(opt) {
case 'v': verbosity++; break;
case 'h': help(1); exit(1);
@ -149,13 +154,14 @@ while ((opt = getopt(argc, argv, "hs:v")) != -1) {
}
if (1 != argc-optind) {
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
fprintf(stderr, "error: %s need one filename\n", argv[0]);
exit(1);
}
foo = convertir_fimg_en_machinable(argv[optind], "-", steps, norm_val);
if (foo)
if (foo) {
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
}
return 0;
}