Compare commits
5 Commits
e9a61bb96a
...
14256b1476
Author | SHA1 | Date | |
---|---|---|---|
|
14256b1476 | ||
|
a600cbbf70 | ||
|
17415bd344 | ||
|
83ec42e140 | ||
|
e128add5a6 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -51,3 +51,5 @@ tools/addpnm2fimg
|
|||||||
tools/cumulfimgs
|
tools/cumulfimgs
|
||||||
tools/fimgops
|
tools/fimgops
|
||||||
tools/fimgfx
|
tools/fimgfx
|
||||||
|
tools/*.png
|
||||||
|
|
||||||
|
2
Makefile
2
Makefile
@ -18,7 +18,7 @@ essai: essai.c libfloatimg.a floatimg.h Makefile
|
|||||||
TOTAR = *.[ch] Makefile *.sh *.md \
|
TOTAR = *.[ch] Makefile *.sh *.md \
|
||||||
doc/the*.tex doc/mk*.sh doc/*.txt \
|
doc/the*.tex doc/mk*.sh doc/*.txt \
|
||||||
funcs/*.[ch] funcs/Makefile \
|
funcs/*.[ch] funcs/Makefile \
|
||||||
tools/*.[ch] tools/READEME.md tools/Makefile \
|
tools/*.[ch] tools/*.sh tools/README.md tools/Makefile \
|
||||||
v4l2/*.[ch] v4l2/Makefile \
|
v4l2/*.[ch] v4l2/Makefile \
|
||||||
scripts/*.sh scripts/README.md \
|
scripts/*.sh scripts/README.md \
|
||||||
lib/*.[ch] lib/Makefile
|
lib/*.[ch] lib/Makefile
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
% \lstset{frame=single} % dessin d'un cadre autour du listing
|
% \lstset{frame=single} % dessin d'un cadre autour du listing
|
||||||
\lstset{basicstyle=\ttfamily\small}
|
\lstset{basicstyle=\ttfamily\small}
|
||||||
\lstset{aboveskip=1em,belowskip=1em}
|
\lstset{aboveskip=0.333em,belowskip=0.666em}
|
||||||
|
|
||||||
\usepackage{babel}
|
\usepackage{babel}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
\usepackage{xspace}
|
\usepackage{xspace}
|
||||||
\usepackage[verbose]{layout}
|
\usepackage[verbose]{layout}
|
||||||
|
|
||||||
\setlength \parskip {0.40em}
|
\setlength \parskip {0.333em}
|
||||||
|
|
||||||
\makeatletter
|
\makeatletter
|
||||||
% exlpication de ce truc ?
|
% exlpication de ce truc ?
|
||||||
@ -518,8 +518,10 @@ désirées.
|
|||||||
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
|
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
Rotation de 90 degrés dans le sens horlogique d'une image RGB.
|
Rotation\index{rotation} de 90 degrés dans le sens
|
||||||
L'image de destination peut être soir vierge, soit pré-allouée
|
horlogique\footnote{ou trigonométrique,le code et la doc
|
||||||
|
ne semblent pas d'accord.} d'une image RGB.
|
||||||
|
L'image de destination peut être soit vierge, soit pré-allouée
|
||||||
aux bonnes dimensions (échange W et H).
|
aux bonnes dimensions (échange W et H).
|
||||||
|
|
||||||
% ----------------------------------
|
% ----------------------------------
|
||||||
@ -649,13 +651,13 @@ Bon, il reste le souci avec les bordures, souci qui ne peut
|
|||||||
Passons maintenant aux choses sérieuses, et définissons la
|
Passons maintenant aux choses sérieuses, et définissons la
|
||||||
description d'un filtre 3x3.
|
description d'un filtre 3x3.
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{lstlisting}
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
float mult;
|
float mult;
|
||||||
float offset;
|
float offset;
|
||||||
} FimgFilter3x3;
|
} FimgFilter3x3;
|
||||||
\end{verbatim}
|
\end{lstlisting}
|
||||||
|
|
||||||
L'usage des champs \texttt{mult} et \texttt{offset} n'est pas
|
L'usage des champs \texttt{mult} et \texttt{offset} n'est pas
|
||||||
clairement défini. Le prototype de la fonction de filtrage
|
clairement défini. Le prototype de la fonction de filtrage
|
||||||
@ -663,9 +665,9 @@ non plus, mais assez simpe quand même. Source et destination
|
|||||||
ne peuvent désigner la même image, et le champ \texttt{matrix}
|
ne peuvent désigner la même image, et le champ \texttt{matrix}
|
||||||
du filtre doit contenir des valeurs cohérentes.
|
du filtre doit contenir des valeurs cohérentes.
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{lstlisting}
|
||||||
int fimg_filter_3x3(FloatImg *src, FloatImg *dst, FimgFilter3x3 *filtr)
|
int fimg_filter_3x3(FloatImg *src, FloatImg *dst, FimgFilter3x3 *filtr)
|
||||||
\end{verbatim}
|
\end{lstlisting}
|
||||||
|
|
||||||
Comme dans la plupart des cas, la gestion des valeurs négatives
|
Comme dans la plupart des cas, la gestion des valeurs négatives
|
||||||
de pixel est laissé au hasard. Quoique, il doit bien exister
|
de pixel est laissé au hasard. Quoique, il doit bien exister
|
||||||
@ -1063,7 +1065,6 @@ calculé quelques lignes plus haut.
|
|||||||
|
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
|
||||||
# write the output as PNG for video encoding
|
# write the output as PNG for video encoding
|
||||||
#
|
#
|
||||||
fimg2png ${FDST} ${dst}
|
fimg2png ${FDST} ${dst}
|
||||||
@ -1182,12 +1183,12 @@ Pour afficher notre format .fimg exotique avec \texttt{display}, vous
|
|||||||
devez mettre ce bout de XML\index{XML} dans le fichier
|
devez mettre ce bout de XML\index{XML} dans le fichier
|
||||||
\texttt{\$HOME/.magick/delegates.xml}~:
|
\texttt{\$HOME/.magick/delegates.xml}~:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{lstlisting}
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<delegatemap>
|
<delegatemap>
|
||||||
<delegate decode="fimg" command="fimg2png '%i' '%o'"/>
|
<delegate decode="fimg" command="fimg2png '%i' '%o'"/>
|
||||||
</delegatemap>
|
</delegatemap>
|
||||||
\end{verbatim}
|
\end{lstlisting}
|
||||||
|
|
||||||
C'est juste un hack rapide, qui ne fonctionne pas très bien avec
|
C'est juste un hack rapide, qui ne fonctionne pas très bien avec
|
||||||
d'autres commande de IM, comme identify, qui a tendance à
|
d'autres commande de IM, comme identify, qui a tendance à
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* floatimg.h
|
* floatimg.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FIMG_VERSION 96
|
#define FIMG_VERSION 97
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in memory descriptor
|
* in memory descriptor
|
||||||
@ -62,6 +62,7 @@ int fimg_describe(FloatImg *head, char *txt);
|
|||||||
char *fimg_str_type(int type);
|
char *fimg_str_type(int type);
|
||||||
int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b);
|
int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b);
|
||||||
int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
|
int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
|
||||||
|
int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb);
|
||||||
int fimg_clear(FloatImg *fimg);
|
int fimg_clear(FloatImg *fimg);
|
||||||
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
|
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
|
||||||
int fimg_rgb_constant(FloatImg *head, float r, float g, float b);
|
int fimg_rgb_constant(FloatImg *head, float r, float g, float b);
|
||||||
|
@ -34,7 +34,7 @@ geometry.o: geometry.c $(DEPS)
|
|||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
rotate.o: rotate.c $(DEPS)
|
rotate.o: rotate.c $(DEPS)
|
||||||
gcc $(COPT) -DDEBUG_LEVEL=1 -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
sfx0.o: sfx0.c $(DEPS)
|
sfx0.o: sfx0.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
@ -31,7 +31,9 @@ if (src->type != FIMG_TYPE_RGB) {
|
|||||||
|
|
||||||
/* check if dst pic is not allocated */
|
/* check if dst pic is not allocated */
|
||||||
if ( 0 == (dst->type | dst->width | dst->height) ) {
|
if ( 0 == (dst->type | dst->width | dst->height) ) {
|
||||||
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "in %s, %p is empty\n", __func__, dst);
|
fprintf(stderr, "in %s, %p is empty\n", __func__, dst);
|
||||||
|
#endif
|
||||||
/* OK allocate a new fpic */
|
/* OK allocate a new fpic */
|
||||||
foo = fimg_create(dst, src->height, src->width, src->type);
|
foo = fimg_create(dst, src->height, src->width, src->type);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
@ -54,7 +56,7 @@ if ( (src->type != dst->type) ||
|
|||||||
for (y=0; y<src->height; y++) {
|
for (y=0; y<src->height; y++) {
|
||||||
for (x=0; x<src->width; x++) {
|
for (x=0; x<src->width; x++) {
|
||||||
fimg_get_rgb(src, x, y, rgb);
|
fimg_get_rgb(src, x, y, rgb);
|
||||||
fimg_plot_rgb(dst, y, x, rgb[0], rgb[1], rgb[2]);
|
fimg_put_rgb(dst, y, x, rgb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,3 +314,24 @@ prgb[2] = head->B[offset];
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau 24 mars 2020 - coronacoding */
|
||||||
|
int fimg_put_rgb(FloatImg *head, int x, int y, float *prgb)
|
||||||
|
{
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
if (head->type != FIMG_TYPE_RGB) {
|
||||||
|
#if DEBUG_LEVEL > 1
|
||||||
|
fprintf(stderr, "%s : type %d is bad.\n", __func__, head->type);
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = x + (y * head->width);
|
||||||
|
head->R[offset] = prgb[0];
|
||||||
|
head->G[offset] = prgb[1];
|
||||||
|
head->B[offset] = prgb[2];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
23
tools/essai.sh
Executable file
23
tools/essai.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# essai des differents outils
|
||||||
|
#
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
|
||||||
|
TMPF="tmp.fimg"
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
||||||
|
function essai_rot90
|
||||||
|
{
|
||||||
|
echo "=== " $0 " ==="
|
||||||
|
./mkfimg -v -t hdeg $TMPF 800 600
|
||||||
|
./fimg2png -v $TMPF foo.png
|
||||||
|
./fimgfx -v rot90 $TMPF bar.fimg
|
||||||
|
}
|
||||||
|
# -----------------------------------------------------
|
||||||
|
|
||||||
|
essai_rot90
|
||||||
|
|
||||||
|
# -----------------------------------------------------
|
@ -88,7 +88,7 @@ if (2 != argc-optind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray);
|
foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray);
|
||||||
if (verbosity)
|
if (foo)
|
||||||
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -17,24 +17,27 @@ typedef struct {
|
|||||||
char *name;
|
char *name;
|
||||||
int id;
|
int id;
|
||||||
int nbarg;
|
int nbarg;
|
||||||
|
int flags;
|
||||||
} 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_xper };
|
Fx_xper };
|
||||||
|
|
||||||
Fx fx_list[] = {
|
Fx fx_list[] = {
|
||||||
{ "cos01", Fx_cos01, 0 },
|
{ "cos01", Fx_cos01, 0, 1 },
|
||||||
{ "cos010", Fx_cos010, 0 },
|
{ "cos010", Fx_cos010, 0, 1 },
|
||||||
{ "pow2", Fx_pow2, 0 },
|
{ "pow2", Fx_pow2, 0, 1 },
|
||||||
{ "sqrt", Fx_sqrt, 0 },
|
{ "sqrt", Fx_sqrt, 0, 1 },
|
||||||
{ "gray0", Fx_gray0, 0 },
|
{ "gray0", Fx_gray0, 0, 1 },
|
||||||
{ "halfsz0", Fx_halfsz0, 0 },
|
{ "halfsz0", Fx_halfsz0, 0, 1 },
|
||||||
{ "xper", Fx_xper, 0 },
|
{ "rot90", Fx_rot90, 0, 0 },
|
||||||
|
{ "xper", Fx_xper, 0, 1 },
|
||||||
{ NULL, 0, 0 }
|
{ NULL, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int lookup_fx(char *txt)
|
int lookup_fxidx(char *txt)
|
||||||
{
|
{
|
||||||
Fx *fx;
|
Fx *fx;
|
||||||
int n;
|
int n;
|
||||||
@ -45,10 +48,10 @@ fprintf(stderr, ">>> %s ( '%s' )\n", __func__, txt);
|
|||||||
|
|
||||||
for (n=0, fx=fx_list; fx->name; fx++, n++) {
|
for (n=0, fx=fx_list; fx->name; fx++, n++) {
|
||||||
#if DEBUG_LEVEL > 1
|
#if DEBUG_LEVEL > 1
|
||||||
fprintf(stderr, "-> %3d %s\n", n, fx->name);
|
fprintf(stderr, " -> %3d %s\n", n, fx->name);
|
||||||
#endif
|
#endif
|
||||||
if (!strcmp(fx->name, txt)) {
|
if (!strcmp(fx->name, txt)) {
|
||||||
return fx->id;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1; /* NOT FOUND */
|
return -1; /* NOT FOUND */
|
||||||
@ -101,15 +104,15 @@ fimg_print_version(1);
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int do_an_effect(char *sf, int act, char *df)
|
int do_an_effect(char *sf, int fxidx, char *df)
|
||||||
{
|
{
|
||||||
FloatImg src, dest;
|
FloatImg src, dest;
|
||||||
int foo;
|
int foo, action;
|
||||||
double maxval;
|
double maxval;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' %d '%s' )\n", __func__,
|
fprintf(stderr, ">>> %s ( '%s' %d '%s' )\n", __func__,
|
||||||
sf, act, df);
|
sf, action, df);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foo = fimg_create_from_dump(sf, &src);
|
foo = fimg_create_from_dump(sf, &src);
|
||||||
@ -120,13 +123,21 @@ if (foo) {
|
|||||||
|
|
||||||
maxval = (double)fimg_get_maxvalue(&src);
|
maxval = (double)fimg_get_maxvalue(&src);
|
||||||
|
|
||||||
foo = fimg_clone(&src, &dest, 0);
|
if (fx_list[fxidx].flags & 1) {
|
||||||
if (foo) {
|
foo = fimg_clone(&src, &dest, 0);
|
||||||
|
if (foo) {
|
||||||
fprintf(stderr, "err clone %p : %d\n", &src, foo);
|
fprintf(stderr, "err clone %p : %d\n", &src, foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* XXX */
|
||||||
|
memset(&dest, 0, sizeof(dest));
|
||||||
|
}
|
||||||
|
|
||||||
switch (act) {
|
action = fx_list[fxidx].id;
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
case Fx_cos01:
|
case Fx_cos01:
|
||||||
fimg_cos_01(&src, &dest, maxval); break;
|
fimg_cos_01(&src, &dest, maxval); break;
|
||||||
case Fx_cos010:
|
case Fx_cos010:
|
||||||
@ -143,14 +154,16 @@ switch (act) {
|
|||||||
case Fx_xper:
|
case Fx_xper:
|
||||||
do_experiment(&src, &dest, maxval); break;
|
do_experiment(&src, &dest, maxval); break;
|
||||||
|
|
||||||
|
case Fx_rot90:
|
||||||
|
foo = fimg_rotate_90(&src, &dest, 0); break;
|
||||||
|
|
||||||
case Fx_halfsz0:
|
case Fx_halfsz0:
|
||||||
fprintf(stderr, "not implemented\n");
|
fprintf(stderr, "halfsize was not implemented\n");
|
||||||
return -3;
|
return -3;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s %s : %d is bad action\n",
|
fprintf(stderr, "%s %s : %d is bad action\n",
|
||||||
__FILE__, __func__, act);
|
__FILE__, __func__, action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -193,7 +206,7 @@ if (3 > argc-optind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator = argv[optind];
|
operator = argv[optind];
|
||||||
action = lookup_fx(operator);
|
action = lookup_fxidx(operator);
|
||||||
if (action < 0) {
|
if (action < 0) {
|
||||||
fprintf(stderr, "garbage found in opcode field : %s\n", operator);
|
fprintf(stderr, "garbage found in opcode field : %s\n", operator);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user