add a new (and funny) contrast adjustement

This commit is contained in:
tth 2019-12-03 14:25:30 +01:00
parent 116cb56e13
commit de3b31db94
5 changed files with 50 additions and 9 deletions

View File

@ -317,7 +317,8 @@ dans l'upscaling.} effectuées.
L'autre façon de procéder est d'explorer notre image à la L'autre façon de procéder est d'explorer notre image à la
recherche de la valeur maximale. recherche de la valeur maximale.
La fonction \texttt{float fimg\_get\_maxvalue(\&fimg)} est 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}. sert à faire les modifications de contraste (page \pageref{fimgfx}.
\vspace{1em} \vspace{1em}

View File

@ -2,7 +2,7 @@
* floatimg.h * floatimg.h
*/ */
#define FIMG_VERSION 78 #define FIMG_VERSION 79
/* /*
* in memory descriptor * 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_square_root(FloatImg *s, FloatImg *d, double maxval);
int fimg_power_2(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_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); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);

View File

@ -132,6 +132,38 @@ for (idx=0; idx<nbre; idx++) {
return 0; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval)
{
int nbre, idx;
double dval;
if (s->type != 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; idx<nbre; idx++) {
dval = s->R[idx] / maxval;
d->R[idx] = maxval * (0.5 - 0.5 * cos(2*3.141592654*dval));
}
return 0;
}
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */

View File

@ -19,10 +19,11 @@ typedef struct {
int nbarg; int nbarg;
} Fx; } Fx;
enum fxid { Fx_cos01, Fx_pow2, Fx_sqrt }; enum fxid { Fx_cos01, Fx_cos010, Fx_pow2, Fx_sqrt };
Fx fx_list[] = { Fx fx_list[] = {
{ "cos01", Fx_cos01, 0 }, { "cos01", Fx_cos01, 0 },
{ "cos010", Fx_cos010, 0 },
{ "pow2", Fx_pow2, 0 }, { "pow2", Fx_pow2, 0 },
{ "sqrt", Fx_sqrt, 0 }, { "sqrt", Fx_sqrt, 0 },
{ NULL, 0, 0 } { NULL, 0, 0 }
@ -52,11 +53,14 @@ return -1;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void help(int lvl) 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); exit(0);
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -88,6 +92,8 @@ if (foo) {
switch (act) { switch (act) {
case Fx_cos01: case Fx_cos01:
fimg_cos_01(&src, &dest, maxval); break; fimg_cos_01(&src, &dest, maxval); break;
case Fx_cos010:
fimg_cos_010(&src, &dest, maxval); break;
case Fx_pow2: case Fx_pow2:
fimg_power_2(&src, &dest, maxval); break; fimg_power_2(&src, &dest, maxval); break;
case Fx_sqrt: case Fx_sqrt:

View File

@ -234,8 +234,10 @@ cumul.count = 0;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
xioctl(fd, VIDIOC_STREAMON, &type); xioctl(fd, VIDIOC_STREAMON, &type);
#if 0
if (verbosity) fprintf(stderr,"pid %d grabbing %d picz...\n", if (verbosity) fprintf(stderr,"pid %d grabbing %d picz...\n",
getpid(), nbre_capt); getpid(), nbre_capt);
#endif
for (i = 0; i < nbre_capt; i++) { for (i = 0; i < nbre_capt; i++) {
do { do {
@ -331,7 +333,7 @@ if (verbosity) {
} }
switch (contrast) { switch (contrast) {
case CONTRAST_NONE: case CONTRAST_NONE:
fprintf(stderr, "contrast: none\n"); // if (verbosity) fprintf(stderr, "contrast: none\n");
break; break;
case CONTRAST_SQRT: case CONTRAST_SQRT:
fimg_square_root(&cumul, NULL, maxvalue); fimg_square_root(&cumul, NULL, maxvalue);