Browse Source

need more work

master
tth 6 months ago
parent
commit
198bd874f1
1 changed files with 35 additions and 5 deletions
  1. +35
    -5
      Fonderie/metriques.c

+ 35
- 5
Fonderie/metriques.c View File

@ -10,6 +10,7 @@
extern int verbosity;
/* -------------------------------------------------------------- */
/* usage --> sfx.c:trinitron */
int stat_zone(FloatImg *pimg, int geom[4], float v3[3])
{
int x, y, xe, ye;
@ -43,9 +44,12 @@ return 0;
}
/* -------------------------------------------------------------- */
/*
* premier essai...
* premier essai : moyenne de toutes les composantes
* de tous les pixels.
*
* Question: pourquoi pas le retour en double precision ?
*/
int get_float_metric_a(FloatImg *pimg, float *where)
int get_float_metric_avg(FloatImg *pimg, float *where)
{
float means[4]; /* four values : R G B A */
int foo;
@ -63,7 +67,8 @@ if (foo) {
return 0;
}
/* -------------------------------------------------------------- */
int get_float_metric_b(FloatImg *pimg, float *where)
/* echantillonage des pixels rouges */
int get_float_metric_iRed(FloatImg *pimg, float *where)
{
int idx, size, nbre;
double adder;
@ -79,6 +84,28 @@ for (idx=20; idx < size; idx+=42) {
return 0;
}
/* -------------------------------------------------------------- */
int get_float_metric_LR(FloatImg *pimg, float *where)
{
int coords[4], foo;
float valL[3], valR[3];
coords[0] = 0; // X
coords[1] = 0; // Y
coords[2] = pimg->width / 2; // W
coords[3] = pimg->height; // H
foo = stat_zone(pimg, coords, valL);
coords[1] = pimg->width / 2;
foo = stat_zone(pimg, coords, valR);
*where = valL[1] - valR[1];
return 0;
}
/* -------------------------------------------------------------- */
/*
* et voici le grand dispactheur
*/
int get_float_metric_from_file(char *fname, float *where, int mode)
{
FloatImg image;
@ -97,10 +124,13 @@ if (foo) {
fval = -1.0; /* sensible default value */
switch (mode) {
case 0: case 1:
foo = get_float_metric_a(&image, &fval);
foo = get_float_metric_avg(&image, &fval);
break;
case 2:
foo = get_float_metric_b(&image, &fval);
foo = get_float_metric_iRed(&image, &fval);
break;
case 3:
foo = get_float_metric_LR(&image, &fval);
break;
default:
fprintf(stderr, "%s: method %d invalid\n",


Loading…
Cancel
Save