still tweaking...

This commit is contained in:
phyto 2020-12-07 22:02:08 +01:00
parent 8668e15d3e
commit ae7fdd49bc
3 changed files with 22 additions and 7 deletions

View File

@ -66,7 +66,7 @@ fprintf(stderr, "IdxValues array at %p\n", idxvalues);
/* compute all the needed values */ /* compute all the needed values */
for (idx=0; idx<nombre; idx++) { for (idx=0; idx<nombre; idx++) {
filename = ptr_glob->gl_pathv[idx]; filename = ptr_glob->gl_pathv[idx];
foo = get_float_metric_a_from_file(filename, &metrique); foo = get_float_metric_from_file(filename, &metrique, method);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d get metric of '%s'\n", __func__, fprintf(stderr, "%s: err %d get metric of '%s'\n", __func__,
foo, filename); foo, filename);
@ -80,7 +80,7 @@ for (idx=0; idx<nombre; idx++) {
if (method) { if (method) {
/* and now, we can massage all our datas */ /* and now, we can massage all our datas */
fprintf(stderr, "sorting %d ...\n", method); // fprintf(stderr, "sorting %d ...\n", method);
qsort(idxvalues, nombre, sizeof(IdxValue), cmp_idxvalues); qsort(idxvalues, nombre, sizeof(IdxValue), cmp_idxvalues);
} }
@ -91,7 +91,7 @@ if (verbosity > 1) {
fflush(stdout); fflush(stdout);
} }
} }
fprintf(stderr, "\n.\n");
return 0; return 0;
} }
@ -140,6 +140,8 @@ w = iarray[0], h = iarray[1];
fprintf(stderr, "first image size : %dx%d\n", w, h); fprintf(stderr, "first image size : %dx%d\n", w, h);
fimg_create(&A, w, h, 3); pFirst = &A; fimg_create(&A, w, h, 3); pFirst = &A;
fimg_vdeg_a(&A, idx_values[0].value);
fimg_create(&B, w, h, 3); pSecond = &B; fimg_create(&B, w, h, 3); pSecond = &B;
fimg_create(&Out, w, h, 3); fimg_create(&Out, w, h, 3);

View File

@ -31,7 +31,21 @@ if (foo) {
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int get_float_metric_a_from_file(char *fname, float *where) int get_float_metric_b(FloatImg *pimg, float *where)
{
int idx, size;
double adder;
adder = 0.0;
size = pimg->width * pimg->height;
for (idx=20; idx < size; idx+=42) {
adder += (double)pimg->R[idx];
}
*where = (float)adder;
return 0;
}
/* -------------------------------------------------------------- */
int get_float_metric_from_file(char *fname, float *where, int mode)
{ {
FloatImg image; FloatImg image;
int foo; int foo;
@ -43,10 +57,9 @@ if (foo) {
return foo; return foo;
} }
fval = -1.0; /* sensible default value */ fval = -1.0; /* sensible default value */
foo = get_float_metric_a(&image, &fval); foo = get_float_metric_b(&image, &fval);
*where = fval; *where = fval;
// fprintf(stderr, "metric of '%s' = %f\n", fname, fval);
fimg_destroy(&image); fimg_destroy(&image);
return 0; return 0;

View File

@ -7,6 +7,6 @@
/* first experiments */ /* first experiments */
int get_float_metric_a(FloatImg *pimg, float *where); int get_float_metric_a(FloatImg *pimg, float *where);
int get_float_metric_a_from_file(char *imgname, float *where); int get_float_metric_from_file(char *imgname, float *where, int mode);
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */