From de3b31db9421caa50aaf0d6af48a5c3aa66981da Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 3 Dec 2019 14:25:30 +0100 Subject: [PATCH] add a new (and funny) contrast adjustement --- doc/the_floatimg_hack.tex | 3 ++- floatimg.h | 4 ++-- lib/contrast.c | 32 ++++++++++++++++++++++++++++++++ tools/fimgfx.c | 16 +++++++++++----- v4l2/grabvidseq.c | 4 +++- 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/doc/the_floatimg_hack.tex b/doc/the_floatimg_hack.tex index e4763d3..fa75bb9 100644 --- a/doc/the_floatimg_hack.tex +++ b/doc/the_floatimg_hack.tex @@ -317,7 +317,8 @@ dans l'upscaling.} effectuées. L'autre façon de procéder est d'explorer notre image à la recherche de la valeur maximale. La fonction \texttt{float fimg\_get\_maxvalue(\&fimg)} est -faite pour ça. C'est la méthode utilisée par l'outil qui +faite pour ça. +C'est actuellement la méthode utilisée par l'outil qui sert à faire les modifications de contraste (page \pageref{fimgfx}. \vspace{1em} diff --git a/floatimg.h b/floatimg.h index cb19982..9445496 100644 --- a/floatimg.h +++ b/floatimg.h @@ -2,7 +2,7 @@ * floatimg.h */ -#define FIMG_VERSION 78 +#define FIMG_VERSION 79 /* * in memory descriptor @@ -83,7 +83,7 @@ int fimg_id_contraste(char *name); int fimg_square_root(FloatImg *s, FloatImg *d, double maxval); int fimg_power_2(FloatImg *s, FloatImg *d, double maxval); int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval); - +int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k); diff --git a/lib/contrast.c b/lib/contrast.c index 1cf0c0e..42cf1a4 100644 --- a/lib/contrast.c +++ b/lib/contrast.c @@ -132,6 +132,38 @@ for (idx=0; idxtype != FIMG_TYPE_RGB) { + fprintf(stderr, "%s : type %d invalide\n", + __func__, s->type); + return -4; + } + +if (NULL==d) { + d = s; + } +else { + if (d->type != FIMG_TYPE_RGB) { + fprintf(stderr, "%s : dst type %d invalide\n", + __func__, d->type); + return -4; + } + } + +nbre = s->width * s->height * 3; + +for (idx=0; idxR[idx] / maxval; + + d->R[idx] = maxval * (0.5 - 0.5 * cos(2*3.141592654*dval)); + } + +return 0; +} /* ---------------------------------------------------------------- */ diff --git a/tools/fimgfx.c b/tools/fimgfx.c index 9048bb4..0d15850 100644 --- a/tools/fimgfx.c +++ b/tools/fimgfx.c @@ -19,10 +19,11 @@ typedef struct { int nbarg; } Fx; -enum fxid { Fx_cos01, Fx_pow2, Fx_sqrt }; +enum fxid { Fx_cos01, Fx_cos010, Fx_pow2, Fx_sqrt }; Fx fx_list[] = { { "cos01", Fx_cos01, 0 }, + { "cos010", Fx_cos010, 0 }, { "pow2", Fx_pow2, 0 }, { "sqrt", Fx_sqrt, 0 }, { NULL, 0, 0 } @@ -52,11 +53,14 @@ return -1; /* --------------------------------------------------------------------- */ static void help(int lvl) { +Fx *fx; -printf("fimg special effects (%d)\n", lvl); - - - +puts("--- fimg special effects ---"); +printf("\t"); +for (fx=fx_list; fx->name; fx++) { + printf("%s ", fx->name); + } +puts(""); exit(0); } /* --------------------------------------------------------------------- */ @@ -88,6 +92,8 @@ if (foo) { switch (act) { case Fx_cos01: fimg_cos_01(&src, &dest, maxval); break; + case Fx_cos010: + fimg_cos_010(&src, &dest, maxval); break; case Fx_pow2: fimg_power_2(&src, &dest, maxval); break; case Fx_sqrt: diff --git a/v4l2/grabvidseq.c b/v4l2/grabvidseq.c index 765c649..2871a42 100644 --- a/v4l2/grabvidseq.c +++ b/v4l2/grabvidseq.c @@ -234,8 +234,10 @@ cumul.count = 0; type = V4L2_BUF_TYPE_VIDEO_CAPTURE; xioctl(fd, VIDIOC_STREAMON, &type); +#if 0 if (verbosity) fprintf(stderr,"pid %d grabbing %d picz...\n", getpid(), nbre_capt); +#endif for (i = 0; i < nbre_capt; i++) { do { @@ -331,7 +333,7 @@ if (verbosity) { } switch (contrast) { case CONTRAST_NONE: - fprintf(stderr, "contrast: none\n"); + // if (verbosity) fprintf(stderr, "contrast: none\n"); break; case CONTRAST_SQRT: fimg_square_root(&cumul, NULL, maxvalue);