big refactoring step 1, expect more bugs

This commit is contained in:
tth
2021-03-09 11:55:48 +01:00
parent 7ada60d113
commit b9d963dfa2
14 changed files with 179 additions and 100 deletions

View File

@@ -98,7 +98,7 @@ memset(accus, 0, 4*sizeof(double));
for (idx=0; idx<surface; idx++) {
accus[0] += head->R[idx];
if (head->type > 2) {
if (head->type > 2) { /* WTF ? */
accus[1] += head->G[idx];
accus[2] += head->B[idx];
}
@@ -123,8 +123,6 @@ 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
@@ -159,12 +157,14 @@ if (fi->type != FIMG_TYPE_RGB) {
return;
}
nbre = fi->width * fi->height * fi->type;
nbre = fi->width * fi->height ;
#if DEBUG_LEVEL
fprintf(stderr, "%s, nbre is %d\n", __func__, nbre);
#endif
for (idx=0; idx<nbre; idx++) {
fi->R[idx] += value;
fi->G[idx] += value;
fi->B[idx] += value;
}
}
/* ---------------------------------------------------------------- */
@@ -179,11 +179,13 @@ 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) count++;
if (fi->G[idx] < 0.0) count++;
if (fi->B[idx] < 0.0) count++;
}
return count;
@@ -237,12 +239,21 @@ if ( (fi->type != FIMG_TYPE_RGB) && (fi->type != FIMG_TYPE_GRAY) ) {
return;
}
nbre = fi->width * fi->height * fi->type;
nbre = fi->width * fi->height;
#if DEBUG_LEVEL
fprintf(stderr, "%s, nbre of datum is %d\n", __func__, nbre);
#endif
for (idx=0; idx<nbre; idx++) {
fi->R[idx] *= value;
if (fi->type == FIMG_TYPE_RGB) {
for (idx=0; idx<nbre; idx++) {
fi->R[idx] *= value;
fi->G[idx] *= value;
fi->B[idx] *= value;
}
}
if (fi->type == FIMG_TYPE_GRAY) {
for (idx=0; idx<nbre; idx++) {
fi->R[idx] *= value;
}
}
}
/* ---------------------------------------------------------------- */