fix in fimg_auto_shift_to_zero

This commit is contained in:
tonton th 2021-02-25 08:23:27 +01:00
parent 0a1260eb6f
commit fdcc0781eb
2 changed files with 13 additions and 2 deletions

View File

@ -9,8 +9,8 @@ FILTRES=$(./t -L | awk 'NR>1 { print $1 }' | sort)
rm /tmp/fstack*.png rm /tmp/fstack*.png
# SRC=$(ls -rt1 $HOME/Essais/FondageDePlomb/capture/* | tail -1) SRC=$(ls -rt1 $HOME/Essais/FondageDePlomb/capture/* | tail -1)
SRC=mire.fimg # SRC=mire.fimg
for F in $FILTRES for F in $FILTRES
do do

View File

@ -71,10 +71,14 @@ return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/*
* I think that this function is fully buggy
*/
int fimg_auto_shift_to_zero(FloatImg *src, FloatImg *dst) int fimg_auto_shift_to_zero(FloatImg *src, FloatImg *dst)
{ {
float coefs[6]; float coefs[6];
int foo; int foo;
float minima = 1e7; /* magic value ? */
if (FIMG_TYPE_RGB != src->type) { if (FIMG_TYPE_RGB != src->type) {
fprintf(stderr, "%s: bad image type %d\n", __func__, src->type); fprintf(stderr, "%s: bad image type %d\n", __func__, src->type);
@ -87,6 +91,13 @@ if (foo) {
return foo; return foo;
} }
/* crude hack for now */
if (coefs[0] < minima) minima = coefs[0];
if (coefs[2] < minima) minima = coefs[2];
if (coefs[4] < minima) minima = coefs[4];
coefs[0] = coefs[2] = coefs[4] = minima;
foo = fimg_shift_to_zero(src, dst, coefs); foo = fimg_shift_to_zero(src, dst, coefs);
if (foo) { if (foo) {
fprintf(stderr, "%s WTF?\n", __func__); fprintf(stderr, "%s WTF?\n", __func__);