a new "rescale" option in cumulfimgs
This commit is contained in:
parent
e6379f6338
commit
feafd2799d
@ -20,7 +20,7 @@
|
||||
* https://git.tetalab.org/tTh/FloatImg
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION (198)
|
||||
#define FIMG_VERSION (201)
|
||||
#define RELEASE_NAME ("noname")
|
||||
|
||||
/* XXX add a test for stdint.h / uint32_t XXX */
|
||||
@ -233,7 +233,7 @@ int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
|
||||
|
||||
/* module funcs/equalize.c */
|
||||
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
|
||||
int fimg_equalize(FloatImg *src, float vmax);
|
||||
int fimg_equalize(FloatImg *src, double vmax);
|
||||
|
||||
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
|
||||
int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);
|
||||
@ -285,6 +285,7 @@ int fimg_meanvalues(FloatImg *head, float means[4]);
|
||||
int fimg_to_gray(FloatImg *head);
|
||||
int fimg_add_cste(FloatImg *fi, float value);
|
||||
int fimg_mul_cste(FloatImg *fi, float value);
|
||||
int fimg_div_cste(FloatImg *fi, float value);
|
||||
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
|
||||
int fimg_absolute(FloatImg *fimg);
|
||||
void fimg_drand48(FloatImg *fi, float kmul);
|
||||
|
@ -296,6 +296,33 @@ if (fi->type == FIMG_TYPE_GRAY) {
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* nouveau 17 septembre 2022 */
|
||||
int fimg_div_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 -44;
|
||||
}
|
||||
|
||||
nbre = fi->width * fi->height;
|
||||
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;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
/*
|
||||
* oh, please explain the usecase of this function !
|
||||
*/
|
||||
|
@ -40,9 +40,10 @@ void help(int v)
|
||||
puts("");
|
||||
puts("$ cumulfimgs a.fimg b.fimg c-fimg ...");
|
||||
puts("cumulator options :");
|
||||
puts("\t-v\tincrease verbosity");
|
||||
puts("\t-o\tname of output file");
|
||||
puts("\t-g\tconvert to gray level");
|
||||
puts("\t-o\tname of output file");
|
||||
puts("\t-s\trescale end image");
|
||||
puts("\t-v\tincrease verbosity");
|
||||
puts("");
|
||||
if (verbosity) { puts("Xperiment"); fimg_print_version(v); }
|
||||
exit(0);
|
||||
@ -52,22 +53,25 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, idx;
|
||||
int opt;
|
||||
int compte = 0;
|
||||
|
||||
int compte = 0;
|
||||
int to_gray = 0;
|
||||
int experiment = 0;
|
||||
int rescale = 0;
|
||||
int src_loaded = 0;
|
||||
|
||||
char *output_file = "out.fimg";
|
||||
FloatImg accu, temp;
|
||||
int src_loaded = 0;
|
||||
float vals[6];
|
||||
|
||||
g_width = g_height = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "gho:vx")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "gho:svx")) != -1) {
|
||||
switch(opt) {
|
||||
case 'g': to_gray = 1; break;
|
||||
case 'h': help(1); break;
|
||||
case 'o': output_file = optarg; break;
|
||||
case 's': rescale = 1; break;
|
||||
case 'v': verbosity++; break;
|
||||
case 'x': experiment++; break;
|
||||
}
|
||||
@ -104,6 +108,11 @@ for (idx=optind; idx<argc; idx++) {
|
||||
compte++;
|
||||
}
|
||||
|
||||
if (rescale) {
|
||||
fprintf(stderr, "cumulfimg: count = %d\n", compte);
|
||||
fimg_div_cste(&accu, (float)compte);
|
||||
}
|
||||
|
||||
/* XXX */
|
||||
if (experiment) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user