Merge branch 'master' of ssh://tetalab.org:2213/tTh/FloatImg

something is broken ?
This commit is contained in:
Tonton Th 2020-10-10 01:26:19 +02:00
commit aa42aa99fb
16 changed files with 559 additions and 36 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ doc/co*.tex
funcs/t funcs/t
funcs/*.o funcs/*.o
funcs/*.png funcs/*.png
funcs/V/*
funcs/*.gif funcs/*.gif
funcs/*.fits funcs/*.fits
funcs/*.tiff funcs/*.tiff

View File

@ -412,7 +412,7 @@ foo = fimg_create_from_dump("lena.fimg", &head);
\end{lstlisting} \end{lstlisting}
Si la valeur retournée est différente de 0, c'est que quelque Si la valeur retournée est différente de 0, c'est que quelque
chose s'est mal passé. chose s'est probablement mal passé.
Certains messages sont parfois explicites. Certains messages sont parfois explicites.
% _________ % _________
@ -884,7 +884,7 @@ pas vraiment compte du contenu de l'image.
\begin{verbatim} \begin{verbatim}
tth@daubian:~/Devel/FloatImg/tools$ ./fimgfx -v -h tth@daubian:~/Devel/FloatImg/tools$ ./fimgfx -v -h
--- fimg special effects --- --- fimg special effects ---
cos01 cos010 pow2 sqrt gray0 xper cos01 cos010 pow2 sqrt gray0 cmixa xper desat
\end{verbatim} \end{verbatim}
Certaines de ces opérations ont besoin d'un paramètre flottant. Certaines de ces opérations ont besoin d'un paramètre flottant.
@ -898,6 +898,12 @@ sera lisible avec le sélecteur \texttt{-L}.
\item [Déformations géométriques:] r90 \item [Déformations géométriques:] r90
\end{description} \end{description}
Et pour les aventureux, la commande \texttt{xper} (abréviation
de \textsl{expérimental}) permet de tester la plus récente tentative
de friture du moment.
% ---------------------
\subsection{fimgops}\index{fimgops}\label{fimgops} \subsection{fimgops}\index{fimgops}\label{fimgops}
Quelques opérations diverses entre deux images, qui doivent être Quelques opérations diverses entre deux images, qui doivent être
@ -955,9 +961,34 @@ avoir plusieurs plans de réalité. Il ne faut en négliger aucun.
Il faut quand même deviner que pour passer de l'espace RGB\index{RGB} Il faut quand même deviner que pour passer de l'espace RGB\index{RGB}
à une abstraction linéaire mono-dimensionnelle, il existe une foultitude à une abstraction linéaire mono-dimensionnelle, il existe une foultitude
de méthodes, toutes plus légitimes que les autres. de méthodes, toutes plus légitimes que les autres.
\index{procrastination}
Et face à l'incertitude du choix, j'ai reporté l'écriture de ce
logiciel aux calendes grecques, voire même plus tard.
\subsection{cumulfimgs}\index{cumulfimgs}\label{cumulfimgs}
Cet outil accumule\index{cumul} une quantité d'images flottantes
(même taille et même type) afin d'obtenir
un flou de meilleure qualité. Aucune mise à l'échelle n'etant
effctuée, les pixels de sortie peuvent atteindre des valeurs
considérables\footnote{Prévoir une gestion des \textsf{overflows} ?}
\begin{verbatim}
tth@delirium:~/Devel/FloatImg/tools$ ./cumulfimgs -h
usage :
cumulfimgs a.fimg b.fimg c-fimg ...
cumulator options :
-v increase verbosity
-o name of output file
-g convert to gray level
\end{verbatim}
Le nom par défaut du fichier résultant est \texttt{out.fimg}.
L'exportation "multiformat" est pour bientôt.
% ------------------------------------------------------------------- % -------------------------------------------------------------------
\section{TODO}\index{TODO}\label{TODO} \section{TODO}\index{TODO}\label{TODO}\
\index{XXX}
Il reste plein de choses à faire pour que ce soit vraiment utilisable, Il reste plein de choses à faire pour que ce soit vraiment utilisable,
surtout dans un contexte artistique à grande porosité. surtout dans un contexte artistique à grande porosité.
@ -971,7 +1002,8 @@ choses seront acquises.
\item Compléter les traitements mathémathiques (eg le gamma\index{gamma}). \item Compléter les traitements mathémathiques (eg le gamma\index{gamma}).
\item Formaliser les codes d'erreur. \textbf{Urgent}. \item Formaliser les codes d'erreur. \textbf{Urgent}.
\item Faire une passe complète de Valgrind\index{valgrind}. \item Faire une passe complète de Valgrind\index{valgrind}.
\item Integrer la fonderie et l'interpolator. \item Intégrer la fonderie et l'interpolator.
\item Vérifier le gestion des images mono-canal.
\end{itemize} \end{itemize}
% ------------------------------------------------------------------- % -------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* ugly code from tTh * ugly code from tTh
*/ */
#define FIMG_VERSION 106 #define FIMG_VERSION 109
/* /*
* in memory descriptor * in memory descriptor
@ -97,6 +97,9 @@ int fimg_killborders(FloatImg *img);
int fimg_lissage_2x2(FloatImg *img); int fimg_lissage_2x2(FloatImg *img);
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr); int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int notused);
/* 'sfx0' module */ /* 'sfx0' module */
int fimg_killcolors_a(FloatImg *fimg, float fval); int fimg_killcolors_a(FloatImg *fimg, float fval);
int fimg_killcolors_b(FloatImg *fimg, float fval); int fimg_killcolors_b(FloatImg *fimg, float fval);
@ -124,6 +127,10 @@ int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
int fimg_mix_rgb_gray(FloatImg *img, float mix); int fimg_mix_rgb_gray(FloatImg *img, float mix);
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]); int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
/* * * * experimental ! */
int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused);
/* module funcs/geometry.c */ /* module funcs/geometry.c */
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax); int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
@ -158,7 +165,7 @@ int fimg_meanvalues(FloatImg *head, float means[4]);
int fimg_to_gray(FloatImg *head); int fimg_to_gray(FloatImg *head);
void fimg_add_cste(FloatImg *fi, float value); void fimg_add_cste(FloatImg *fi, float value);
void fimg_mul_cste(FloatImg *fi, float value); void fimg_mul_cste(FloatImg *fi, float value);
int fimg_normalize(FloatImg *fi, double maxima, int notused); int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
void fimg_drand48(FloatImg *fi, float kmul); void fimg_drand48(FloatImg *fi, float kmul);
int fimg_count_negativ(FloatImg *fi); int fimg_count_negativ(FloatImg *fi);
int fimg_clamp_negativ(FloatImg *fi); int fimg_clamp_negativ(FloatImg *fi);

View File

@ -5,7 +5,7 @@ DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \ fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \
equalize.o fimg-fits.o saturation.o histogram.o \ equalize.o fimg-fits.o saturation.o histogram.o \
hsv.o hsv.o classif.o contour2x2.o qsortrgb.o
#--------------------------------------------------------------- #---------------------------------------------------------------
@ -55,9 +55,19 @@ equalize.o: equalize.c $(DEPS)
sfx0.o: sfx0.c $(DEPS) sfx0.o: sfx0.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
contour2x2.o: contour2x2.c $(DEPS)
gcc $(COPT) -c $<
rampes.o: rampes.c $(DEPS) rampes.o: rampes.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
classif.o: classif.c $(DEPS)
gcc $(COPT) -c $<
qsortrgb.o: qsortrgb.c $(DEPS)
gcc $(COPT) -c $<
hsv.o: hsv.c $(DEPS) hsv.o: hsv.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

93
funcs/classif.c Normal file
View File

@ -0,0 +1,93 @@
/*
* classif.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
int verbosity;
/* --------------------------------------------------------------------- */
/* nouveau 2 octobre 2020, juste avant sonoptic de la pluie craignos */
int fimg_classif_trial(FloatImg *psrc, FloatImg *pdst, float fval, int notused)
{
float minmax[6], delta[3], baryc[3];
float range, dist, rgb[3], dr, dg, db;
int x, y, on, off;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__, psrc, pdst, fval, notused);
#endif
/* calculer les amplitudes RGB de l'image source */
fimg_get_minmax_rgb(psrc, minmax);
delta[0] = minmax[1] - minmax[0];
delta[1] = minmax[3] - minmax[2];
delta[2] = minmax[5] - minmax[4];
/* chercher le plus petit des deltas */
range = delta[0]; if (delta[1]<range) range=delta[1];
if (delta[2]<range) range=delta[2];
/* convertir le diametre en rayon (magic inside) */
range *= fval;
if (verbosity ) fprintf(stderr, "deltas : %f %f %f / %f\n",
delta[0], delta[1], delta[2], range);
/* calcul du "barycentre" chromatique */
baryc[0] = (minmax[1] + minmax[0]) / 2;
baryc[1] = (minmax[3] + minmax[2]) / 2;
baryc[2] = (minmax[5] + minmax[4]) / 2;
if (verbosity) fprintf(stderr, "barycs : %f %f %f\n",
baryc[0], baryc[1], baryc[2]);
on = off = 0;
for (y=0; y<psrc->height; y++) {
for (x=0; x<psrc->width; x++) {
fimg_get_rgb(psrc, x, y, rgb);
/* calcul de la distance chromatique */
dr = rgb[0] - baryc[0];
dg = rgb[1] - baryc[1];
db = rgb[2] - baryc[2];
dist = sqrtf( (dr*dr) + (dg*dg) + (db*db) );
#if DEBUG_LEVEL
if (x==y) fprintf(stderr, "%4d %4d %f\n", x, y, dist);
#endif
/* action !!! */
if (dist > range) {
/* make our pixel gray-level */
rgb[0] = rgb[1] = rgb[2] = 0.0;
// (rgb[0] + rgb[1] + rgb[2]) / 3.0;
on++;
}
else {
/* the easy part : do nothing */
off++;
}
fimg_put_rgb(pdst, x, y, rgb);
/* MUST BE MORE CREATIVE HERE !!! */
}
}
fprintf(stderr, "on %d off %d\n", on, off);
return 0;
}
/* --------------------------------------------------------------------- */

71
funcs/contour2x2.c Normal file
View File

@ -0,0 +1,71 @@
/*
* classif.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
int verbosity;
/* --------------------------------------------------------------------- */
/* nouveau 4 octobre 2020, juste avant sonoptic de la pluie craignos */
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int notused)
{
float avg[4];
int foo, x, y, q;
int tbl[] = /* deep magic inside */
{
0, 1, 1, 1,
1, 1, 0, 1,
1, 0, 1, 1,
1, 1, 1, 0
};
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
#endif
foo = fimg_meanvalues(psrc, avg);
if (verbosity) {
fprintf(stderr, "mean values : %f %f %f\n", avg[0], avg[1], avg[2]);
}
#define RP(ix, iy) ( psrc->R[((iy)*psrc->width)+(ix)] < avg[0] )
#define GP(ix, iy) ( psrc->G[((iy)*psrc->width)+(ix)] < avg[1] )
#define BP(ix, iy) ( psrc->B[((iy)*psrc->width)+(ix)] < avg[2] )
for (y=0; y<psrc->height-1; y++) {
for (x=0; x<psrc->width-1; x++) {
q = ( ( RP(x, y) << 3 ) |
( RP(x+1, y) << 2 ) |
( RP(x, y+1) << 1 ) |
( RP(x+1, y+1) ) );
pdst->R[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ;
q = ( ( GP(x, y) << 3 ) |
( GP(x+1, y) << 2 ) |
( GP(x, y+1) << 1 ) |
( GP(x+1, y+1) ) );
pdst->G[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ;
q = ( ( BP(x, y) << 3 ) |
( BP(x+1, y) << 2 ) |
( BP(x, y+1) << 1 ) |
( BP(x+1, y+1) ) );
pdst->B[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ;
}
}
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -19,7 +19,7 @@ int foo;
float dr, dg, db; float dr, dg, db;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, src); fprintf(stderr, ">>> %s ( %p %p %f )\n", __func__, src, vptr, vmax);
#endif #endif
memset(minmax, 0, 6*sizeof(float)); memset(minmax, 0, 6*sizeof(float));
@ -34,9 +34,9 @@ dr = minmax[1] - minmax[0];
dg = minmax[3] - minmax[2]; dg = minmax[3] - minmax[2];
db = minmax[5] - minmax[4]; db = minmax[5] - minmax[4];
printf("Rmin %12.4g Rmax %12.4g delta %12.4g\n", minmax[0], minmax[1], dr); printf("Rmin %12.4g max %12.4g delta %12.4g\n", minmax[0], minmax[1], dr);
printf("Gmin %12.4g Gmax %12.4g delta %12.4g\n", minmax[2], minmax[3], dg); printf("Gmin %12.4g max %12.4g delta %12.4g\n", minmax[2], minmax[3], dg);
printf("Bmin %12.4g Bmax %12.4g delta %12.4g\n", minmax[4], minmax[5], db); printf("Bmin %12.4g max %12.4g delta %12.4g\n", minmax[4], minmax[5], db);
if ( (minmax[0]<0.0) || (minmax[2]<0.0) || (minmax[4]<0.0) ) { if ( (minmax[0]<0.0) || (minmax[2]<0.0) || (minmax[4]<0.0) ) {
fprintf(stderr, "%s: negative value ?\n", __func__); fprintf(stderr, "%s: negative value ?\n", __func__);

104
funcs/qsortrgb.c Normal file
View File

@ -0,0 +1,104 @@
/*
* qsort_rgb.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
int verbosity;
/* --------------------------------------------------------------------- */
/* nouveau 7 octobre 2020, juste avant sonoptic de la pluie craignos */
static int compare_a(const void *p1, const void *p2)
{
return ( *(float *)p1 < *(float *)p2 );
}
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused)
{
int foo, szimg;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
#endif
foo = fimg_copy_data(psrc, pdst);
szimg = pdst->width * pdst->height;
fprintf(stderr, "%s : %d pixels\n", __func__, szimg);
qsort(pdst->R, szimg, sizeof(float), compare_a);
qsort(pdst->G, szimg, sizeof(float), compare_a);
qsort(pdst->B, szimg, sizeof(float), compare_a);
return 0;
}
/* --------------------------------------------------------------------- */
typedef struct {
float sum;
float r, g, b;
} pix;
static compare_b(const void *p1, const void *p2)
{
pix *s1, *s2;
s1 = (pix *)p1;
s2 = (pix *)p2;
return ( s1->sum < s2->sum );
}
int fimg_qsort_rgb_b(FloatImg *psrc, FloatImg *pdst, int notused)
{
int x, y, szimg;
pix *ppix, *ptr;
float rgb[3];
// #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
// #endif
szimg = pdst->width * pdst->height;
fprintf(stderr, "%s : %d pixels\n", __func__, szimg);
ppix = calloc(szimg, sizeof(pix));
ptr = ppix; /* mobile pointer */
for (y=0; y<psrc->height; y++) {
for (x=0; x<psrc->width; x++) {
fimg_get_rgb(psrc, x, y, rgb);
ptr->sum = rgb[0] + rgb[1] + rgb[2];
ptr->r = rgb[0];
ptr->g = rgb[1];
ptr->b = rgb[2];
ptr++; /* next pixel */
}
}
qsort(ppix, szimg, sizeof(pix), compare_b);
ptr = ppix; /* mobile pointer */
for (y=0; y<psrc->height; y++) {
for (x=0; x<psrc->width; x++) {
rgb[0] = ptr->r;
rgb[1] = ptr->g;
rgb[2] = ptr->b;
fimg_put_rgb(pdst, x, y, rgb);
ptr++; /* next pixel */
}
}
free(ppix);
return 0;
}
/* --------------------------------------------------------------------- */

139
funcs/t.c
View File

@ -14,6 +14,126 @@ int verbosity;
float global_fvalue; float global_fvalue;
/* --------------------------------------------------------------------- */
/*
* nouveau 7 octobre 2020 pendant sonoptic
*/
//
int essai_qsort_rgb(char *infile)
{
FloatImg src, dst;
int foo;
if (NULL != infile) {
fprintf(stderr, "%s : loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
fimg_clone(&src, &dst, 1);
foo = fimg_qsort_rgb_b(&src, &dst, 0);
if (foo) {
fprintf(stderr, "%s: err %d in qsort_rgb\n", __func__, foo);
return foo;
}
foo = fimg_dump_to_file(&dst, "out.fimg", 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */
/*
* nouveau 5 octobre 2020 pendant sonoptic
*/
int essai_contour_2x2(char *infile)
{
FloatImg src, dst;
int foo;
if (NULL != infile) {
fprintf(stderr, "%s : loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
fimg_clone(&src, &dst, 1);
foo = fimg_contour_2x2(&src, &dst, 0);
if (foo) {
fprintf(stderr, "%s: err %d in contour_2x2\n", __func__, foo);
return foo;
}
foo = fimg_save_as_pnm(&dst, "out.pnm", 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */
/*
* nouveau 5 octobre 2020 pendant sonoptic
*/
int essai_classif(char *infile)
{
FloatImg src, dst;
int foo;
if (NULL != infile) {
fprintf(stderr, "%s : loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
fimg_clone(&src, &dst, 1);
fprintf(stderr, "%s : fvalue is %f\n", __func__, global_fvalue);
foo = fimg_classif_trial(&src, &dst, global_fvalue, 0);
if (foo) {
fprintf(stderr, "%s: err %d in classif_trial\n", __func__, foo);
return foo;
}
foo = fimg_save_as_pnm(&dst, "out.pnm", 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* nouveau 19 aout 2020, le matin avant la canicule */ /* nouveau 19 aout 2020, le matin avant la canicule */
@ -31,7 +151,6 @@ if (foo) {
return foo; return foo;
} }
return -7; return -7;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -434,7 +553,7 @@ return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Histo, Hsv }; Histo, Hsv, Classif, Ctr2x2, Qsortrgb };
typedef struct { typedef struct {
char *name; char *name;
int Cmd; int Cmd;
@ -451,6 +570,9 @@ Command commands[] = {
{ "wtiff", Wtiff }, { "wtiff", Wtiff },
{ "histo", Histo }, { "histo", Histo },
{ "hsv", Hsv }, { "hsv", Hsv },
{ "classif", Classif },
{ "ctr2x2", Ctr2x2 },
{ "qsortrgb", Qsortrgb },
{ NULL, 0 } { NULL, 0 }
} ; } ;
@ -514,7 +636,9 @@ command = argv[optind];
filename = argv[optind+1]; filename = argv[optind+1];
if (verbosity) { if (verbosity) {
fprintf(stderr, "running command '%s' on '%s'\n", command, filename); fprintf(stderr, "%s : running command '%s' on '%s'\n",
argv[0], command, filename);
fprintf(stderr, "global fvalue : %f\n", global_fvalue);
} }
opt = lookup_cmd(command); opt = lookup_cmd(command);
@ -547,6 +671,15 @@ switch(opt) {
case Hsv: case Hsv:
foo = fimg_essai_hsv(filename); foo = fimg_essai_hsv(filename);
break; break;
case Classif:
foo = essai_classif(filename);
break;
case Ctr2x2:
foo = essai_contour_2x2(filename);
break;
case Qsortrgb:
foo = essai_qsort_rgb(filename);
break;
default: default:
fprintf(stderr, "%s : bad command\n", command); fprintf(stderr, "%s : bad command\n", command);
exit(1); exit(1);

32
funcs/vroum.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
src=/dev/shm/foo.fimg
out=out.fimg
maxi=99
W="640"
H="480"
grabopt=" -s 640x480 -v -p 0 -n 100 -c cos01 "
mkdir /tmp/V
G=$(printf "%dx%d+0+0" $W $H)
for foo in $(seq 0 $maxi)
do
echo
grabvidseq -$grabopt -o $src
fval=$(echo "$foo / $maxi" | bc -l)
./t -k $fval -v qsortrgb $src
echo $foo ' = ' $fval
dst=$(printf "/tmp/V/%03d.png" $foo)
montage $src $out -geometry $G $dst
done
convert -delay 10 V/*.png foo.gif

View File

@ -4,8 +4,9 @@ cp libfloatimg.a /usr/local/lib
cp floatimg.h /usr/local/include cp floatimg.h /usr/local/include
cp tools/mkfimg tools/fimg2pnm tools/fimgops \ cp tools/mkfimg tools/fimg2pnm tools/fimgops \
tools/fimg2png tools/fimg2tiff \ tools/fimg2png tools/fimg2tiff tools/fimg2fits \
tools/png2fimg tools/fimgstats tools/fimgfx \ tools/png2fimg tools/fimgstats tools/fimgfx \
tools/cumulfimgs \
/usr/local/bin /usr/local/bin
cp v4l2/grabvidseq v4l2/video-infos \ cp v4l2/grabvidseq v4l2/video-infos \

View File

@ -70,7 +70,7 @@ for (foo=0; foo<nbb; foo++) {
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0; (src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;
} }
return -99; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

View File

@ -246,7 +246,7 @@ for (idx=0; idx<nbre; idx++) {
} }
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int fimg_normalize(FloatImg *fi, double maxima, int notused) int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused)
{ {
double coef; double coef;

View File

@ -19,12 +19,12 @@ int foo, numbers[3];
foo = fimg_fileinfos(path, numbers); foo = fimg_fileinfos(path, numbers);
if (foo) { if (foo) {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s -> err %d\n", path, foo); fprintf(stderr, "fileinfo of '%s' -> err %d\n", path, foo);
#endif #endif
return foo; return foo;
} }
fprintf(stderr, "%s \t%d x %d\n",path, numbers[0], numbers[1]); if (verbosity) fprintf(stderr, "%-20s %d x %d\n",path, numbers[0], numbers[1]);
if (FIMG_TYPE_RGB != numbers[2]) { if (FIMG_TYPE_RGB != numbers[2]) {
fprintf(stderr, "file %s, %d : bad type\n", path, numbers[2]); fprintf(stderr, "file %s, %d : bad type\n", path, numbers[2]);
@ -36,10 +36,13 @@ return 0;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
void help(int v) void help(int v)
{ {
puts("");
puts("$ cumulfimgs a.fimg b.fimg c-fimg ...");
puts("cumulator options :"); puts("cumulator options :");
puts("\t-v\tincrease verbosity"); puts("\t-v\tincrease verbosity");
puts("\t-o\tname of output file"); puts("\t-o\tname of output file");
puts("\t-g\tconvert to gray level");
puts("");
if (verbosity) { puts(""); fimg_print_version(1); } if (verbosity) { puts(""); fimg_print_version(1); }
exit(0); exit(0);
} }
@ -48,14 +51,17 @@ int main(int argc, char *argv[])
{ {
int foo, idx; int foo, idx;
int opt; int opt;
int to_gray = 0;
char *output_file = "out.fimg"; char *output_file = "out.fimg";
FloatImg accu, temp; FloatImg accu, temp;
int src_loaded = 0; int src_loaded = 0;
g_width = g_height = 0; g_width = g_height = 0;
while ((opt = getopt(argc, argv, "ho:v")) != -1) { while ((opt = getopt(argc, argv, "gho:v")) != -1) {
switch(opt) { switch(opt) {
case 'g': to_gray = 1; break;
case 'h': help(0); break; case 'h': help(0); break;
case 'o': output_file = optarg; break; case 'o': output_file = optarg; break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
@ -67,16 +73,17 @@ if (verbosity) fprintf(stderr, "------ cumulfimgs ------\n");
fprintf(stderr, "argc = %d, optind = %d\n", argc, optind); fprintf(stderr, "argc = %d, optind = %d\n", argc, optind);
#endif #endif
// foo = testfile(output_file);
// fprintf(stderr, "Output %s -> %d\n", output_file, foo);
for (idx=optind; idx<argc; idx++) { for (idx=optind; idx<argc; idx++) {
#if DEBUG_LEVEL
fprintf(stderr, "%5d %s\n", idx, argv[idx]); fprintf(stderr, "%5d %s\n", idx, argv[idx]);
#endif
foo = testfile(argv[idx]); foo = testfile(argv[idx]);
if (foo) {
fprintf(stderr, "testfile %s -> %d\n", argv[idx],foo); fprintf(stderr, "testfile %s -> %d\n", argv[idx],foo);
exit(1);
}
if ( ! src_loaded ) { if ( ! src_loaded ) {
foo = fimg_create_from_dump(argv[idx], &accu); foo = fimg_create_from_dump(argv[idx], &accu);
@ -85,13 +92,29 @@ for (idx=optind; idx<argc; idx++) {
} }
else { else {
foo = fimg_load_from_dump(argv[idx], &temp); foo = fimg_load_from_dump(argv[idx], &temp);
if (foo) {
fprintf(stderr, "load from dump -> %d\n", foo);
exit(1);
}
fimg_add_2(&temp, &accu); fimg_add_2(&temp, &accu);
} }
} }
if (to_gray) {
foo = fimg_desaturate(&accu, &accu, 0);
if (foo) {
fprintf(stderr, "desaturate: error %d\n", foo);
}
}
foo = fimg_dump_to_file(&accu, output_file, 0); foo = fimg_dump_to_file(&accu, output_file, 0);
if (foo) {
fprintf(stderr, "error %d while saving '%s'\n", foo, output_file);
exit(1);
}
return 0; return 0;
} }

View File

@ -27,7 +27,6 @@ function essai_cmixa
{ {
./mkfimg -vv -t tpat0 $TMPF 800 600 ./mkfimg -vv -t tpat0 $TMPF 800 600
./fimgfx -vv cmixa $TMPF bar.fimg ./fimgfx -vv cmixa $TMPF bar.fimg
} }
# ----------------------------------------------------- # -----------------------------------------------------
function essai_cumulator function essai_cumulator
@ -36,11 +35,19 @@ D=" 800 600 "
./mkfimg -v -t hdeg hdeg.fimg $D ./mkfimg -v -t hdeg hdeg.fimg $D
./mkfimg -v -t vdeg vdeg.fimg $D ./mkfimg -v -t vdeg vdeg.fimg $D
./mkfimg -v -t drand48 rand.fimg $D ./mkfimg -v -t drand48 rand.fimg $D
./mkfimg -v -t tpat0 pat0.fimg $D
./cumulfimgs -vv -o foo.fimg hdeg.fimg rand.fimg vdeg.fimg ./cumulfimgs -v -g -o foo.fimg \
hdeg.fimg pat0.fimg rand.fimg vdeg.fimg
}
# -----------------------------------------------------
function essai_contour
{
./mkfimg -vv -t tpat0 $TMPF 800 600
./fimgfx -vv ctr2x2 $TMPF bar.fimg
} }
# ----------------------------------------------------- # -----------------------------------------------------
essai_cumulator essai_contour
# ----------------------------------------------------- # -----------------------------------------------------

View File

@ -21,7 +21,7 @@ typedef struct {
} Fx; } Fx;
enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0, enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
Fx_rot90, Fx_cmixa, Fx_Desat, Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm,
Fx_xper }; Fx_xper };
Fx fx_list[] = { Fx fx_list[] = {
@ -34,7 +34,9 @@ Fx fx_list[] = {
{ "rot90", Fx_rot90, 0, 0 }, { "rot90", Fx_rot90, 0, 0 },
{ "cmixa", Fx_cmixa, 0, 1 }, { "cmixa", Fx_cmixa, 0, 1 },
{ "xper", Fx_xper, 0, 1 }, { "xper", Fx_xper, 0, 1 },
{ "desat", Fx_Desat, 0, 1 }, { "desat", Fx_desat, 0, 1 },
{ "ctr2x2", Fx_ctr2x2, 0, 1 },
{ "norm", Fx_norm, 0, 1 },
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
@ -59,6 +61,9 @@ for (n=0, fx=fx_list; fx->name; fx++, n++) {
return -1; /* NOT FOUND */ return -1; /* NOT FOUND */
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/*
* this is the mutant function
*/
int do_experiment(FloatImg *S, FloatImg *D, float kf) int do_experiment(FloatImg *S, FloatImg *D, float kf)
{ {
int foo; int foo;
@ -74,10 +79,10 @@ if (foo) {
return -98; return -98;
} }
foo = fimg_killcolors_a(D, kf); foo = fimg_classif_trial(S, D, kf, 0);
if (foo) { if (foo) {
fprintf(stderr, "%s err %d killcolors %p %f\n", __func__, fprintf(stderr, "%s err %d classif_trial %p\n", __func__,
foo, S, kf); foo, S);
return -98; return -98;
} }
@ -167,11 +172,15 @@ switch (action) {
fprintf(stderr, "halfsize was not implemented\n"); fprintf(stderr, "halfsize was not implemented\n");
return -3; return -3;
case Fx_Desat: case Fx_desat:
fimg_copy_data(&src, &dest); fimg_copy_data(&src, &dest);
foo = fimg_mix_rgb_gray(&dest, global_fvalue); foo = fimg_mix_rgb_gray(&dest, global_fvalue);
break; break;
case Fx_ctr2x2:
foo = fimg_contour_2x2(&src, &dest, 0);
break;
default: default:
fprintf(stderr, "%s %s : %d is bad action\n", fprintf(stderr, "%s %s : %d is bad action\n",
__FILE__, __func__, action); __FILE__, __func__, action);