Compare commits

..

No commits in common. "2d75f70215cb4e4bc6677b3f8bdd04b40a99c414" and "e51888b206981169936cfb6475687465235939a4" have entirely different histories.

9 changed files with 22 additions and 108 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash -v
#!/bin/bash
DOC=the_floatimg_hack

View File

@ -312,7 +312,6 @@ maximale \textsl{supposée} de l'image source.
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);
\end{verbatim}
Rappelons qu'il est possible pour un logiciel applicatif
@ -325,14 +324,6 @@ maximale du capteur, et le second sert à compter le
nombre de capture\footnote{Et c'est bien géré aussi
dans l'upscaling.} effectuées.
La fonction
\texttt{fimg\_normalize(FloatImg *fi, double maxima, int notused);}
tente de gérer ce cas d'utilisation. Son ajout au captureur d'images
floues sera probablement le bienvenue. Je me suis bien rendu compte
à l'usage\footnote{Une histoire de \textit{fonderie}, un logiciel
censé faire des films flous à partir d'images floues} en situation
festive qu'il manquait des données dans la chaine de traitement.
\vspace{1em}
L'autre façon de procéder est d'explorer notre image à la
@ -340,7 +331,7 @@ recherche de la valeur maximale.
La fonction \texttt{float fimg\_get\_maxvalue(\&fimg)} est
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}
@ -544,7 +535,7 @@ Il reste plein de choses à faire pour que ce soit vraiment utilisable.
\item Remplacer le « fait-maison » par \textsc{libnetpnm}\index{pnm}.
\textsl{[en cours]}.
\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.
\end{itemize}

View File

@ -2,7 +2,7 @@
# building the base library
#
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
COPT = -Wall -fpic -g -pg -no-pie -DDEBUG_LEVEL=0
OBJS = fimg-core.o fimg-pnm.o fimg-file.o fimg-math.o \
fimg-timers.o operators.o fimg-2gray.o \

View File

@ -15,7 +15,7 @@ extern int verbosity; /* must be declared around main() */
/*
* floating imgs MUST be allocated before calling this func.
*/
int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k)
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k)
{
float kr, kg, kb, kdiv;
int nbb, foo;

View File

@ -91,11 +91,6 @@ if ( ! fimg_type_is_valid(t) ) {
return -2;
}
/*
* what to do if we've got a descriptor for an image
* already allocated ?
*/
memset(fimg, 0, sizeof(FloatImg));
surface = w * h;

View File

@ -163,14 +163,14 @@ fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head);
fp = fopen(fname, "r");
if (NULL==fp) {
perror(fname);
return -15;
exit(1);
}
foo = fread(&filehead, sizeof(FimgFileHead), 1, fp);
if (1 != foo) {
fprintf(stderr, "%s : short read\n", fname);
fclose(fp);
return -16;
return -1;
}
#if DEBUG_LEVEL
fprintf(stderr, "%s : got [ %d %d %d ] from '%s'\n", __func__,

View File

@ -151,7 +151,7 @@ void fimg_mul_cste(FloatImg *fi, float value)
{
int nbre, idx;
if ( (fi->type != FIMG_TYPE_RGB) && (fi->type != FIMG_TYPE_GRAY) ) {
if (fi->type != FIMG_TYPE_RGB) {
fprintf(stderr, "%s : type %d invalide\n",
__func__, fi->type);
return;
@ -183,7 +183,6 @@ if (fi->count < 1) {
/*
* mmmm, is this real ?
* how to accuratly check the value of 'I.fval' ?
*/
coef = 1.0 / ((double)fi->count * (double)fi->fval);

84
lib/t.c
View File

@ -41,50 +41,6 @@ if (foo) {
val = fimg_get_maxvalue(&A);
fprintf(stderr, "AFTER max pixel %f\n", val);
fimg_destroy(&A);
return 0;
}
/* ---------------------------------------------------------------- */
#define WI 1024
#define HI 768
#define KDEG 3.141592654 /* secret magic number */
int essai_interpolate(int k)
{
FloatImg A, B, C;
int foo;
foo = fimg_create(&A, WI, HI, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "%s err create A %d\n", __func__, foo);
return foo;
}
fimg_hdeg_a(&A, KDEG);
foo = fimg_create(&B, WI, HI, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "%s err create B %d\n", __func__, foo);
return foo;
}
fimg_vdeg_a(&B, KDEG);
foo = fimg_create(&C, WI, HI, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "%s err create C %d\n", __func__, foo);
return foo;
}
foo = fimg_interpolate(&A, &B, &C, 0.5);
if (foo) {
fprintf(stderr, "%s err interpolate %d\n", __func__, foo);
return foo;
}
foo = fimg_save_as_pnm(&C, "interpolate.pnm", 0);
fimg_destroy(&A); fimg_destroy(&B); fimg_destroy(&C);
return 0;
}
/* ---------------------------------------------------------------- */
@ -118,14 +74,13 @@ fimg_destroy(&gray);
return 0;
}
/* ---------------------------------------------------------------- */
#define TAILLE 1024
int essai_clone_et_copy(int unused)
{
FloatImg A, B, C;
int foo;
foo = fimg_create(&A, TAILLE, TAILLE, FIMG_TYPE_RGB);
foo = fimg_create(&A, 512, 512, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "%s err create A %d\n", __func__, foo);
return foo;
@ -135,8 +90,8 @@ if (foo) {
fprintf(stderr, "%s err drawing A %d\n", __func__, foo);
return foo;
}
foo = fimg_save_as_pnm(&A, "A.pnm", 0);
if (foo) {
fprintf(stderr, "%s : err %d on save_as_pnm\n", __func__, foo);
exit(1);
@ -148,7 +103,7 @@ if (foo) {
return foo;
}
foo = fimg_create(&C, TAILLE, TAILLE, FIMG_TYPE_RGB);
foo = fimg_create(&C, 512, 512, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "%s err create A %d\n", __func__, foo);
return foo;
@ -160,13 +115,9 @@ if (foo) {
}
foo = fimg_save_as_pnm(&C, "C.pnm", 0);
fimg_destroy(&A); fimg_destroy(&B); fimg_destroy(&C);
return 0;
}
#undef TAILLE
/* ---------------------------------------------------------------- */
int essai_contraste(char *fname)
@ -176,12 +127,6 @@ FloatImg dessin, copy;
double maxi;
foo = fimg_create_from_dump(fname, &dessin);
if (foo) {
fprintf(stderr, "in %s, error %d loading '%s'\n",
__func__, foo, fname);
return foo;
}
foo = fimg_clone(&dessin, &copy, 0);
maxi = (double)fimg_get_maxvalue(&dessin);
@ -190,28 +135,30 @@ fprintf(stderr, "image source valeur maxi = %f\n", maxi);
fimg_power_2(&dessin, &copy, maxi);
maxi = (double)fimg_get_maxvalue(&copy);
fprintf(stderr, "apres power_2 valeur maxi = %f\n", maxi);
fimg_save_as_pnm(&copy, "power2.pnm", 0);
fimg_dump_to_file(&copy, "power2.fimg", 0);
fimg_square_root(&dessin, &copy, maxi);
maxi = (double)fimg_get_maxvalue(&copy);
fprintf(stderr, "apres square_root valeur maxi = %f\n", maxi);
fimg_save_as_pnm(&copy, "squareroot.pnm", 0);
fimg_dump_to_file(&copy, "squareroot.fimg", 0);
fimg_cos_01(&dessin, &copy, maxi);
maxi = (double)fimg_get_maxvalue(&copy);
fprintf(stderr, "apres cos 01 valeur maxi = %f\n", maxi);
fimg_save_as_pnm(&copy, "cos_01.pnm", 0);
fimg_dump_to_file(&copy, "cos_01.fimg", 0);
fimg_cos_010(&dessin, &copy, maxi);
maxi = (double)fimg_get_maxvalue(&copy);
fprintf(stderr, "apres cos 010 valeur maxi = %f\n", maxi);
fimg_save_as_pnm(&copy, "cos_010.pnm", 0);
fimg_dump_to_file(&copy, "cos_010.fimg", 0);
fimg_destroy(&dessin); fimg_destroy(&copy);
fimg_destroy(&dessin);
return 0;
return -1;
}
/* ---------------------------------------------------------------- */
#define W 320
#define H 240
int main(int argc, char *argv[])
{
int foo, opt;
@ -231,14 +178,5 @@ if (verbosity) fimg_print_version(0);
foo = essai_normalize();
fprintf(stderr, "retour essai normalize -> %d\n", foo);
foo = essai_contraste("quux.fimg");
fprintf(stderr, "retour essai contraste -> %d\n", foo);
foo = essai_clone_et_copy(0);
fprintf(stderr, "retour essai clone'n'copy -> %d\n", foo);
foo = essai_interpolate(0);
fprintf(stderr, "retour essai interpolate -> %d\n", foo);
return 0;
}

View File

@ -19,14 +19,13 @@ typedef struct {
int nbarg;
} Fx;
enum fxid { Fx_cos01, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0 };
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 },
{ "gray0", Fx_gray0, 0 },
{ NULL, 0, 0 }
};
@ -60,10 +59,6 @@ puts("------ fimg special effects ------");
puts("usage:");
puts("\tfimgfix [options] <effect> source.fimg resultat.fimg");
puts("options:");
puts("\t-k N.N\tset the floating value");
puts("\t-v\tincrease verbosity");
puts("effects:");
printf("\t");
for (fx=fx_list; fx->name; fx++) {
@ -108,10 +103,6 @@ switch (act) {
case Fx_sqrt:
fimg_square_root(&src, &dest, maxval); break;
case Fx_gray0: /* new 2020 01 10 */
fimg_to_gray(&src); fimg_copy_data(&src, &dest);
break;
default:
fprintf(stderr, "*** %s : %d is bad action\n", __func__, act);
break;