more clenaup, expect more bugs

This commit is contained in:
tth
2021-03-17 18:32:51 +01:00
parent 706e218ff0
commit 3632dc1680
23 changed files with 98 additions and 137 deletions

View File

@@ -77,11 +77,6 @@ for (idx=0; idx<surface; idx++) {
if (fval < mmvals[4]) mmvals[4] = fval;
else if (fval > mmvals[5]) mmvals[5] = fval;
}
#if 0
for (foo=0; foo<6; foo++) {
fprintf(stderr, "%3d %g\n", foo, mmvals[foo]);
}
#endif
return -0;
}
@@ -97,10 +92,10 @@ if (surface < 1) return -1;
memset(accus, 0, 4*sizeof(double));
for (idx=0; idx<surface; idx++) {
accus[0] += head->R[idx];
accus[0] += (double)head->R[idx];
if (head->type > 2) { /* WTF ? */
accus[1] += head->G[idx];
accus[2] += head->B[idx];
accus[1] += (double)head->G[idx];
accus[2] += (double)head->B[idx];
}
}
@@ -122,7 +117,6 @@ return 0;
Mais c,a ne semble pas etre la bonne methode. Il faut aller voir :
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
*/
/* ---------------------------------------------------------------- */
/*
* more elaborate functions are in fimg-2gray.c
@@ -144,17 +138,17 @@ for (foo=0; foo<(head->width*head->height); foo++) {
add += head->B[foo];
head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0;
}
return -1;
return 0;
}
/* ---------------------------------------------------------------- */
void fimg_add_cste(FloatImg *fi, float value)
int fimg_add_cste(FloatImg *fi, float value)
{
int nbre, idx;
if (fi->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
__func__, fi->type);
return;
return -44;
}
nbre = fi->width * fi->height ;
@@ -166,12 +160,13 @@ for (idx=0; idx<nbre; idx++) {
fi->G[idx] += value;
fi->B[idx] += value;
}
return 0;
}
/* ---------------------------------------------------------------- */
int fimg_count_negativ(FloatImg *fi)
long fimg_count_negativ(FloatImg *fi)
{
int nbre, idx;
int count;
long count;
if (fi->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
@@ -183,19 +178,19 @@ nbre = fi->width * fi->height;
count = 0;
for (idx=0; idx<nbre; idx++) {
if (fi->R[idx] < 0.0) count++;
if (fi->G[idx] < 0.0) count++;
if (fi->B[idx] < 0.0) count++;
if (fi->R[idx] < 0.0) count++;
if (fi->G[idx] < 0.0) count++;
if (fi->B[idx] < 0.0) count++;
}
return count;
}
/* ---------------------------------------------------------------- */
/* nouveau 29 fevrier 2020 */
int fimg_clamp_negativ(FloatImg *fi)
long fimg_clamp_negativ(FloatImg *fi)
{
int nbre, idx;
int count;
long count;
if (fi->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
@@ -203,13 +198,18 @@ if (fi->type != FIMG_TYPE_RGB) {
return -1;
}
nbre = fi->width * fi->height * fi->type;
nbre = fi->width * fi->height;
count = 0;
for (idx=0; idx<nbre; idx++) {
if (fi->R[idx] < 0.0) {
fi->R[idx] = 0.0;
count++;
fi->R[idx] = 0.0; count++;
}
if (fi->G[idx] < 0.0) {
fi->G[idx] = 0.0; count++;
}
if (fi->B[idx] < 0.0) {
fi->B[idx] = 0.0; count++;
}
}
@@ -229,14 +229,14 @@ for (idx=0; idx<nbre; idx++) {
return count;
}
/* ---------------------------------------------------------------- */
void fimg_mul_cste(FloatImg *fi, float value)
int fimg_mul_cste(FloatImg *fi, float value)
{
int nbre, idx;
if ( (fi->type != FIMG_TYPE_RGB) && (fi->type != FIMG_TYPE_GRAY) ) {
fprintf(stderr, "%s : type %d invalide\n",
__func__, fi->type);
return;
return -44;
}
nbre = fi->width * fi->height;
@@ -255,8 +255,12 @@ if (fi->type == FIMG_TYPE_GRAY) {
fi->R[idx] *= value;
}
}
return 0;
}
/* ---------------------------------------------------------------- */
/*
* oh, please explain the usecase of this function !
*/
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused)
{
double coef;