Compare commits
153 Commits
56073c0c80
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8202df9a63 | ||
|
|
67ba638690 | ||
|
|
e8a7bf28e3 | ||
|
|
b19107d71b | ||
|
|
fabe94792b | ||
|
|
d1e67f7397 | ||
|
|
28453e862a | ||
|
|
2147d4b164 | ||
|
|
b0983ab18b | ||
|
|
08fcf513cc | ||
|
|
e6b72e5faa | ||
|
|
756766ca42 | ||
|
|
9ede78fa5d | ||
|
|
506bf39393 | ||
|
|
26e82619fb | ||
|
|
91440e7ea5 | ||
|
|
5fbff721d8 | ||
|
|
d510e56d44 | ||
|
|
2a8348f0f9 | ||
|
|
f473a58f75 | ||
|
|
556e1ad825 | ||
|
|
23842595fd | ||
|
|
6069c45b5a | ||
|
|
4e7debaae6 | ||
|
|
b7c32d24f3 | ||
|
|
4f27e491b1 | ||
|
|
11e87efd67 | ||
|
|
85dbf384bd | ||
|
|
8c4b9a6aa0 | ||
|
|
bb2b3b72de | ||
|
|
7586423d23 | ||
|
|
bdfb3e279d | ||
|
|
e00c6b8fb2 | ||
|
|
cce8e0b86c | ||
|
|
f5ce5a3699 | ||
|
|
0d092f89af | ||
|
|
79f4e011a5 | ||
|
|
a433176c54 | ||
|
|
02b4493659 | ||
|
|
fe3bc9d64c | ||
|
|
346ea08aba | ||
|
|
e0c5695ab8 | ||
|
|
3604f41a57 | ||
|
|
953462eb6e | ||
|
|
4ecce5bdc0 | ||
|
|
65c0212108 | ||
|
|
681899b06d | ||
|
|
fc9b6571f3 | ||
|
|
f1d42c74a6 | ||
|
|
36c9dc3e88 | ||
|
|
fa5e4d5acd | ||
|
|
5afb90bedf | ||
|
|
387c25401c | ||
|
|
9fb09f401f | ||
|
|
83e577b89a | ||
|
|
c598c4a2c0 | ||
|
|
b33a752af7 | ||
|
|
9c5849e299 | ||
|
|
9dd2064b7a | ||
|
|
a438ab9362 | ||
|
|
381f329810 | ||
|
|
3bd387f0a9 | ||
|
|
085e19942a | ||
|
|
152beddcb7 | ||
|
|
c1b6f9ae40 | ||
|
|
2c407e5dd9 | ||
|
|
c6b75d3bba | ||
|
|
12347e9066 | ||
|
|
9e9535221f | ||
|
|
1f1398f9f2 | ||
|
|
2699476135 | ||
|
|
cfe9f8cdae | ||
|
|
5d139312e2 | ||
|
|
2c14368cd5 | ||
|
|
658ef3ab08 | ||
|
|
8b8c1b466f | ||
|
|
817982c074 | ||
|
|
6a4b2f7c32 | ||
|
|
36fcc15b0a | ||
|
|
8c0f55b7cb | ||
|
|
ee5e081031 | ||
|
|
d23a35849a | ||
|
|
82ffe1c2cc | ||
|
|
0a482a7316 | ||
|
|
2c1687f82b | ||
|
|
0f245582d5 | ||
|
|
c8faa77904 | ||
|
|
03763a4dfb | ||
|
|
54d9a9939d | ||
|
|
488893f6a3 | ||
|
|
e9ca450584 | ||
|
|
3fd604b14a | ||
|
|
0169fbade7 | ||
|
|
0e00e00df5 | ||
|
|
6e9aa75694 | ||
|
|
603194451a | ||
|
|
3ef1fdf02e | ||
|
|
ad93b7935c | ||
|
|
cd6f045789 | ||
|
|
99bbd20b47 | ||
|
|
54b061232d | ||
|
|
b0fc5107c9 | ||
|
|
9e36c8b64c | ||
|
|
0a5f58867c | ||
|
|
5c59dc7ef7 | ||
|
|
7244b4c829 | ||
|
|
17a4cc4dd2 | ||
|
|
3949d147ef | ||
|
|
72cb5aa0f6 | ||
|
|
2ff17fc54b | ||
|
|
ed227d6563 | ||
|
|
90b9d4e37a | ||
|
|
253647c008 | ||
|
|
67cb70fa3b | ||
|
|
1d356a6f12 | ||
|
|
cc647b43b4 | ||
|
|
58e782de84 | ||
|
|
cb599a253c | ||
|
|
ff916c434c | ||
|
|
11a1e95146 | ||
|
|
6e92252778 | ||
|
|
a4b7f5c21c | ||
|
|
36d30b76d7 | ||
|
|
e00423ed9b | ||
|
|
3e66e822f2 | ||
|
|
a449c53592 | ||
|
|
154844c94d | ||
|
|
bf239a9004 | ||
|
|
7d66b09635 | ||
|
|
70694cf592 | ||
|
|
a72f544b4b | ||
|
|
b3ca197b89 | ||
|
|
c1ce8f7696 | ||
|
|
4ae4947fbe | ||
|
|
af103abdcf | ||
|
|
1ef877d947 | ||
|
|
1ad4b406d7 | ||
|
|
c004f22b16 | ||
|
|
d58decefcb | ||
|
|
63bc4ed7af | ||
|
|
b79f6851f5 | ||
|
|
70dc8a7638 | ||
|
|
63674c8eee | ||
|
|
be4b6a774e | ||
|
|
d750c027fa | ||
|
|
7f3912a133 | ||
|
|
1f4b424be7 | ||
|
|
d49b77a79f | ||
|
|
86a903360c | ||
|
|
5d18cb6c3f | ||
|
|
0e77fdeb7a | ||
|
|
0cb40ae2a0 | ||
|
|
a02b725ae0 |
39
.gitignore
vendored
39
.gitignore
vendored
@@ -30,15 +30,6 @@ doc/*.ind
|
|||||||
doc/co*.tex
|
doc/co*.tex
|
||||||
doc/foo.html
|
doc/foo.html
|
||||||
|
|
||||||
funcs/t
|
|
||||||
funcs/*.o
|
|
||||||
funcs/*.png
|
|
||||||
funcs/V/*
|
|
||||||
funcs/*.gif
|
|
||||||
funcs/*.fits
|
|
||||||
funcs/*.tiff
|
|
||||||
funcs/toto
|
|
||||||
|
|
||||||
scripts/*.fimg
|
scripts/*.fimg
|
||||||
scripts/*.pnm
|
scripts/*.pnm
|
||||||
scripts/*.gif
|
scripts/*.gif
|
||||||
@@ -54,23 +45,6 @@ v4l2/*.tiff
|
|||||||
v4l2/video-infos
|
v4l2/video-infos
|
||||||
v4l2/nc-camcontrol
|
v4l2/nc-camcontrol
|
||||||
|
|
||||||
tools/fimg2png
|
|
||||||
tools/fimg2pnm
|
|
||||||
tools/fimg2tiff
|
|
||||||
tools/fimg2fits
|
|
||||||
tools/fimg2text
|
|
||||||
tools/fimgstats
|
|
||||||
tools/fimghalfsize
|
|
||||||
tools/mkfimg
|
|
||||||
tools/png2fimg
|
|
||||||
tools/addtga2fimg
|
|
||||||
tools/addpnm2fimg
|
|
||||||
tools/cumulfimgs
|
|
||||||
tools/fimgops
|
|
||||||
tools/fimgfx
|
|
||||||
tools/fimgmetadata
|
|
||||||
tools/*.png
|
|
||||||
tools/*.tiff
|
|
||||||
|
|
||||||
Fonderie/*.o
|
Fonderie/*.o
|
||||||
Fonderie/*.png
|
Fonderie/*.png
|
||||||
@@ -84,17 +58,4 @@ Fonderie/singlepass
|
|||||||
Fonderie/crapdef.h
|
Fonderie/crapdef.h
|
||||||
Fonderie/crapstr.h
|
Fonderie/crapstr.h
|
||||||
|
|
||||||
experiment/assemblage
|
|
||||||
experiment/extracteur
|
|
||||||
experiment/*.fimg
|
|
||||||
experiment/*.pnm
|
|
||||||
experiment/*.o
|
|
||||||
experiment/muxplanes
|
|
||||||
experiment/movepixels
|
|
||||||
experiment/tcache
|
|
||||||
|
|
||||||
contrib/fimg2povhf
|
|
||||||
contrib/*.tga
|
|
||||||
contrib/pov.stderr
|
|
||||||
contrib/*.png
|
|
||||||
contrib/*.gif
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ COPT = -g -fpic -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses
|
|||||||
LIBS = ../libfloatimg.a -ltiff -lpnglite -lm -lz -lcfitsio
|
LIBS = ../libfloatimg.a -ltiff -lpnglite -lm -lz -lcfitsio
|
||||||
|
|
||||||
OBJS = fifo.o sfx.o crapulator.o glitches.o metriques.o \
|
OBJS = fifo.o sfx.o crapulator.o glitches.o metriques.o \
|
||||||
filterstack.o single.o
|
filterstack.o single.o utilfuncs.o
|
||||||
|
|
||||||
DEPS = ../floatimg.h \
|
DEPS = ../floatimg.h \
|
||||||
../libfloatimg.a \
|
../libfloatimg.a \
|
||||||
fifo.h crapulator.h metriques.h glitches.h sfx.h \
|
fifo.h crapulator.h metriques.h glitches.h sfx.h \
|
||||||
filterstack.h crapdef.h crapstr.h single.h
|
filterstack.h crapdef.h crapstr.h single.h utilfuncs.h
|
||||||
|
|
||||||
all: fonderie interpolator singlepass t
|
all: fonderie interpolator singlepass t
|
||||||
|
|
||||||
@@ -41,19 +41,19 @@ singlepass: singlepass.c ${DEPS} ${OBJS} Makefile
|
|||||||
# some files are magically generated, sorry.
|
# some files are magically generated, sorry.
|
||||||
#
|
#
|
||||||
crapdef.h: crapulors.liste Makefile craplist2h.awk
|
crapdef.h: crapulors.liste Makefile craplist2h.awk
|
||||||
./craplist2h.awk < $< | tee $@
|
< $< ./craplist2h.awk > $@
|
||||||
|
|
||||||
crapstr.h: crapulors.liste Makefile craplist2str.awk
|
crapstr.h: crapulors.liste Makefile craplist2str.awk
|
||||||
./craplist2str.awk < $< | tee $@
|
< $< ./craplist2str.awk > $@
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
#
|
#
|
||||||
# a lot of silly functions
|
# a lot of silly functions
|
||||||
#
|
#
|
||||||
crapulator.o: crapulator.c ${DEPS} Makefile
|
crapulator.o: crapulator.c $(DEPS) Makefile
|
||||||
gcc ${COPT} -c $<
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
fifo.o: fifo.c fifo.h Makefile
|
fifo.o: fifo.c fifo.h $(DEPS) Makefile
|
||||||
gcc ${COPT} -c $<
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
sfx.o: sfx.c ${DEPS} Makefile
|
sfx.o: sfx.c ${DEPS} Makefile
|
||||||
@@ -71,4 +71,7 @@ metriques.o: metriques.c metriques.h Makefile
|
|||||||
glitches.o: glitches.c glitches.h Makefile
|
glitches.o: glitches.c glitches.h Makefile
|
||||||
gcc ${COPT} -c $<
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
|
utilfuncs.o: utilfuncs.c utilfuncs.h Makefile
|
||||||
|
gcc ${COPT} -c $<
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|||||||
@@ -3,12 +3,14 @@
|
|||||||
Avec toutes ces fonctions disponibles et `grabvidseq`, nous
|
Avec toutes ces fonctions disponibles et `grabvidseq`, nous
|
||||||
savons faire des images **floues**. L'étape suivante, les plus
|
savons faire des images **floues**. L'étape suivante, les plus
|
||||||
pervers d'entre vous le savent déja, est celle de la création
|
pervers d'entre vous le savent déja, est celle de la création
|
||||||
de **films flous** dans le domaine spacio-temporel.
|
de **films flous** dans le domaine spatio-temporel.
|
||||||
|
|
||||||
À l'heure actuelle, il y a plusieurs programmes distincts. Le premier
|
À l'heure actuelle, il y a plusieurs programmes distincts. Le premier
|
||||||
(fonderie) fait une moyenne mobile sur N images consécutives,
|
(fonderie) fait une moyenne mobile sur N images consécutives,
|
||||||
et le second (interpolator) fait un fondu-enchainé de N pas
|
le second (interpolator) fait un fondu-enchainé de N pas
|
||||||
entre deux images consécutives.
|
entre deux images consécutives,
|
||||||
|
et le troisième (singlepass) fait d'autres trucs, comme
|
||||||
|
répéter N fois un image pour avoir une vidéo sacadée.
|
||||||
|
|
||||||
Mais avant et après un de ces deux traitements, il y a des chaines
|
Mais avant et après un de ces deux traitements, il y a des chaines
|
||||||
de filtres...
|
de filtres...
|
||||||
@@ -20,16 +22,15 @@ destinés à augmenter la kitchitude du produit final. Ils peuvent être chainé
|
|||||||
les uns après les autres, à l'entrée et à la sortie du process
|
les uns après les autres, à l'entrée et à la sortie du process
|
||||||
de floutagement.
|
de floutagement.
|
||||||
|
|
||||||
Ces filtres ont chacun un nom et un numéro. que l'on peut (en théorie)
|
Ces filtres ont chacun un nom, utilisable dans une chaine de filtres.
|
||||||
utiliser indistinctement dans une chaine de filtres.
|
|
||||||
L'option `-L` de ces logiciels permet d'obtenir la liste des filtres.
|
L'option `-L` de ces logiciels permet d'obtenir la liste des filtres.
|
||||||
|
Pour ne rien filtrer, utilisez le filtre `none`, il est là pour ça.
|
||||||
|
|
||||||
Une chaine de filtres est constituée d'une liste de nom ou de numéro
|
Une chaine de filtres est constituée d'une liste de nom
|
||||||
de filtre, séparés par le caractère `:`, une façon de faire très
|
de filtre, séparés par le caractère `:`, une façon de faire très
|
||||||
classique dans notre univers, en fait. Et si on veut prendre des risques,
|
classique dans notre univers, en fait.
|
||||||
on doit continuer à appeler les filtres par leur numéro, jdçjdr.
|
|
||||||
|
|
||||||
`mirsplit:ctr2x2:3:killlines`
|
`mirsplit:ctr2x2:killlines`
|
||||||
|
|
||||||
Nous allons donc voir quelques exemples un peu plus loin.
|
Nous allons donc voir quelques exemples un peu plus loin.
|
||||||
|
|
||||||
@@ -70,12 +71,14 @@ GRABDIR="/spool/tth/fonderie"
|
|||||||
FONDEUR="$HOME/Devel/FloatImg/Fonderie/fonderie"
|
FONDEUR="$HOME/Devel/FloatImg/Fonderie/fonderie"
|
||||||
GLOB=${GRABDIR}'/?????.fimg'
|
GLOB=${GRABDIR}'/?????.fimg'
|
||||||
|
|
||||||
${FONDEUR} -I "$GLOB" -E cos01:25 -T 30 -F 2:classtrial
|
${FONDEUR} -I "$GLOB" -E cos01:trinitron -F classtrial -T 30
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Par défaut le répertoire où sont exportées les images est nommé
|
||||||
|
`p8/` et il doit être là, c'est donc à vous de le créer.
|
||||||
Votre machine va maintenant mouliner avec entrain et persévérance,
|
Votre machine va maintenant mouliner avec entrain et persévérance,
|
||||||
puis
|
puis
|
||||||
ensuite il suffit d'encoder toutes les images générées dans
|
ensuite il vous suffira d'encoder toutes les images générées dans
|
||||||
`p8/` (répertoire de sortie par défaut)
|
`p8/` (répertoire de sortie par défaut)
|
||||||
avec une incantation de ffmpeg :
|
avec une incantation de ffmpeg :
|
||||||
|
|
||||||
@@ -95,7 +98,7 @@ assez rudimentaire, avec un paramétrage simpliste, et un manque
|
|||||||
criant de documentation...
|
criant de documentation...
|
||||||
|
|
||||||
Dans la même équipe, vous pouvez aussi aller contempler `glitches.c`
|
Dans la même équipe, vous pouvez aussi aller contempler `glitches.c`
|
||||||
pour voir le genre de traitement que l'on fait subir à nox pixels
|
pour voir le genre de traitement que l'on fait subir à nos pixels
|
||||||
flottants.
|
flottants.
|
||||||
|
|
||||||
## Interpolator
|
## Interpolator
|
||||||
@@ -112,8 +115,8 @@ usage:
|
|||||||
interpolator [options] <inglob> <outdir> <nbsteep>
|
interpolator [options] <inglob> <outdir> <nbsteep>
|
||||||
options:
|
options:
|
||||||
-S nn mysterious sort
|
-S nn mysterious sort
|
||||||
-E i:bla:k input filter chain
|
-E foo:bla:kr input filter chain
|
||||||
-F name:j output filter chain
|
-F name:just output filter chain
|
||||||
-L list available filters
|
-L list available filters
|
||||||
-v increase verbosity
|
-v increase verbosity
|
||||||
```
|
```
|
||||||
@@ -130,12 +133,15 @@ usage:
|
|||||||
-F define:the:filter:chain
|
-F define:the:filter:chain
|
||||||
-g input glob pattern
|
-g input glob pattern
|
||||||
-L list available filters
|
-L list available filters
|
||||||
|
-r N repetiiing factor
|
||||||
-O /output/directory
|
-O /output/directory
|
||||||
-v spit more messages
|
-v spit more messages
|
||||||
```
|
```
|
||||||
|
|
||||||
## Conclusion
|
## Conclusion
|
||||||
|
|
||||||
|
Tout cela est bien rigolo :)
|
||||||
|
|
||||||
|
|
||||||
**Use the source, Luke**
|
**Use the source, Luke**
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,19 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
print "// -----------------------------------"
|
print "// -------------------------------------"
|
||||||
print "// generated file, do not edit by hand !"
|
print "// generated file, do not edit by hand !"
|
||||||
print "// -----------------------------------"
|
print "// -------------------------------------"
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 is the badly brain-designed numeric id
|
# $1 is the badly brain-designed numeric id
|
||||||
# $2 is the user name of the filter
|
# $2 is the user name of the filter
|
||||||
|
|
||||||
{
|
{
|
||||||
printf "#define CR_%s (%d)\n", $2, $1
|
name = sprintf("CR_%s", $2)
|
||||||
|
printf "#define %-15s (%d)\n", name, $1
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
print "// generated file, do not edit by hand !"
|
print "\n// generated file, do not edit by hand !"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
# is includet by 'crapulator.c'
|
# is includet by 'crapulator.c'
|
||||||
#
|
#
|
||||||
BEGIN {
|
BEGIN {
|
||||||
print "// -----------------------------------"
|
print "// -------------------------------------"
|
||||||
print "// generated file, do not edit by hand";
|
print "// generated file, do not edit by hand !";
|
||||||
print "// -----------------------------------"
|
print "// -------------------------------------"
|
||||||
print "Crapulor CrapL[] = {";
|
print "Crapulor CrapL[] = {";
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 is the badly brain-designed numeric id
|
# $1 is the badly brain-designed numeric id
|
||||||
@@ -16,12 +16,13 @@ BEGIN {
|
|||||||
# $3 and $4 are two not used parameters
|
# $3 and $4 are two not used parameters
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
printf " { CR_%s, \"%s\", %d, %f }, // id=%d\n",
|
name = sprintf("CR_%s", $2)
|
||||||
$2, $2, $3, $4, $1;
|
printf " { %-14s, \"%s\", %d, %f }, // #%d\n",
|
||||||
|
name, $2, $3, $4, $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
print " { -1, NULL }"
|
print " { -1, NULL }"
|
||||||
print " };"
|
print " };"
|
||||||
print "// generated file, do not edit by hand"
|
print "// ! generated file, do not edit by hand !"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ FloatImg img;
|
|||||||
int foo, retval;
|
int foo, retval;
|
||||||
FimgFilter3x3 *pfiltre;
|
FimgFilter3x3 *pfiltre;
|
||||||
|
|
||||||
FimgFilter3x3 lowpass = {
|
static FimgFilter3x3 lowpass = {
|
||||||
{
|
{
|
||||||
1.0, 2.0, 1.0,
|
1.0, 2.0, 1.0,
|
||||||
2.0, 4.0, 2.0,
|
2.0, 4.0, 2.0,
|
||||||
@@ -91,7 +91,7 @@ FimgFilter3x3 lowpass = {
|
|||||||
16.0, 0.0
|
16.0, 0.0
|
||||||
};
|
};
|
||||||
|
|
||||||
FimgFilter3x3 hipass = {
|
static FimgFilter3x3 hipass = {
|
||||||
/* there was a bug with this filter */
|
/* there was a bug with this filter */
|
||||||
{
|
{
|
||||||
-1.0, -1.0, -1.0,
|
-1.0, -1.0, -1.0,
|
||||||
@@ -101,7 +101,7 @@ FimgFilter3x3 hipass = {
|
|||||||
1.0, 0.0
|
1.0, 0.0
|
||||||
};
|
};
|
||||||
|
|
||||||
FimgFilter3x3 diagonal = {
|
static FimgFilter3x3 diagonal = {
|
||||||
/* there was a bug with this filter */
|
/* there was a bug with this filter */
|
||||||
{
|
{
|
||||||
4.0, 1.0, 0.0,
|
4.0, 1.0, 0.0,
|
||||||
@@ -195,6 +195,22 @@ int ret;
|
|||||||
memset(&tmp, 0, sizeof(FloatImg));
|
memset(&tmp, 0, sizeof(FloatImg));
|
||||||
fimg_clone(img, &tmp, 0);
|
fimg_clone(img, &tmp, 0);
|
||||||
ret = fimg_pixelize_h_rnd(img, &tmp, k);
|
ret = fimg_pixelize_h_rnd(img, &tmp, k);
|
||||||
|
if (verbosity > 1) fprintf(stderr, "in %s, pixelize H rnd -> %d\n",
|
||||||
|
__func__, ret);
|
||||||
|
fimg_copy_data(&tmp, img);
|
||||||
|
fimg_destroy(&tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* added Mon Apr 1 15:56:54 UTC 2024 */
|
||||||
|
static int run_triptyq(FloatImg *img, int k)
|
||||||
|
{
|
||||||
|
FloatImg tmp;
|
||||||
|
int ret;
|
||||||
|
memset(&tmp, 0, sizeof(FloatImg));
|
||||||
|
fimg_clone(img, &tmp, 0);
|
||||||
|
ret = fimg_make_triptyq(img, &tmp, k);
|
||||||
fimg_copy_data(&tmp, img);
|
fimg_copy_data(&tmp, img);
|
||||||
fimg_destroy(&tmp);
|
fimg_destroy(&tmp);
|
||||||
|
|
||||||
@@ -222,7 +238,21 @@ FloatImg tmp;
|
|||||||
int ret;
|
int ret;
|
||||||
memset(&tmp, 0, sizeof(FloatImg));
|
memset(&tmp, 0, sizeof(FloatImg));
|
||||||
fimg_clone(img, &tmp, 0);
|
fimg_clone(img, &tmp, 0);
|
||||||
ret = graylevel2popcolors(img, &tmp, k);
|
ret = graylevel2popcolors(img, &tmp, k);
|
||||||
|
fimg_copy_data(&tmp, img);
|
||||||
|
fimg_destroy(&tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* new Sun Feb 12 11:30:02 CET 2023 */
|
||||||
|
static int run_rndfluffy(FloatImg *img, int k)
|
||||||
|
{
|
||||||
|
FloatImg tmp;
|
||||||
|
int ret;
|
||||||
|
memset(&tmp, 0, sizeof(FloatImg));
|
||||||
|
fimg_clone(img, &tmp, 0);
|
||||||
|
ret = fimg_make_rndfluffy_lines(img, &tmp, k);
|
||||||
fimg_copy_data(&tmp, img);
|
fimg_copy_data(&tmp, img);
|
||||||
fimg_destroy(&tmp);
|
fimg_destroy(&tmp);
|
||||||
|
|
||||||
@@ -234,12 +264,37 @@ static int run_decomprgbz_gray(FloatImg *img, int k)
|
|||||||
FloatImg tmp;
|
FloatImg tmp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* ugly code here */
|
||||||
memset(&tmp, 0, sizeof(FloatImg));
|
memset(&tmp, 0, sizeof(FloatImg));
|
||||||
fimg_clone(img, &tmp, 0);
|
fimg_clone(img, &tmp, 0);
|
||||||
ret = fimg_decomp_rgbz_gray(img, &tmp, k);
|
ret = fimg_decomp_rgbz_gray(img, &tmp, k);
|
||||||
fimg_copy_data(&tmp, img);
|
fimg_copy_data(&tmp, img);
|
||||||
fimg_destroy(&tmp);
|
fimg_destroy(&tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* new Sun Jul 16 11:27:43 UTC 2023 */
|
||||||
|
int run_suprbg(FloatImg *img, int notused)
|
||||||
|
{
|
||||||
|
FloatImg tmp;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (notused) {
|
||||||
|
fprintf(stderr, "FATAL: invalid notused in %s\n", __func__);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ugly code here */
|
||||||
|
memset(&tmp, 0, sizeof(FloatImg));
|
||||||
|
fimg_clone(img, &tmp, 0);
|
||||||
|
ret = poke_sup_rb_g(img, &tmp);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "%s: ret = %d\n", __func__, ret);
|
||||||
|
}
|
||||||
|
fimg_copy_data(&tmp, img);
|
||||||
|
fimg_destroy(&tmp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
@@ -399,14 +454,6 @@ switch (idFx) {
|
|||||||
retval = plot_multidots(image, 42);
|
retval = plot_multidots(image, 42);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CR_message:
|
|
||||||
fprintf(stderr, "### msg from pid %d, fval=%f ###\n",
|
|
||||||
getpid(), fval);
|
|
||||||
/* here, we can display stats ! */
|
|
||||||
fimg_describe(image, "in crapulator");
|
|
||||||
retval = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CR_nothing:
|
case CR_nothing:
|
||||||
retval = do_something(image, 3);
|
retval = do_something(image, 3);
|
||||||
break;
|
break;
|
||||||
@@ -418,9 +465,12 @@ switch (idFx) {
|
|||||||
case CR_pixelizh:
|
case CR_pixelizh:
|
||||||
retval = run_pixelize_0(image, 8);
|
retval = run_pixelize_0(image, 8);
|
||||||
break;
|
break;
|
||||||
|
case CR_pixelizv:
|
||||||
|
retval = run_pixelize_0(image, 32);
|
||||||
|
break;
|
||||||
|
|
||||||
case CR_pixelrand:
|
case CR_pixelrand:
|
||||||
retval = run_pixelize_random(image, -1);
|
retval = run_pixelize_random(image, 16);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CR_splitlevel:
|
case CR_splitlevel:
|
||||||
@@ -428,10 +478,10 @@ switch (idFx) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CR_decrgbzc:
|
case CR_decrgbzc:
|
||||||
retval = run_decomprgbz_color(image, -1);
|
retval = run_decomprgbz_color(image, 0);
|
||||||
break;
|
break;
|
||||||
case CR_decrgbzg:
|
case CR_decrgbzg:
|
||||||
retval = run_decomprgbz_gray(image, -1);
|
retval = run_decomprgbz_gray(image, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CR_hilightr:
|
case CR_hilightr:
|
||||||
@@ -439,10 +489,37 @@ switch (idFx) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CR_gr2popcol:
|
case CR_gr2popcol:
|
||||||
// fprintf(stderr, "******* TO BE DONE ********\n");
|
|
||||||
retval = run_gr2popcol(image, -1);
|
retval = run_gr2popcol(image, -1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CR_fluffy:
|
||||||
|
retval = run_rndfluffy(image, 75);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_suprbg:
|
||||||
|
retval = run_suprbg(image, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_thermocol:
|
||||||
|
/* new Wed Mar 20 19:42:42 UTC 2024 */
|
||||||
|
retval = fimg_auto_thermique(image, image, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_triptyq:
|
||||||
|
/* added Mon Apr 1 15:52:32 UTC 2024*/
|
||||||
|
retval = run_triptyq(image, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_togray:
|
||||||
|
retval = fimg_to_gray(image);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CR_shift0:
|
||||||
|
/* added Sun Sep 29 16:55:54 UTC 2024 */
|
||||||
|
retval = fimg_auto_shift_to_zero(image, image);
|
||||||
|
// fprintf(stderr, "******** Shift Zero -> %d\n", retval);
|
||||||
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
fprintf(stderr, "%s : effect #%d invalid\n",
|
fprintf(stderr, "%s : effect #%d invalid\n",
|
||||||
__func__, idFx);
|
__func__, idFx);
|
||||||
@@ -478,13 +555,25 @@ void list_crapulors(char *texte)
|
|||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
#define OUT stdout
|
#define OUT stdout
|
||||||
if (NULL!=texte) fprintf(OUT, "______________. %s\n", texte);
|
|
||||||
|
if (verbosity) {
|
||||||
|
fprintf(stderr, "We have around %ld filters now !\n", NBCRAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL!=texte && verbosity)
|
||||||
|
fprintf(OUT, " _________ %s _________\n", texte);
|
||||||
|
|
||||||
for (idx=0; CrapL[idx].id!=-1; idx++) {
|
for (idx=0; CrapL[idx].id!=-1; idx++) {
|
||||||
fprintf(OUT, " %-12s | %4d | %5d | %8.3f\n",
|
if (verbosity) {
|
||||||
|
fprintf(OUT, " %-12s | %4d | %5d | %8.3f\n",
|
||||||
CrapL[idx].name,
|
CrapL[idx].name,
|
||||||
CrapL[idx].id,
|
CrapL[idx].id,
|
||||||
CrapL[idx].ipar,
|
CrapL[idx].ipar,
|
||||||
CrapL[idx].fpar);
|
CrapL[idx].fpar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(OUT, "%s\n", CrapL[idx].name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#undef OUT
|
#undef OUT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,5 +42,11 @@
|
|||||||
50 decrgbzc 1 99
|
50 decrgbzc 1 99
|
||||||
51 decrgbzg 1 99
|
51 decrgbzg 1 99
|
||||||
60 gr2popcol 1 99
|
60 gr2popcol 1 99
|
||||||
99 message 1 1.0
|
61 fluffy 1 0.12
|
||||||
|
62 suprbg 1 0
|
||||||
|
80 thermocol 1 0
|
||||||
|
81 triptyq 1 0
|
||||||
|
90 togray 1 0
|
||||||
|
91 shift0 1 0
|
||||||
-1 end 1 1.0
|
-1 end 1 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ return 0;
|
|||||||
*/
|
*/
|
||||||
int export_fifo(char *fname, int notused)
|
int export_fifo(char *fname, int notused)
|
||||||
{
|
{
|
||||||
int foo, type;
|
int foo;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
||||||
@@ -118,7 +118,7 @@ return 0;
|
|||||||
int insert_picture(FloatImg *src)
|
int insert_picture(FloatImg *src)
|
||||||
{
|
{
|
||||||
FloatImg *dst;
|
FloatImg *dst;
|
||||||
int nbre, foo;
|
int nbre;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( %p )\n", __func__, src);
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, src);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
#include "fifo.h"
|
#include "fifo.h"
|
||||||
#include "glitches.h"
|
#include "glitches.h"
|
||||||
#include "crapulator.h"
|
#include "crapulator.h"
|
||||||
@@ -108,7 +109,7 @@ fprintf(stderr, "glob '%s' -> %d, %d files found\n", pattern, foo,
|
|||||||
/* get the size of the inputs images */
|
/* get the size of the inputs images */
|
||||||
foo = fimg_fileinfos(globbuf.gl_pathv[0], datas);
|
foo = fimg_fileinfos(globbuf.gl_pathv[0], datas);
|
||||||
width = datas[0]; height = datas[1];
|
width = datas[0]; height = datas[1];
|
||||||
fprintf(stderr, "first image size %dx%d\n", width, height);
|
if (verbosity) fprintf(stderr, "first image size %dx%d\n", width, height);
|
||||||
|
|
||||||
fimg_create(&input, width, height, 3);
|
fimg_create(&input, width, height, 3);
|
||||||
|
|
||||||
@@ -120,10 +121,10 @@ if (foo) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
maxvalue = fimg_get_maxvalue(&input);
|
maxvalue = fimg_get_maxvalue(&input);
|
||||||
fprintf(stderr, "first image maxvalue %f\n", maxvalue);
|
if (verbosity) fprintf(stderr, "first image maxvalue %f\n", maxvalue);
|
||||||
|
|
||||||
foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB);
|
foo = create_fifo(szfifo, width, height, FIMG_TYPE_RGB);
|
||||||
fprintf(stderr, "init fifo (%d slots) --> %d\n", szfifo, foo);
|
if (verbosity) fprintf(stderr, "init fifo (%d slots) = %d\n", szfifo, foo);
|
||||||
|
|
||||||
/* XXX inject a few strange pics in the fifo */
|
/* XXX inject a few strange pics in the fifo */
|
||||||
insert_blank(&input, blk, outdir);
|
insert_blank(&input, blk, outdir);
|
||||||
@@ -186,10 +187,12 @@ puts("\t-F\toutput:filter:chain");
|
|||||||
// puts("\t-g\tconvert to gray");
|
// puts("\t-g\tconvert to gray");
|
||||||
puts("\t-I\tinput glob pattern");
|
puts("\t-I\tinput glob pattern");
|
||||||
puts("\t-L\tlist available filters");
|
puts("\t-L\tlist available filters");
|
||||||
puts("\t-O\toutput directory");
|
puts("\t-O\toutput directory (default p8/)");
|
||||||
puts("\t-T\tfifo size");
|
puts("\t-T\tfifo size");
|
||||||
puts("\t-v\tincrease verbosity");
|
puts("\t-v\tincrease verbosity");
|
||||||
|
|
||||||
|
if (verbosity) { puts(""); fimg_print_version(2); puts(""); }
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
@@ -200,13 +203,12 @@ int fifosize = 10;
|
|||||||
char *in_pattern = "capture/?????.fimg";
|
char *in_pattern = "capture/?????.fimg";
|
||||||
char *out_dir = "p8";
|
char *out_dir = "p8";
|
||||||
int outfmt = FILE_TYPE_PNG;
|
int outfmt = FILE_TYPE_PNG;
|
||||||
int blanks = 20;
|
int blanks = 10;
|
||||||
char *InFchain = "none";
|
char *InFchain = "none";
|
||||||
char *OutFchain = "none";
|
char *OutFchain = "none";
|
||||||
|
|
||||||
fprintf(stderr, "*** %s\n\tcompiled %s, %s, pid %d\n",
|
fprintf(stderr, "*** %s\n\tcompiled %s, %s, pid %d\n",
|
||||||
argv[0], __DATE__, __TIME__, getpid());
|
argv[0], __DATE__, __TIME__, getpid());
|
||||||
fimg_print_version(2);
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:T:vw:x:")) != -1) {
|
while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:T:vw:x:")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
@@ -229,6 +231,7 @@ while ((opt = getopt(argc, argv, "B:E:F:ghI:LO:T:vw:x:")) != -1) {
|
|||||||
break;
|
break;
|
||||||
case 'v': verbosity++;
|
case 'v': verbosity++;
|
||||||
break;
|
break;
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +240,16 @@ if (verbosity) {
|
|||||||
fprintf(stderr, "\toutput dir '%s'\n", out_dir);
|
fprintf(stderr, "\toutput dir '%s'\n", out_dir);
|
||||||
fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
|
fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
|
||||||
fprintf(stderr, "\tout filter '%s'\n", OutFchain);
|
fprintf(stderr, "\tout filter '%s'\n", OutFchain);
|
||||||
|
fprintf(stderr, "\tfifo size %d\n", fifosize);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* check for the export directory
|
||||||
|
*/
|
||||||
|
foo = check_if_export_dir_is_valid(out_dir, 0);
|
||||||
|
if ( !foo ) {
|
||||||
|
fprintf(stderr, "** export dir (%s) not valid\n", out_dir);
|
||||||
|
fprintf(stderr, "** may be you have to create it ?\n");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foo = parse_filter_chain(0, InFchain);
|
foo = parse_filter_chain(0, InFchain);
|
||||||
@@ -258,7 +271,7 @@ if (verbosity > 1) {
|
|||||||
|
|
||||||
foo = demarre_la_machine(in_pattern, out_dir, fifosize, outfmt, blanks);
|
foo = demarre_la_machine(in_pattern, out_dir, fifosize, outfmt, blanks);
|
||||||
|
|
||||||
fprintf(stderr, "retour du big-run de la machine -> %d\n", foo);
|
fprintf(stderr, "retour du bigrun de la machine -> %d\n", foo);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,36 +151,38 @@ int pass, szimg, osrc, odst;
|
|||||||
szimg = picture->width * picture->height;
|
szimg = picture->width * picture->height;
|
||||||
|
|
||||||
for (pass=0; pass<szimg/32; pass++) {
|
for (pass=0; pass<szimg/32; pass++) {
|
||||||
|
|
||||||
osrc = rand() % szimg;
|
osrc = rand() % szimg;
|
||||||
odst = rand() % szimg;
|
odst = rand() % szimg;
|
||||||
picture->R[odst] = (picture->R[osrc] + picture->R[odst]) / 2.0;
|
picture->R[odst] = (picture->R[osrc] + picture->R[odst]) / 2.0;
|
||||||
picture->G[odst] = (picture->G[osrc] + picture->G[odst]) / 2.0;
|
picture->G[odst] = (picture->G[osrc] + picture->G[odst]) / 2.0;
|
||||||
picture->B[odst] = (picture->B[osrc] + picture->B[odst]) / 2.0;
|
picture->B[odst] = (picture->B[osrc] + picture->B[odst]) / 2.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* FIXME XXX
|
||||||
|
*/
|
||||||
int random_blocks(FloatImg *picture, int percent)
|
int random_blocks(FloatImg *picture, int percent)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if ( (picture->width%16) || (picture->height%16) )
|
if ( (picture->width%16) || (picture->height%16) )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: %d%d bad dims\n", __func__,
|
fprintf(stderr, "WARNING %s: %dx%d bad dims\n", __func__,
|
||||||
picture->width, picture->height);
|
picture->width, picture->height);
|
||||||
|
// return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y=0; y<picture->height; y+=16) {
|
for (y=16; y<picture->height-16; y+=16) {
|
||||||
for (x=0; x<picture->width; x+=16) {
|
for (x=16; x<picture->width-16; x+=16) {
|
||||||
if (percent < (rand()%100) ) {
|
if (percent < (rand()%100) ) {
|
||||||
un_petit_flou_8x8(picture, x, y);
|
un_petit_flou_8x8(picture, x, y);
|
||||||
un_petit_flou_8x8(picture, x+8, y);
|
un_petit_flou_8x8(picture, x+8, y);
|
||||||
un_petit_flou_8x8(picture, x, y+8);
|
un_petit_flou_8x8(picture, x, y+8);
|
||||||
un_petit_flou_8x8(picture, x+8, y+8);
|
un_petit_flou_8x8(picture, x+8, y+8);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
#include "fifo.h"
|
#include "fifo.h"
|
||||||
#include "glitches.h"
|
#include "glitches.h"
|
||||||
#include "crapulator.h"
|
#include "crapulator.h"
|
||||||
@@ -54,10 +55,14 @@ char *filename;
|
|||||||
IdxValue *idxvalues;
|
IdxValue *idxvalues;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, ptr_glob,
|
fprintf(stderr, ">>> %s ( %p %p %d %p)\n", __func__, ptr_glob,
|
||||||
ptr_idxval, method);
|
ptr_idxval, method, p_average);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (0==method && verbosity) {
|
||||||
|
fprintf(stderr, "\tWTF? in %s, sort method was ZERO?\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
nombre = ptr_glob->gl_pathc;
|
nombre = ptr_glob->gl_pathc;
|
||||||
|
|
||||||
/* allocate the array for the sorting action */
|
/* allocate the array for the sorting action */
|
||||||
@@ -66,7 +71,7 @@ if (NULL==idxvalues) {
|
|||||||
fprintf(stderr, "MEMORY ERROR in %s\n", __func__);
|
fprintf(stderr, "MEMORY ERROR in %s\n", __func__);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "IdxValues array at %p\n", idxvalues);
|
// fprintf(stderr, "IdxValues array at %p\n", idxvalues);
|
||||||
|
|
||||||
*ptr_idxval = idxvalues;
|
*ptr_idxval = idxvalues;
|
||||||
average = 0.0;
|
average = 0.0;
|
||||||
@@ -104,7 +109,7 @@ if (verbosity > 1) {
|
|||||||
average /= (double)nombre;
|
average /= (double)nombre;
|
||||||
*p_average = average;
|
*p_average = average;
|
||||||
|
|
||||||
fprintf(stderr, "\naverage %f\n", average);
|
fprintf(stderr, "\naverage of ??? is %f\n", average);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -126,18 +131,18 @@ float coef;
|
|||||||
double meanmetric;
|
double meanmetric;
|
||||||
IdxValue *idx_values; /* gni? */
|
IdxValue *idx_values; /* gni? */
|
||||||
|
|
||||||
fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n",
|
fprintf(stderr, " interpolate from '%s' to '%s' with %d steps.\n",
|
||||||
pattern, outdir, Nsteps);
|
pattern, outdir, Nsteps);
|
||||||
|
|
||||||
if (negative) fprintf(stderr, "%s: negative ON\n", __func__);
|
if (negative) fprintf(stderr, "%s: negative ON\n", __func__);
|
||||||
|
|
||||||
memset(&globbuf, 0, sizeof(glob_t));
|
memset(&globbuf, 0, sizeof(glob_t));
|
||||||
foo = glob(pattern, 0, NULL, &globbuf);
|
foo = glob(pattern, 0, NULL, &globbuf);
|
||||||
fprintf(stderr, "globbing '%s' -> %d, %d files found\n",
|
fprintf(stderr, " globbing '%s' -> %d, %d files found\n",
|
||||||
pattern, foo, (int)globbuf.gl_pathc);
|
pattern, foo, (int)globbuf.gl_pathc);
|
||||||
if (0 == globbuf.gl_pathc) {
|
if (0 == globbuf.gl_pathc) {
|
||||||
fprintf(stderr, "%s : no file found, aborting\n", __func__);
|
fprintf(stderr, "%s : no file found, ABEND\n", __func__);
|
||||||
return -1;
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
idx_values = NULL;
|
idx_values = NULL;
|
||||||
@@ -155,7 +160,7 @@ if (FIMG_TYPE_RGB != iarray[2]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w = iarray[0], h = iarray[1];
|
w = iarray[0], h = iarray[1];
|
||||||
fprintf(stderr, "first image size : %dx%d\n", w, h);
|
if (verbosity) fprintf(stderr, "first image size : %dx%d\n", w, h);
|
||||||
|
|
||||||
fimg_create(&A, w, h, 3); pFirst = &A; fimg_clear(&A);
|
fimg_create(&A, w, h, 3); pFirst = &A; fimg_clear(&A);
|
||||||
fimg_create(&B, w, h, 3); pSecond = &B; fimg_clear(&B);
|
fimg_create(&B, w, h, 3); pSecond = &B; fimg_clear(&B);
|
||||||
@@ -172,7 +177,8 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
|||||||
(int)globbuf.gl_pathc, cptr);
|
(int)globbuf.gl_pathc, cptr);
|
||||||
foo = fimg_load_from_dump(cptr, &B);
|
foo = fimg_load_from_dump(cptr, &B);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "load %s from dump -> %d\n", cptr, foo);
|
fprintf(stderr, "\n%s: load %s from dump -> %d\n", __func__,
|
||||||
|
cptr, foo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,9 +241,7 @@ puts("\t-S nn\t\tmysterious sort");
|
|||||||
puts("\t-L\t\tlist available filters");
|
puts("\t-L\t\tlist available filters");
|
||||||
puts("\t-v\t\tincrease verbosity");
|
puts("\t-v\t\tincrease verbosity");
|
||||||
|
|
||||||
if (verbosity) {
|
if (verbosity) { puts(""); fimg_print_version(2); puts(""); }
|
||||||
list_crapulors("available filters");
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -252,10 +256,11 @@ int opt;
|
|||||||
int sort = 0;
|
int sort = 0;
|
||||||
char *InFchain = "0";
|
char *InFchain = "0";
|
||||||
char *OutFchain = "0";
|
char *OutFchain = "0";
|
||||||
|
char *out_dir = "p8/";
|
||||||
|
|
||||||
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
|
fprintf(stderr, "*** %s\n\tcompiled on %s %s\n", argv[0],
|
||||||
__DATE__, __TIME__);
|
__DATE__, __TIME__);
|
||||||
fimg_print_version(2);
|
if (verbosity) fimg_print_version(2);
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
/* this is for the debug off calling shellscript */
|
/* this is for the debug off calling shellscript */
|
||||||
@@ -274,6 +279,7 @@ while ((opt = getopt(argc, argv, "E:F:hLnS:v")) != -1) {
|
|||||||
case 'S': sort = atoi(optarg); break;
|
case 'S': sort = atoi(optarg); break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'n': negative = 1; break;
|
case 'n': negative = 1; break;
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,6 +292,18 @@ if (3 != (argc-optind)) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out_dir = argv[optind+1];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check for the export directory
|
||||||
|
*/
|
||||||
|
foo = check_if_export_dir_is_valid(out_dir, 0);
|
||||||
|
if ( !foo ) {
|
||||||
|
fprintf(stderr, "** export dir (%s) not valid\n", out_dir);
|
||||||
|
fprintf(stderr, "** may be you have to create it ?\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
foo = parse_filter_chain(0, InFchain);
|
foo = parse_filter_chain(0, InFchain);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "err %d parsing '%s'\n", foo, InFchain);
|
fprintf(stderr, "err %d parsing '%s'\n", foo, InFchain);
|
||||||
@@ -302,6 +320,7 @@ if (verbosity) {
|
|||||||
fprintf(stderr, "\toutput dir '%s'\n", argv[optind+1]);
|
fprintf(stderr, "\toutput dir '%s'\n", argv[optind+1]);
|
||||||
fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
|
fprintf(stderr, "\tsrc filter '%s'\n", InFchain);
|
||||||
fprintf(stderr, "\tout filter '%s'\n", OutFchain);
|
fprintf(stderr, "\tout filter '%s'\n", OutFchain);
|
||||||
|
fprintf(stderr, "\tsort %d\n", sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity > 1) {
|
if (verbosity > 1) {
|
||||||
|
|||||||
@@ -21,6 +21,52 @@
|
|||||||
*/
|
*/
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* new Sun Mar 31 22:31:31 UTC 2024 */
|
||||||
|
|
||||||
|
int add_a_border_0(FloatImg *src, FloatImg *dst)
|
||||||
|
{
|
||||||
|
|
||||||
|
fprintf(stderr, "****** %s:%s to be implemented\n", __FILE__, __func__);
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* nouveau Sun Jul 16 07:37:22 UTC 2023
|
||||||
|
*
|
||||||
|
* may-be this can be an on-place function ?
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int poke_sup_rb_g(FloatImg *src, FloatImg *dst)
|
||||||
|
{
|
||||||
|
int idx, nbpix, foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( (foo=fimg_images_not_compatible(src, dst)) )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: no compat %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbpix = src->width * src->height;
|
||||||
|
if (verbosity > 1)
|
||||||
|
fprintf(stderr, "%s work on %d pixels\n", __func__, nbpix);
|
||||||
|
|
||||||
|
for (idx=0; idx<nbpix; idx++) {
|
||||||
|
dst->R[idx] = src->R[idx];
|
||||||
|
dst->B[idx] = src->B[idx];
|
||||||
|
if (src->R[idx] < src->B[idx])
|
||||||
|
dst->G[idx] = src->R[idx];
|
||||||
|
else
|
||||||
|
dst->G[idx] = src->B[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
/* nouveau 14 mai 2022 rue Ernest Renan */
|
/* nouveau 14 mai 2022 rue Ernest Renan */
|
||||||
|
|
||||||
@@ -91,6 +137,9 @@ static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals)
|
|||||||
int x, y, pline, off;
|
int x, y, pline, off;
|
||||||
int ym;
|
int ym;
|
||||||
|
|
||||||
|
// fprintf(stderr, ">>> %s ( %p %d,%d,%d,%d )\n", __func__, pimg,
|
||||||
|
// pos[0], pos[1], pos[2], pos[3]);
|
||||||
|
|
||||||
fimg_clear_rectangle(pimg, pos);
|
fimg_clear_rectangle(pimg, pos);
|
||||||
|
|
||||||
ym = pos[1]+pos[3]-1;
|
ym = pos[1]+pos[3]-1;
|
||||||
@@ -101,6 +150,7 @@ for (y=pos[1]; y<ym; y++) {
|
|||||||
pline = y*pimg->width;
|
pline = y*pimg->width;
|
||||||
for (x=0; x<5; x++) {
|
for (x=0; x<5; x++) {
|
||||||
off = pline + (x+pos[0]);
|
off = pline + (x+pos[0]);
|
||||||
|
|
||||||
/* wtf i'm doing here ? */
|
/* wtf i'm doing here ? */
|
||||||
if ( (pos[1]==y) || (ym-1==y) ) {
|
if ( (pos[1]==y) || (ym-1==y) ) {
|
||||||
pimg->R[off] = fvals[0] * FDIM;
|
pimg->R[off] = fvals[0] * FDIM;
|
||||||
@@ -129,20 +179,36 @@ float vals[3];
|
|||||||
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STP 16 /* stepd for x & y axex */
|
/* XXX CRITICAL BUG XXX
|
||||||
|
*
|
||||||
|
* what to do if STP is not a modulo of
|
||||||
|
* the width (or size) of the picture ?
|
||||||
|
* why if img height is 600 and stp was 16 ?
|
||||||
|
|
||||||
|
tth@redlady:~/Devel/FloatImg/Fonderie$ bc -l
|
||||||
|
600/16
|
||||||
|
37.50000000000000000000
|
||||||
|
|
||||||
|
*
|
||||||
|
* And this mistake is all around the code /o\
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define STP 15 /* stepd for x & y axex */
|
||||||
coo[2] = coo[3] = STP;
|
coo[2] = coo[3] = STP;
|
||||||
|
|
||||||
for (y=0; y<pimg->height; y+=STP) {
|
for (y=0; y < pimg->height-STP; y+=STP) {
|
||||||
coo[1] = y;
|
coo[1] = y;
|
||||||
for (x=0; x<pimg->width; x+=STP) {
|
for (x=0; x < pimg->width-STP; x+=STP) {
|
||||||
coo[0] = x;
|
coo[0] = x;
|
||||||
foo = stat_zone(pimg, coo, vals);
|
foo = stat_zone(pimg, coo, vals);
|
||||||
if (foo) abort();
|
if (foo) abort();
|
||||||
/* next step : plot the datas */
|
|
||||||
pixel_trinitron(pimg, coo, vals);
|
pixel_trinitron(pimg, coo, vals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef STP
|
#undef STP
|
||||||
|
|
||||||
|
// fprintf(stderr, " end trinitron\n"); // XXX
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
@@ -374,8 +440,9 @@ int des_bords_sombres_b(FloatImg *pimg, int nbre)
|
|||||||
{
|
{
|
||||||
int idx, x, foo;
|
int idx, x, foo;
|
||||||
float coef, *fptr;
|
float coef, *fptr;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, offset);
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, nbre);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (idx=0; idx<nbre; idx++) {
|
for (idx=0; idx<nbre; idx++) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ int graylevel2popcolors(FloatImg *src, FloatImg *dst, int k);
|
|||||||
|
|
||||||
int incrustation_vignette(FloatImg *src, FloatImg *dst, int k);
|
int incrustation_vignette(FloatImg *src, FloatImg *dst, int k);
|
||||||
|
|
||||||
|
int poke_sup_rb_g(FloatImg *src, FloatImg *dst);
|
||||||
|
|
||||||
int trinitron(FloatImg *pimg, int notused);
|
int trinitron(FloatImg *pimg, int notused);
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ if (foo) {
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
if (S_IFDIR != (stbuf.st_mode & S_IFMT)) {
|
if (S_IFDIR != (stbuf.st_mode & S_IFMT)) {
|
||||||
fprintf(stderr, "! %s must be a directory\n", dest);
|
fprintf(stderr, "%s: %s must be a directory\n", __func__, dest);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
#include "crapulator.h"
|
#include "crapulator.h"
|
||||||
#include "filterstack.h"
|
#include "filterstack.h"
|
||||||
#include "single.h"
|
#include "single.h"
|
||||||
@@ -25,6 +26,9 @@
|
|||||||
int verbosity;
|
int verbosity;
|
||||||
|
|
||||||
/* ----------------------------------------------------------- */
|
/* ----------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* parameter 'duplic' is the repetition factor
|
||||||
|
*/
|
||||||
int run_the_singlepass(char *globber, char *destdir, int duplic,
|
int run_the_singlepass(char *globber, char *destdir, int duplic,
|
||||||
int fchain, int outfmt)
|
int fchain, int outfmt)
|
||||||
{
|
{
|
||||||
@@ -35,11 +39,11 @@ char *fname;
|
|||||||
double elapsed;
|
double elapsed;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' '%s' %d %d )\n", __func__,
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d %d %d )\n", __func__,
|
||||||
globber, destdir, fchain, outfmt);
|
globber, destdir, duplic, fchain, outfmt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// filterstack_list(fchain, "Run the single pass");
|
if (verbosity) filterstack_list(fchain, "Run the single pass");
|
||||||
|
|
||||||
(void)fimg_timer_set(0);
|
(void)fimg_timer_set(0);
|
||||||
|
|
||||||
@@ -81,17 +85,21 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
|||||||
else {
|
else {
|
||||||
foo = fimg_load_from_dump(fname, &image);
|
foo = fimg_load_from_dump(fname, &image);
|
||||||
}
|
}
|
||||||
|
if (verbosity > 1) {
|
||||||
|
fprintf(stderr, "%s: image '%s' loaded in %p\n",
|
||||||
|
__func__, fname, &image);
|
||||||
|
}
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "get image -> %d\n", foo);
|
fprintf(stderr, "get image -> %d\n", foo);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == idx) {
|
if (0==idx && verbosity) {
|
||||||
fprintf(stderr, "image size %dx%d\n",
|
fprintf(stderr, "\tfirst image size %dx%d\n",
|
||||||
image.width, image.height);
|
image.width, image.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, " %6ld %s\r", (long)globbuf.gl_pathc-idx, fname);
|
// fprintf(stderr, " %6ld %s\r", (long)globbuf.gl_pathc-idx, fname);
|
||||||
|
|
||||||
foo = filterstack_run(fchain, &image, 0);
|
foo = filterstack_run(fchain, &image, 0);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
@@ -107,10 +115,6 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
|
|||||||
fprintf(stderr, "error %d on push_picture\n", foo);
|
fprintf(stderr, "error %d on push_picture\n", foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
if (loop) {
|
|
||||||
/* this is just a wip XXX */
|
|
||||||
microglitch(&image, loop);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +123,7 @@ fprintf(stderr, "\n");
|
|||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
|
|
||||||
fimg_destroy(&image);
|
fimg_destroy(&image);
|
||||||
single_print_state("end of run", 0);
|
// single_print_state("end of run", 0);
|
||||||
|
|
||||||
elapsed = fimg_timer_get(0);
|
elapsed = fimg_timer_get(0);
|
||||||
fprintf(stderr, "%s: %ld frames, elapsed %.3f s, %.3f fps\n",
|
fprintf(stderr, "%s: %ld frames, elapsed %.3f s, %.3f fps\n",
|
||||||
@@ -156,9 +160,9 @@ char *outdir = "./p8";
|
|||||||
int do_xper = 0;
|
int do_xper = 0;
|
||||||
int repeat = 1;
|
int repeat = 1;
|
||||||
|
|
||||||
fprintf(stderr, "*** %s : compiled %s %s\n", __FILE__,
|
fprintf(stderr, "*** %s\n\tcompiled %s %s\n", argv[0],
|
||||||
__DATE__, __TIME__);
|
__DATE__, __TIME__);
|
||||||
fimg_print_version(2);
|
if (verbosity) fimg_print_version(2);
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "\t/!\\ %s is option driven\n", argv[0]);
|
fprintf(stderr, "\t/!\\ %s is option driven\n", argv[0]);
|
||||||
@@ -188,7 +192,6 @@ while ((opt = getopt(argc, argv, "hF:g:LO:r:svx")) != -1) {
|
|||||||
fprintf(stderr, "%s ABEND\n", argv[0]);
|
fprintf(stderr, "%s ABEND\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repeat < 1) {
|
if (repeat < 1) {
|
||||||
@@ -196,6 +199,13 @@ if (repeat < 1) {
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foo = check_if_export_dir_is_valid(outdir, 0);
|
||||||
|
if ( !foo ) {
|
||||||
|
fprintf(stderr, "** export dir (%s) not valid\n", outdir);
|
||||||
|
fprintf(stderr, "** may be you have to create it ?\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
foo = parse_filter_chain(FILTERS, filterchain);
|
foo = parse_filter_chain(FILTERS, filterchain);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
||||||
@@ -212,9 +222,12 @@ if (verbosity) {
|
|||||||
fprintf(stderr, "\tdo xper %d\n", do_xper);
|
fprintf(stderr, "\tdo xper %d\n", do_xper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REAL action here
|
||||||
|
*/
|
||||||
foo = run_the_singlepass(globbing, outdir, repeat,
|
foo = run_the_singlepass(globbing, outdir, repeat,
|
||||||
FILTERS, FILE_TYPE_PNG);
|
FILTERS, FILE_TYPE_PNG);
|
||||||
fprintf(stderr, "\n\tRun the single pass --> %d\n", foo);
|
fprintf(stderr, "\tRun the single pass --> %d\n", foo);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
57
Fonderie/t.c
57
Fonderie/t.c
@@ -16,6 +16,8 @@
|
|||||||
#include "crapulator.h"
|
#include "crapulator.h"
|
||||||
#include "single.h"
|
#include "single.h"
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
|
|
||||||
/* ----------------------------------------------------------- */
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
int verbosity;
|
int verbosity;
|
||||||
@@ -28,6 +30,30 @@ int verbosity;
|
|||||||
|
|
||||||
#define STK 6
|
#define STK 6
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------- */
|
||||||
|
/* new Sat Nov 9 22:17:46 UTC 2024 */
|
||||||
|
int essai_test_export_dir(char *footxt)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, footxt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = check_if_export_dir_is_valid("/tmp/quux", 0);
|
||||||
|
fprintf(stderr, " got %d\n\n", foo);
|
||||||
|
|
||||||
|
foo = check_if_export_dir_is_valid("/home", 0);
|
||||||
|
fprintf(stderr, " got %d\n\n", foo);
|
||||||
|
|
||||||
|
foo = check_if_export_dir_is_valid("./", 0);
|
||||||
|
fprintf(stderr, " got %d\n\n", foo);
|
||||||
|
|
||||||
|
foo = check_if_export_dir_is_valid("Makefile", 0);
|
||||||
|
fprintf(stderr, " got %d\n\n", foo);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
/* ----------------------------------------------------------- */
|
/* ----------------------------------------------------------- */
|
||||||
|
|
||||||
int essai_filterstack(char *fIname, char *fOname)
|
int essai_filterstack(char *fIname, char *fOname)
|
||||||
@@ -36,11 +62,16 @@ int foo;
|
|||||||
FloatImg image;
|
FloatImg image;
|
||||||
double debut, fin;
|
double debut, fin;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, fIname, fOname);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// filterstack_list(STK, __func__);
|
// filterstack_list(STK, __func__);
|
||||||
|
|
||||||
foo = fimg_create_from_dump(fIname, &image);
|
foo = fimg_create_from_dump(fIname, &image);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "err %d create image\n", foo);
|
fprintf(stderr, "%s: err %d create from dump\n", __func__, foo);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,8 +104,6 @@ return 0;
|
|||||||
|
|
||||||
foo = essayer_single("capture/???42.fimg", "/tmp/x8/", STK);
|
foo = essayer_single("capture/???42.fimg", "/tmp/x8/", STK);
|
||||||
fprintf(stderr, "essayer single -> %d\n", foo);
|
fprintf(stderr, "essayer single -> %d\n", foo);
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
int essayer_single(char *globpattern, char *destdir, int chain)
|
int essayer_single(char *globpattern, char *destdir, int chain)
|
||||||
{
|
{
|
||||||
@@ -161,14 +190,14 @@ puts("\t-s\tdo single test");
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* ----------------------------------------------------------- */
|
/* ----------------------------------------------------------- */
|
||||||
int experiment(void)
|
int experiment(char *fname)
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
FloatImg image, dest;
|
FloatImg image, dest;
|
||||||
|
|
||||||
fprintf(stderr, "--------- EXPERIMENT ------------\n");
|
fprintf(stderr, "----- EXPERIMENT on '%s' -----\n", fname);
|
||||||
|
|
||||||
foo = fimg_create_from_dump("mire.fimg", &image);
|
foo = fimg_create_from_dump(fname, &image);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: err %d on create_from_dump\n",
|
fprintf(stderr, "%s: err %d on create_from_dump\n",
|
||||||
__func__, foo);
|
__func__, foo);
|
||||||
@@ -177,8 +206,8 @@ if (foo) {
|
|||||||
|
|
||||||
foo = fimg_clone(&image, &dest, 0);
|
foo = fimg_clone(&image, &dest, 0);
|
||||||
|
|
||||||
foo = graylevel2popcolors(&image, &dest, 0);
|
foo = poke_sup_rb_g(&image, &dest);
|
||||||
fprintf(stderr, "POP COLOR- -> %d\n", foo);
|
fprintf(stderr, "poke sup rb g --> %d\n", foo);
|
||||||
|
|
||||||
fimg_export_picture(&dest, "foo.png", 0);
|
fimg_export_picture(&dest, "foo.png", 0);
|
||||||
|
|
||||||
@@ -220,17 +249,25 @@ while ((opt = getopt(argc, argv, "hF:g:i:Lo:O:svx")) != -1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "%s : argc = %d, optind = %d\n", argv[0], argc, optind);
|
fprintf(stderr, ">>> %s : argc=%d, optind=%d\n", argv[0], argc, optind);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
foo = essai_test_export_dir("bla bla");
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d in essai_test_export_dir\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
|
||||||
foo = parse_filter_chain(STK, filterchain);
|
foo = parse_filter_chain(STK, filterchain);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (do_xper) {
|
if (do_xper) {
|
||||||
experiment();
|
experiment(infile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (do_single) {
|
if (do_single) {
|
||||||
|
|||||||
53
Fonderie/utilfuncs.c
Normal file
53
Fonderie/utilfuncs.c
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* utilfuncs.c
|
||||||
|
*
|
||||||
|
* new Sat Nov 9 22:15:15 UTC 2024
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "utilfuncs.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
int check_if_export_dir_is_valid(char *path, int action)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s', %d )\n", __func__, path, action);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = stat(path, &statbuf);
|
||||||
|
if (foo) {
|
||||||
|
if (verbosity) perror(path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, " mode 0x%x\n", statbuf.st_mode);
|
||||||
|
#endif
|
||||||
|
if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
|
||||||
|
if (verbosity) fprintf(stderr, "%s: Not a directory\n", path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* OK, c'est un repertoire, mais peut-on écrire dedans ? */
|
||||||
|
foo = access(path, W_OK);
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, " access '%s' = %d\n", path, foo);
|
||||||
|
#endif
|
||||||
|
if (0 != foo) {
|
||||||
|
if (verbosity) fprintf(stderr, "%s: can't write\n", path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1; /* export dir is OK */
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
11
Fonderie/utilfuncs.h
Normal file
11
Fonderie/utilfuncs.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* utilfuncs.c
|
||||||
|
*
|
||||||
|
* new Sat Nov 9 22:15:49 UTC 2024
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int check_if_export_dir_is_valid(char *path, int action);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
33
README.md
33
README.md
@@ -7,7 +7,6 @@ voire même des [films flous](Fonderie/).
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
Il y a une [description](http://la.buvette.org/photos/cumul/) bien plus
|
Il y a une [description](http://la.buvette.org/photos/cumul/) bien plus
|
||||||
pas trop longue pour les curieux, et un début de
|
pas trop longue pour les curieux, et un début de
|
||||||
[documentation](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
|
[documentation](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
|
||||||
@@ -22,7 +21,20 @@ Par ailleurs, d'autres expérimentations sont
|
|||||||
sur le traitement et l'assemblage de ces images floues dans le but de faire
|
sur le traitement et l'assemblage de ces images floues dans le but de faire
|
||||||
des films flous.
|
des films flous.
|
||||||
|
|
||||||
*En avant vers l'infini, et au-delà...*
|
## *Show us the code !*
|
||||||
|
|
||||||
|
Il y a plusieurs répertoires contenant le code source, en voici
|
||||||
|
la liste :
|
||||||
|
|
||||||
|
* [lib](lib/README.md) : le noyau du système, fonctions de base.
|
||||||
|
* [funcs](funcs/README.md) : fonctions de support : export, traitement
|
||||||
|
filtrage, effets...
|
||||||
|
* [tools](tools/README.md) : utilitaires divers, outils de debug et gadgets.
|
||||||
|
* [v4l2](v4l2/README.md): gestion des webcams sous Linux.
|
||||||
|
* [experiment](experiment/README.md) : fonctions en chantier, qui migreront
|
||||||
|
un jour dans d'autres catégories.
|
||||||
|
* [contrib](contrib/README.md) : des choses peu ou pas maintenues.
|
||||||
|
|
||||||
|
|
||||||
## Dépendances
|
## Dépendances
|
||||||
|
|
||||||
@@ -37,16 +49,15 @@ apt install liblo-dev
|
|||||||
apt install libv4l2-dev
|
apt install libv4l2-dev
|
||||||
apt install libcfitsio-dev
|
apt install libcfitsio-dev
|
||||||
apt install libnetpbm-dev
|
apt install libnetpbm-dev
|
||||||
|
apt install libncurses-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Bon, OK, je suis en train de changer de machine, et ça serait vraiment
|
Bon, OK, je suis en train de changer de machine, et ça serait vraiment
|
||||||
cool d'avoir juste une ligne à c'n'p, donc voila :
|
cool d'avoir juste une ligne à c'n'p, donc voila :
|
||||||
|
|
||||||
```
|
```
|
||||||
apt install libtiff-dev libpnglite-dev liblo-dev libv4l2-dev \
|
apt install libtiff-dev libpnglite-dev liblo-dev libv4l2-dev \
|
||||||
libcfitsio-dev libnetpbm-dev
|
libcfitsio-dev libnetpbm-dev libncurses-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Il est probable que j'en oublie.
|
Il est probable que j'en oublie.
|
||||||
Et ya Debian qui change des trucs, alors, ça marche plus, du
|
Et ya Debian qui change des trucs, alors, ça marche plus, du
|
||||||
genre que c'est la deuxième fois que ça m'arrive.
|
genre que c'est la deuxième fois que ça m'arrive.
|
||||||
@@ -63,9 +74,9 @@ coté de pkg-config.
|
|||||||
|
|
||||||
Certains outils externes sont aussi utiles :
|
Certains outils externes sont aussi utiles :
|
||||||
|
|
||||||
- gnuplot
|
- gnuplot, pour analyser des données,
|
||||||
- ImageMagick
|
- ImageMagick, parce que Brunus aime ça,
|
||||||
- LaTeX
|
- LaTeX, pour la (trop maigre) documentation.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@@ -73,4 +84,10 @@ Encore trop légère, mais déja [présente](doc/).
|
|||||||
C'est à vous de compiler le
|
C'est à vous de compiler le
|
||||||
[PDF](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
|
[PDF](http://la.buvette.org/photos/cumul/the_floatimg_hack.pdf)
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
https://berthub.eu/articles/posts/always-do-this-floating-point/
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
*Your mileage may vary...*
|
*Your mileage may vary...*
|
||||||
|
|||||||
8
build.sh
8
build.sh
@@ -1,10 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e ; set -u
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
function build
|
function build
|
||||||
{
|
{
|
||||||
echo ============= $1 ==============
|
echo "============= $1 =============="
|
||||||
curdir=${PWD}
|
curdir=${PWD}
|
||||||
cd $1
|
cd $1
|
||||||
make
|
make
|
||||||
@@ -13,7 +15,7 @@ cd ${curdir}
|
|||||||
|
|
||||||
if [ ${error} -ne 0 ]
|
if [ ${error} -ne 0 ]
|
||||||
then
|
then
|
||||||
echo === error on $1 = ${error}
|
echo "=== error on $1 = ${error}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -28,7 +30,7 @@ build Fonderie
|
|||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
|
echo "========== Project root ==============="
|
||||||
make
|
make
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
14
contrib/.gitignore
vendored
Normal file
14
contrib/.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
fimg2povhf
|
||||||
|
demo_fmorph
|
||||||
|
|
||||||
|
toto
|
||||||
|
core
|
||||||
|
|
||||||
|
*.tga
|
||||||
|
*.png
|
||||||
|
*.pnm
|
||||||
|
*.gif
|
||||||
|
*.fimg
|
||||||
|
*.mp4
|
||||||
|
|
||||||
@@ -1,7 +1,18 @@
|
|||||||
|
|
||||||
DBGL = '-DDEBUG_LEVEL=1 -g '
|
DBGL = -DDEBUG_LEVEL=1 -g
|
||||||
|
|
||||||
fimg2povhf: fimg2povhf.c Makefile
|
fimg2povhf: fimg2povhf.c Makefile
|
||||||
gcc -Wall $(DBGL) $< -limage -lfloatimg -lm -o $@
|
gcc -Wall $(DBGL) $< -limage -lfloatimg -lm -o $@
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
|
|
||||||
|
demo_fmorph: demo_fmorph.c Makefile
|
||||||
|
gcc -Wall $(DBGL) $< -lfloatimg -lpnglite -lm -o $@
|
||||||
|
|
||||||
|
in.fimg: Makefile
|
||||||
|
mkfimg -t tpat0 -v $@ 640 480
|
||||||
|
|
||||||
|
out.png: in.fimg demo_fmorph
|
||||||
|
./demo_fmorph $< $@
|
||||||
|
|
||||||
|
# --------------------------------------------------------
|
||||||
@@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
Need some external garbage, sorry.
|
Need some external garbage, sorry.
|
||||||
|
|
||||||
Try to compile this really old code:
|
## do_eff_spass.sh
|
||||||
http://la.buvette.org/devel/libimage/libimage.html
|
|
||||||
|
Script shell permettant (en théorie) de faire un montage
|
||||||
|
d'une petite séquence de chacun des effets disponibles
|
||||||
|
dans la Fonderie. `singlepass` inside.
|
||||||
|
|
||||||
Use the code, frtk !
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
116
contrib/demo_fmorph.c
Normal file
116
contrib/demo_fmorph.c
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* DEMONSTRATOR FOR FMORPHO
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <floatimg.h>
|
||||||
|
|
||||||
|
int verbosity = 1;
|
||||||
|
|
||||||
|
#define DF_W 512
|
||||||
|
#define DF_H 128
|
||||||
|
|
||||||
|
/* ~~~ -------------------------------------------------------------- +++ */
|
||||||
|
int demo_fmorph(char *srcf, char *dsti, int mode)
|
||||||
|
{
|
||||||
|
FloatImg simg, // image source
|
||||||
|
timg, uimg, // intermediaires
|
||||||
|
dimg; // destination
|
||||||
|
FimgArea51 rect;
|
||||||
|
char line[200];
|
||||||
|
|
||||||
|
int foo, pass, hpos;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, srcf, dsti, mode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* chargement image source
|
||||||
|
*/
|
||||||
|
foo = fimg_create_from_dump(srcf, &simg);
|
||||||
|
fprintf(stderr, " load of %s --> %d\n", srcf, foo);
|
||||||
|
if (foo) {
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* images temporaires
|
||||||
|
*/
|
||||||
|
foo = fimg_create(&timg, DF_W, DF_H, FIMG_TYPE_RGB);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d create T img\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
foo = fimg_create(&uimg, DF_W, DF_H, FIMG_TYPE_RGB);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d create U img\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* image de destination
|
||||||
|
*/
|
||||||
|
foo = fimg_create(&dimg, DF_W, DF_H*9, FIMG_TYPE_RGB);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d create D img\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this is an iterator
|
||||||
|
*/
|
||||||
|
rect.x = 20; rect.y = 20;
|
||||||
|
rect.w = DF_W; rect.h = DF_H;
|
||||||
|
|
||||||
|
for (pass=0; pass<9; pass++) {
|
||||||
|
hpos = pass * DF_H;
|
||||||
|
fprintf(stderr, "pass %d, hpos %d\n", pass, hpos);
|
||||||
|
foo = fimg_extractor(&simg, &timg, &rect);
|
||||||
|
|
||||||
|
// sprintf(line, "S_%02d.png", pass);
|
||||||
|
// foo = fimg_save_as_png(&timg, line, 0);
|
||||||
|
|
||||||
|
foo = fimg_filtre_morpho_0(&timg, &uimg, pass);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d filtre morpho, pass %d\n",
|
||||||
|
foo, pass);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sprintf(line, "D_%02d.png", pass);
|
||||||
|
foo = fimg_save_as_png(&uimg, line, 0);
|
||||||
|
|
||||||
|
foo = fimg_incrustator_0(&uimg, &dimg, 0, hpos, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d incrustator\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_save_as_png(&dimg, dsti, 0);
|
||||||
|
/*
|
||||||
|
* do some cleanup
|
||||||
|
*/
|
||||||
|
fimg_destroy(&simg); fimg_destroy(&timg); fimg_destroy(&dimg);
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ~~~ -------------------------------------------------------------- +++ */
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
fimg_print_version(1);
|
||||||
|
|
||||||
|
if (3 != argc) {
|
||||||
|
fprintf(stderr, "usage:\n\t%s src.fimg dst.png\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = demo_fmorph(argv[1], argv[2], 0);
|
||||||
|
fprintf(stderr, " got --> %d\n", foo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ~~~ -------------------------------------------------------------- +++ */
|
||||||
163
contrib/do_eff_spass.sh
Executable file
163
contrib/do_eff_spass.sh
Executable file
@@ -0,0 +1,163 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SPASS="../Fonderie/singlepass"
|
||||||
|
|
||||||
|
SRCDIR=$HOME"/Essais/PS-eye/frames/"
|
||||||
|
DSTPOL=$HOME"/TMP/"
|
||||||
|
echo "source = " $SRCDIR
|
||||||
|
echo "spool = " $DSTPOL
|
||||||
|
|
||||||
|
LINKFARM=$DSTPOL"LinkFarm"
|
||||||
|
echo "linkfarm = " $LINKFARM
|
||||||
|
|
||||||
|
# VIDZ="$HOME/BU/vrac/all_effects.mp4"
|
||||||
|
VIDZ="foo.mp4"
|
||||||
|
echo "lolvidz = " $VIDZ
|
||||||
|
|
||||||
|
LINKNUM=0
|
||||||
|
|
||||||
|
# --------------------------------------------
|
||||||
|
|
||||||
|
do_an_effect_pass()
|
||||||
|
{
|
||||||
|
local effect=$1
|
||||||
|
local ddir=$2
|
||||||
|
|
||||||
|
figlet "$effect" ; echo
|
||||||
|
echo " files to ===> " $ddir
|
||||||
|
|
||||||
|
rm -f $ddir/?????.png
|
||||||
|
|
||||||
|
$SPASS -F $effect \
|
||||||
|
-g $SRCDIR/'?????.fimg' \
|
||||||
|
-O $ddir \
|
||||||
|
-r 1
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# --------------------------------------------
|
||||||
|
insert_blank()
|
||||||
|
{
|
||||||
|
local count=$1
|
||||||
|
|
||||||
|
local imgname="$DSTPOL/blank.fimg"
|
||||||
|
|
||||||
|
if [ ! -r $imgname ] ; then
|
||||||
|
mkfimg -v -t black $imgname 640 480
|
||||||
|
fimg2png -v $imgname $DSTPOL/blank.png
|
||||||
|
echo "blankimage done" | boxes
|
||||||
|
# display $DSTPOL/blank.png &
|
||||||
|
# exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
for foo in $(seq 0 $count)
|
||||||
|
do
|
||||||
|
linkname=$(printf "%s/L%05d.png" $LINKFARM $LINKNUM)
|
||||||
|
ln --force --symbolic $DSTPOL/blank.png $linkname
|
||||||
|
# file $linkname
|
||||||
|
LINKNUM=$(( LINKNUM + 1 ))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
# --------------------------------------------
|
||||||
|
|
||||||
|
make_the_linkfarm_from()
|
||||||
|
{
|
||||||
|
local effname=$1
|
||||||
|
local sdir=$2
|
||||||
|
|
||||||
|
echo "====== Linkfarming from " $sdir \
|
||||||
|
"====== avec" $(ls $sdir | wc -l) "images"
|
||||||
|
|
||||||
|
mogrify \
|
||||||
|
-font Utopia-Bold \
|
||||||
|
-pointsize 64 \
|
||||||
|
-kerning 9 \
|
||||||
|
-fill Gray90 \
|
||||||
|
-stroke Gray10 \
|
||||||
|
-strokewidth 2 \
|
||||||
|
-gravity South-East \
|
||||||
|
-annotate +30+20 $effname \
|
||||||
|
$sdir/*.png
|
||||||
|
|
||||||
|
for img in $(ls -1 $sdir/?????.png)
|
||||||
|
do
|
||||||
|
|
||||||
|
linkname=$(printf "%s/L%05d.png" $LINKFARM $LINKNUM)
|
||||||
|
# echo "image = " $img
|
||||||
|
# echo "link = " $linkname
|
||||||
|
|
||||||
|
ln --force --symbolic $img $linkname
|
||||||
|
|
||||||
|
LINKNUM=$(( LINKNUM + 1 ))
|
||||||
|
done
|
||||||
|
echo " linkfarming done"
|
||||||
|
}
|
||||||
|
# --------------------------------------------
|
||||||
|
# traite tous les effets
|
||||||
|
|
||||||
|
do_all_the_effects()
|
||||||
|
{
|
||||||
|
EFFECTS=$( $SPASS -L | sort )
|
||||||
|
|
||||||
|
banner 'FULL RUN'
|
||||||
|
|
||||||
|
for effect in $EFFECTS
|
||||||
|
do
|
||||||
|
DDIR=$DSTPOL"/$effect"
|
||||||
|
|
||||||
|
if [ -d $DDIR ] ; then
|
||||||
|
rm -f $DDIR"/?????.png"
|
||||||
|
fi
|
||||||
|
if [ ! -r $DDIR ] ; then
|
||||||
|
mkdir -v $DDIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
do_an_effect_pass $effect $DDIR
|
||||||
|
make_the_linkfarm_from $effect $DDIR
|
||||||
|
|
||||||
|
insert_blank 30
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# --------------------------------------------
|
||||||
|
|
||||||
|
debug_run()
|
||||||
|
{
|
||||||
|
local eff=$1
|
||||||
|
local DDIR=$DSTPOL"/$eff"
|
||||||
|
|
||||||
|
banner 'DEBUG RUN'
|
||||||
|
echo "DDIR = " $DDIR
|
||||||
|
|
||||||
|
do_an_effect_pass $eff $DDIR
|
||||||
|
make_the_linkfarm_from $eff $DDIR
|
||||||
|
}
|
||||||
|
|
||||||
|
# --------------------------------------------
|
||||||
|
# MAIN
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
rm -v -f $LINKFARM/L*.png ; echo
|
||||||
|
|
||||||
|
insert_blank 30
|
||||||
|
|
||||||
|
# debug_run 'rndblks'
|
||||||
|
do_all_the_effects
|
||||||
|
|
||||||
|
banner 'encoding'
|
||||||
|
|
||||||
|
ffmpeg -nostdin \
|
||||||
|
-loglevel warning \
|
||||||
|
-y -r 30 -f image2 -i ${LINKFARM}/L%05d.png \
|
||||||
|
-metadata artist='---[ tTh ]---' \
|
||||||
|
-metadata title='---[ All the 'Fonderie' effects ]---' \
|
||||||
|
-preset veryslow \
|
||||||
|
-c:v libx264 -pix_fmt yuv420p \
|
||||||
|
$VIDZ
|
||||||
|
|
||||||
|
echo " encoding of " $VIDZ " . . . . . [done]"
|
||||||
|
|
||||||
|
|
||||||
@@ -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=0.1em,belowskip=0.1em}
|
\lstset{aboveskip=0.01em,belowskip=0.1em}
|
||||||
|
|
||||||
\usepackage{babel} % ?
|
\usepackage{babel} % ?
|
||||||
|
|
||||||
@@ -25,8 +25,10 @@
|
|||||||
% \usepackage{url}
|
% \usepackage{url}
|
||||||
\usepackage{xspace}
|
\usepackage{xspace}
|
||||||
\usepackage[verbose]{layout}
|
\usepackage[verbose]{layout}
|
||||||
|
\usepackage{ulem}
|
||||||
|
|
||||||
\setlength \parskip {0.35em}
|
\setlength \parskip {0.18em}
|
||||||
|
\setcounter{tocdepth}{2} % XXX à regarder un de ces jours ?
|
||||||
|
|
||||||
\makeatletter
|
\makeatletter
|
||||||
% explication de ce truc ?
|
% explication de ce truc ?
|
||||||
@@ -41,7 +43,7 @@
|
|||||||
\makeindex
|
\makeindex
|
||||||
|
|
||||||
% ------ a few new commands
|
% ------ a few new commands
|
||||||
\newcommand{\interparagraphe { \vspace{60pt} } }
|
\newcommand{\interparagraphe { \vspace{50pt} } }
|
||||||
|
|
||||||
% -------------------------------------------------------------------
|
% -------------------------------------------------------------------
|
||||||
\title{Floating images processing (for fun and profit ?)}
|
\title{Floating images processing (for fun and profit ?)}
|
||||||
@@ -52,9 +54,9 @@
|
|||||||
|
|
||||||
\section*{Une image flottante ?}
|
\section*{Une image flottante ?}
|
||||||
|
|
||||||
|
\vspace{2em}
|
||||||
\textsl{Mais de quoi parle-t-on exactement ?}
|
\textsl{Mais de quoi parle-t-on exactement ?}
|
||||||
|
\vspace{2em}
|
||||||
% XXX XXX XXX\vspace{1em}
|
|
||||||
|
|
||||||
Traditionnellement, les valeurs des pixels dans les images
|
Traditionnellement, les valeurs des pixels dans les images
|
||||||
informatiques sont mémorisées sur 8 bits, un octet\index{octet},
|
informatiques sont mémorisées sur 8 bits, un octet\index{octet},
|
||||||
@@ -77,7 +79,13 @@ pour ceux qui suivent le canal \texttt{\#tetalab} sur le réseau
|
|||||||
IRC de \textsl{libera.chat}.
|
IRC de \textsl{libera.chat}.
|
||||||
|
|
||||||
\textbf{Attention !} ce document commence par une bonne rafale
|
\textbf{Attention !} ce document commence par une bonne rafale
|
||||||
de technique parfois \textsl{hardue}, avec des pointeurs dedans.
|
de technique parfois \textsl{hardue}\footnote{hard + ardue = private
|
||||||
|
joke Usenet}, avec des pointeurs dedans, mais vous êtes déja
|
||||||
|
au courant.
|
||||||
|
Le pointeur, c'est bien, c'est comme le doigt sur les écrans
|
||||||
|
de zombiephones, ça sert juste à dire «~C'est là !~», c'est
|
||||||
|
donc gravement utile, mais parfois, le doigt glisse.
|
||||||
|
Et là, tout peut arriver.
|
||||||
Vous avez parfaitement le droit de sauter directement à
|
Vous avez parfaitement le droit de sauter directement à
|
||||||
la page \pageref{outils} pour quelque chose de plus concret.
|
la page \pageref{outils} pour quelque chose de plus concret.
|
||||||
|
|
||||||
@@ -92,7 +100,7 @@ certains points. Je vais tenter de répondre à ces FAQ~:%
|
|||||||
« Fréquentes et Absurdes Questions » avec des réponses
|
« Fréquentes et Absurdes Questions » avec des réponses
|
||||||
absurdes et précises.
|
absurdes et précises.
|
||||||
|
|
||||||
\subsubsection*{c'est quoi un image d'un point de vue physique ?}
|
\subsubsection*{c'est quoi une image d'un point de vue physique ?}
|
||||||
|
|
||||||
Une représentation approximative d'un monde physique invisible.
|
Une représentation approximative d'un monde physique invisible.
|
||||||
L'infinie bio-complexité de notre système oculaire et ses interactions
|
L'infinie bio-complexité de notre système oculaire et ses interactions
|
||||||
@@ -102,8 +110,9 @@ numériques quand certains ont songé à passer du flou mental à la grille
|
|||||||
physique.
|
physique.
|
||||||
|
|
||||||
Les détails techniques sur cette représentation sont en page
|
Les détails techniques sur cette représentation sont en page
|
||||||
\pageref{FloatImg desc}, avec des pointeurs dedans.
|
\pageref{FloatImg desc}, avec des pointeurs et des
|
||||||
Ah, les pointeurs, la pire chose du monde\dots
|
tableaux dedans.
|
||||||
|
Ah, les pointeurs, la pire chose du monde, mais pourquoi s'en passer\dots
|
||||||
|
|
||||||
\subsubsection*{quelques rappels de comment on acquiert et numérise une image}
|
\subsubsection*{quelques rappels de comment on acquiert et numérise une image}
|
||||||
|
|
||||||
@@ -122,7 +131,7 @@ dans les machin-trocs, et un grain d'image vraiment présent.
|
|||||||
|
|
||||||
Ah vous en voulez de la technique ? Oké, on y va.
|
Ah vous en voulez de la technique ? Oké, on y va.
|
||||||
En fait, on va tripoter pleins de nombres, plus ou moins rangés dans
|
En fait, on va tripoter pleins de nombres, plus ou moins rangés dans
|
||||||
des champs de pixels, pour concrétiser l'existence perceptuelles de ces
|
des champs de pixels, pour concrétiser l'existence perceptuelle de ces
|
||||||
grains de lumière chromatisés.
|
grains de lumière chromatisés.
|
||||||
|
|
||||||
\subsubsection*{quelques belles images / schémas polychromes en intro pour
|
\subsubsection*{quelques belles images / schémas polychromes en intro pour
|
||||||
@@ -136,20 +145,23 @@ la glisser dans le capitalisme de surveillance.
|
|||||||
|
|
||||||
\setlength \parskip {0em}
|
\setlength \parskip {0em}
|
||||||
|
|
||||||
|
\pagebreak
|
||||||
\tableofcontents
|
\tableofcontents
|
||||||
\pagebreak
|
\pagebreak
|
||||||
\setlength \parskip {0.40em}
|
\setlength \parskip {0.40em}
|
||||||
|
|
||||||
\layout \pagebreak
|
% XXX \layout \pagebreak
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
\section{Théorie}\index{théorie}
|
|
||||||
|
|
||||||
|
\section{Théorie}\index{théorie}
|
||||||
|
|
||||||
Pour le moment, seule la quête de l'empirisme absolu a été
|
Pour le moment, seule la quête de l'empirisme absolu a été
|
||||||
visée. Les justifications mathématiques attendront le retour
|
visée. Les justifications mathématiques attendront le retour
|
||||||
du schmod777. Ceci dit, rien ne nous empêche d'aller consulter
|
de monsieur Schmod777.
|
||||||
Wikipedia~:
|
Ceci dit, rien ne nous empêche d'aller consulter
|
||||||
|
Wikipedia, afin de mieux connaitre ces nombres flottants
|
||||||
|
que nous allons utiliser~:
|
||||||
|
|
||||||
\begin{quotation}
|
\begin{quotation}
|
||||||
An IEEE 754 32-bit base-2 floating-point variable has
|
An IEEE 754 32-bit base-2 floating-point variable has
|
||||||
@@ -164,22 +176,36 @@ officially referred to as binary32; it was called single in
|
|||||||
IEEE 754-1985.
|
IEEE 754-1985.
|
||||||
\end{quotation}
|
\end{quotation}
|
||||||
|
|
||||||
Ce qui nous conduit à estimer qu'il est possible de cumuler environ
|
% XXX
|
||||||
quelques milliers d'images standard à 256 niveaux, sans trop avoir
|
% Ce qui nous conduit à estimer qu'il est possible de cumuler environ
|
||||||
à se soucier des éventuelles pertes de précision. Mais ça demande
|
% quelques milliers d'images standard à 256 niveaux, sans trop avoir
|
||||||
à être confirmé par des esprits supérieurs.
|
% à se soucier des éventuelles pertes de précision. Mais ça demande
|
||||||
|
% à être confirmé par des esprits supérieurs.
|
||||||
|
|
||||||
|
https://dl.acm.org/doi/pdf/10.1145/103162.103163
|
||||||
|
|
||||||
\subsection{Dynamique}\index{dynamique}
|
\subsection{Dynamique}\index{dynamique}
|
||||||
|
|
||||||
Dynamique, précision et \textsl{macheps} ? Peu de gens connaissent
|
Dynamique, précision et \textsl{macheps} ? Peu de gens connaissent
|
||||||
la fourbitude des calculs en virgule flottante avec les ordinateurs.
|
la fourbitude des calculs en virgule flottante avec les ordinateurs.
|
||||||
Moi-même compris.
|
Moi-même compris. Il est évident qu'une étude théorique doit être
|
||||||
|
effectuée afin d'éviter les potentiels inconvénients.
|
||||||
|
|
||||||
|
Ceci dit, le standard \textsl{ieee754}\index{ieee754} nous indique qu'il
|
||||||
|
y a 23 bits pour la mantisse, ce qui nous propose déja
|
||||||
|
plus de huit millions de valeurs possibles.
|
||||||
|
Considérons un cas typique~:
|
||||||
|
le cumul de $N$ images ayant un niveau maximum $Vm$.
|
||||||
|
|
||||||
\subsection{Pixel négatif ?}
|
\subsection{Pixel négatif ?}
|
||||||
|
|
||||||
Il est très difficle d'imaginer une lumière négative. Sauf peut-être
|
Il est très difficle d'imaginer une lumière négative. Sauf peut-être
|
||||||
si nous songeons à des coefficients d'absorption, ou un canal
|
si nous songeons à des coefficients d'absorption, ou un canal
|
||||||
\textsl{alpha} qui inverserait les valeurs ?
|
\textsl{alpha} qui inverserait les valeurs ? Un domaine dont
|
||||||
|
l'exploration peut confiner au mysticisme de part la multitude
|
||||||
|
des traitement possibles : valeur absolue, \textsl{clamping},
|
||||||
|
report sur les autres composantes. Votre imagination est
|
||||||
|
la limite.
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
|
|
||||||
@@ -192,7 +218,7 @@ mais nous sommes tous là pour améliorer les choses, dans
|
|||||||
la mesure de nos moyens.
|
la mesure de nos moyens.
|
||||||
Nous allons donc directement rentrer au cœur du problème,
|
Nous allons donc directement rentrer au cœur du problème,
|
||||||
en écrivant quelques lignes de code montrant le fonctionnement
|
en écrivant quelques lignes de code montrant le fonctionnement
|
||||||
général de la chose.
|
général de la chose vu du coté de la machine.
|
||||||
|
|
||||||
\subsection{L'idée}
|
\subsection{L'idée}
|
||||||
|
|
||||||
@@ -200,8 +226,8 @@ Pour commencer par quelque chose de simple,
|
|||||||
nous allons créer une image RGB\index{RGB} complètement noire,
|
nous allons créer une image RGB\index{RGB} complètement noire,
|
||||||
puis l'enregistrer dans un fichier \texttt{.fimg}\index{.fimg},
|
puis l'enregistrer dans un fichier \texttt{.fimg}\index{.fimg},
|
||||||
un format complètement inconnu, puisque je viens de l'inventer
|
un format complètement inconnu, puisque je viens de l'inventer
|
||||||
à l'instant même.
|
à l'instant même\footnote{Enfin, non, il y a déja longtemps,
|
||||||
Enfin, non, il y a déja longtemps, avant la grande pandémie.
|
avant la grande pandémie.}.
|
||||||
|
|
||||||
Tout d'abord, nous devons déclarer et garnir quelques variables
|
Tout d'abord, nous devons déclarer et garnir quelques variables
|
||||||
pour gérer la machinerie interne.
|
pour gérer la machinerie interne.
|
||||||
@@ -216,8 +242,9 @@ Ensuite, nous enchainerons trois étapes : la création de l'image
|
|||||||
en mémoire centrale, l'initialisation des valeurs de chaque pixel à 0.0
|
en mémoire centrale, l'initialisation des valeurs de chaque pixel à 0.0
|
||||||
(une valeur que certains associent au noir complet, et d'autres à une
|
(une valeur que certains associent au noir complet, et d'autres à une
|
||||||
impossibilité quantique),
|
impossibilité quantique),
|
||||||
et pour conclure, l'enregistrement dans un fichier\footnote{Au format
|
et pour conclure, l'enregistrement de cette image dans un
|
||||||
ésotérique, mais très véloce.} binaire.
|
fichier\footnote{Au format ésotérique, mais très véloce.}
|
||||||
|
binaire.
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
memset(fimg, 0, sizeof(FloatImg));
|
memset(fimg, 0, sizeof(FloatImg));
|
||||||
@@ -234,10 +261,9 @@ if (foo) {
|
|||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
|
Une fois ce code enrobé dans un \texttt{main()}, compilé puis exécuté,
|
||||||
Une fois ce code enrobé dans un \texttt{main()}, compilé et exécuté,
|
|
||||||
nous pouvons entrevoir, grâce au logiciel
|
nous pouvons entrevoir, grâce au logiciel
|
||||||
\texttt{fimgstats} (voir page \pageref{fimgstats}),
|
\texttt{fimgstats} (décrit en page \pageref{fimgstats}),
|
||||||
le résultat sous forme de chiffres divers, et/ou inutiles~:
|
le résultat sous forme de chiffres divers, et/ou inutiles~:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
@@ -261,9 +287,9 @@ Avec un bon script bash, il y a déja de quoi faire.
|
|||||||
La suite vers la page \pageref{codaz}.
|
La suite vers la page \pageref{codaz}.
|
||||||
|
|
||||||
Vous trouverez dans le répertoire \texttt{tools/}\index{tools/}
|
Vous trouverez dans le répertoire \texttt{tools/}\index{tools/}
|
||||||
d'autres exemples de mise en œuvre des fonctions disponibles
|
d'autres exemples de mise en œuvre de quelques fonctions disponibles
|
||||||
sous formes d'outils en ligne de commande,
|
sous formes d'outils en ligne de commande,
|
||||||
lesquels sont approximativement décrits en page \pageref{outils}.
|
lesquels outils sont approximativement décrits en page \pageref{outils}.
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
\section{Installation}
|
\section{Installation}
|
||||||
@@ -273,21 +299,22 @@ une distribution Debian\index{Debian} récente (amd64 et x86),
|
|||||||
mais ça marche quasiment pareil avec Fedora\index{Fedora} 64,
|
mais ça marche quasiment pareil avec Fedora\index{Fedora} 64,
|
||||||
et
|
et
|
||||||
probablement Raspbian\index{Raspbian}, modulo les éventuels
|
probablement Raspbian\index{Raspbian}, modulo les éventuels
|
||||||
soucis de boutisme.
|
soucis de boutisme que j'ai absolument négligés de prendre
|
||||||
|
en compte.
|
||||||
\textit{Attention, ça va devenir un peu gore\dots}
|
\textit{Attention, ça va devenir un peu gore\dots}
|
||||||
|
|
||||||
\subsection{Prérequis}
|
\subsection{Prérequis}
|
||||||
|
|
||||||
Vous devez, en dehors des outils classiques (gcc, Awk, make\dots),
|
Vous devez, en dehors des outils classiques (gcc, Awk, make\dots),
|
||||||
avoir quelques bibliothèques installées\footnote{Les \texttt{-dev}
|
avoir quelques bibliothèques installées~:
|
||||||
en plus pour Debian et dérivées}~:
|
|
||||||
\textsf{
|
\textsf{
|
||||||
libv4l2, libpnglite, libtiff,
|
libv4l2, libpnglite, libtiff,
|
||||||
libnetpbm\footnote{package libnetpbm10-dev},
|
libnetpbm\footnote{package libnetpbm10-dev},
|
||||||
libz\footnote{package zlib1g-dev}, libcurses,
|
libz\footnote{package zlib1g-dev}, libcurses,
|
||||||
libcfitsio-dev
|
libcfitsio...
|
||||||
} % end of textsf
|
} % end of textsf
|
||||||
éventuellement avec le \textsf{-dev} correspondant,
|
éventuellement avec le \textsf{-dev} correspondant, qui contient, entre
|
||||||
|
autres, les fichiers \texttt{.h} associés
|
||||||
et probablement d'autres choses.
|
et probablement d'autres choses.
|
||||||
|
|
||||||
Il est même quasiment certain que Bash soit indispensable, tout
|
Il est même quasiment certain que Bash soit indispensable, tout
|
||||||
@@ -296,7 +323,8 @@ Une connaissance de base de l'utilisation du shell\index{shell}
|
|||||||
et de l'écriture de Makefile's sera un plus.
|
et de l'écriture de Makefile's sera un plus.
|
||||||
|
|
||||||
Il faut aussi savoir où trouver le code. Il est dans le Git du
|
Il faut aussi savoir où trouver le code. Il est dans le Git du
|
||||||
Tetalab. Mais comme je ne comprend rien à Git, c'est pas la peine
|
Tetalab\footnote{\texttt{https://git.tetalab.org/tTh/FloatImg}}.
|
||||||
|
Mais comme je ne comprend rien à Git, c'est pas la peine
|
||||||
de m'envoyer des trucs genre \textsl{pull-request} auquels je ne
|
de m'envoyer des trucs genre \textsl{pull-request} auquels je ne
|
||||||
comprend rien.
|
comprend rien.
|
||||||
|
|
||||||
@@ -338,7 +366,7 @@ Faites-en ce que vous voulez.
|
|||||||
Classiquement, il y a un fichier \texttt{.h} à inclure dans chacun
|
Classiquement, il y a un fichier \texttt{.h} à inclure dans chacun
|
||||||
de vos codes source,
|
de vos codes source,
|
||||||
\texttt{floatimg.h}, généralement logé dans \texttt{/usr/local/include}
|
\texttt{floatimg.h}, généralement logé dans \texttt{/usr/local/include}
|
||||||
contenant un certain nombre de définition de structures, de macros,
|
et contenant un certain nombre de définition de structures, de macros,
|
||||||
de constantes\footnote{À l'ancienne, via le pré-processeur}
|
de constantes\footnote{À l'ancienne, via le pré-processeur}
|
||||||
et les prototypes des fonctions utilisables par vos logiciels.
|
et les prototypes des fonctions utilisables par vos logiciels.
|
||||||
|
|
||||||
@@ -347,7 +375,7 @@ classées en deux catégories : \texttt{lib/} et \texttt{funcs/}.
|
|||||||
La première contient les choses qui sont relativement figées,
|
La première contient les choses qui sont relativement figées,
|
||||||
et la seconde celles qui risquent de bouger. Cette classification
|
et la seconde celles qui risquent de bouger. Cette classification
|
||||||
est en fait indécement arbitraire.
|
est en fait indécement arbitraire.
|
||||||
D'autant plus qu'il y a aussi un répertoire nommé « experiemental ».
|
D'autant plus qu'il y a aussi un répertoire nommé « experimental ».
|
||||||
|
|
||||||
\subsection{Structures, macros\dots}
|
\subsection{Structures, macros\dots}
|
||||||
|
|
||||||
@@ -406,7 +434,7 @@ quelques images...
|
|||||||
|
|
||||||
Le champ \textsl{count} sera mis à 0 et
|
Le champ \textsl{count} sera mis à 0 et
|
||||||
le champ \textsl{fval} sera initialisé à 15.0
|
le champ \textsl{fval} sera initialisé à 15.0
|
||||||
(qui est la valeur maximale que peut renvoyer ce capteur).
|
(ce qui est la valeur maximale que peut renvoyer ce capteur).
|
||||||
Ensuite, dans la boucle capture/cumul, \textsl{count} sera
|
Ensuite, dans la boucle capture/cumul, \textsl{count} sera
|
||||||
incrémenté à chaque passe, et nous aurons donc, en finale,
|
incrémenté à chaque passe, et nous aurons donc, en finale,
|
||||||
toutes les informations nécessaires pour exploiter au mieux la dynamique
|
toutes les informations nécessaires pour exploiter au mieux la dynamique
|
||||||
@@ -445,24 +473,26 @@ avant le moindre usage\footnote{\texttt{man 3 memset}}.
|
|||||||
Certains membres de cette structure sont
|
Certains membres de cette structure sont
|
||||||
documentés dans ce document, et les autres sont dangereux à
|
documentés dans ce document, et les autres sont dangereux à
|
||||||
toucher. Les types d'images actuellement gérés sont les trois grands
|
toucher. Les types d'images actuellement gérés sont les trois grands
|
||||||
classiques : gray, rgb et rgba. et expliquées quelques lignes plus haut.
|
classiques : niveau de gris, rouge-vert-bleu et rgb avec un canal alpha,
|
||||||
|
et expliquées quelques lignes plus haut.
|
||||||
|
|
||||||
|
XXX\index{XXX} raconter fimg\_clone
|
||||||
|
|
||||||
Comme vous allez le voir plus loin, il y a plein de fonctions qui
|
Comme vous allez le voir plus loin, il y a plein de fonctions qui
|
||||||
prennent en argument deux images: une source et une destination.
|
prennent en argument deux images: la source et la destination.
|
||||||
Et dans la plupart des cas, ces deux images doivent être compatibles,
|
Dans la plupart des cas, ces deux images doivent être compatibles,
|
||||||
c'est à dire même type et mêmes dimensions.
|
c'est à dire de même type et de mêmes dimensions.
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
/* return 0 if compatible */
|
/* return 0 if pictures are compatible */
|
||||||
int fimg_images_not_compatible(FloatImg *a, FloatImg *b);
|
int fimg_images_not_compatible(FloatImg *a, FloatImg *b);
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
|
|
||||||
C'est bien beau d'être enfin une image résidente en mémoire centrale, mais
|
C'est bien beau d'être enfin une image résidente en mémoire centrale, mais
|
||||||
pouvoir aussi exister à long terme en étant stocké dans la matrice
|
pouvoir aussi exister à long terme en étant stocké dans la matrice
|
||||||
est tout aussi pertinent.
|
est tout aussi pertinent.
|
||||||
Il y a deux opérations qui supportent le reste des transits ram/ps.
|
Il y a deux opérations qui supportent le reste des transits ram/ps.
|
||||||
Le format des fichiers est décrit page \pageref{formatfimg}.
|
Le format de ces fichiers est décrit page \pageref{formatfimg}.
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
int fimg_dump_to_file(FloatImg *fimg, char *fname, int notused);
|
int fimg_dump_to_file(FloatImg *fimg, char *fname, int notused);
|
||||||
@@ -472,7 +502,7 @@ int fimg_load_from_dump(char *fname, FloatImg *where);
|
|||||||
Recharger une image depuis un fichier nécessite que celle-ci et
|
Recharger une image depuis un fichier nécessite que celle-ci et
|
||||||
l'image de destination en mémoire
|
l'image de destination en mémoire
|
||||||
ait précisément les mêmes caractéristiques
|
ait précisément les mêmes caractéristiques
|
||||||
(taille, type...), donc l'image en ram doit être
|
(taille, type...), donc l'image en mémoire centrale doit être
|
||||||
pré-allouée. On peut connaitre ces valeurs en appelant
|
pré-allouée. On peut connaitre ces valeurs en appelant
|
||||||
\texttt{int fimg\_fileinfos(char *fname, int datas[3])}.
|
\texttt{int fimg\_fileinfos(char *fname, int datas[3])}.
|
||||||
|
|
||||||
@@ -497,17 +527,20 @@ foo = fimg_create_from_dump("lena.fimg", &head);
|
|||||||
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 probablement mal passé.
|
chose s'est probablement mal passé.
|
||||||
Certains messages sont parfois explicites. Mais parfois non.
|
Certains messages sont parfois explicites. Mais parfois non.
|
||||||
|
Quand aux valeurs retournées en cas d'erreur, c'est le désordre
|
||||||
|
intégral\footnote{Un vrai désastre, même...}.
|
||||||
|
|
||||||
% _________
|
% _________
|
||||||
|
|
||||||
\subsection{Dessiner}
|
\subsection{Dessiner}
|
||||||
|
|
||||||
Bon, vous avez une image latente, et vous souhaitez dessiner dessus
|
Bon, vous avez en mémoire centrale une image latente,
|
||||||
(ou dedans ?) avec vos encres flottantes ?
|
et vous souhaitez dessiner dessus (ou dedans ?) avec vos encres flottantes ?
|
||||||
Il y a des fonctions pour ça, par exemple~:
|
Il y a actuellement deux fonctions pour ça, légèrement différentes~:
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
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_put_rgb(FloatImg *head, int x, int y, float rgb[3]);
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
Les paramètres sont explicites, mais leur validité doit être
|
Les paramètres sont explicites, mais leur validité doit être
|
||||||
@@ -526,7 +559,8 @@ $x$ et $y$ de la demande.
|
|||||||
Quand au canal \textsl{alpha}\index{alpha}, il est pour le moment
|
Quand au canal \textsl{alpha}\index{alpha}, il est pour le moment
|
||||||
superbement ignoré. Ceci dit, on vient de me faire remarquer qu'il
|
superbement ignoré. Ceci dit, on vient de me faire remarquer qu'il
|
||||||
peut être utilisable aussi pour faire du
|
peut être utilisable aussi pour faire du
|
||||||
\textsl{z-buffer}\index{z-buffer}\index{rgbz}\dots
|
\textsl{z-buffer}\index{z-buffer}\index{rgbz}, une technique
|
||||||
|
classique dans la génération d'images en trois dimensions.\dots
|
||||||
|
|
||||||
% ----------------------------------
|
% ----------------------------------
|
||||||
|
|
||||||
@@ -644,9 +678,12 @@ aux bonnes dimensions (échange W et H).
|
|||||||
\subsection{Format du fichier \textsc{fimg}}\index{format}\label{formatfimg}
|
\subsection{Format du fichier \textsc{fimg}}\index{format}\label{formatfimg}
|
||||||
|
|
||||||
D'un design très empirique, c'est certainement à revoir pour l'avenir.
|
D'un design très empirique, c'est certainement à revoir pour l'avenir.
|
||||||
Tout d'abord pour normaliser l'endianess et le packing dans les structs%
|
La force du \textsl{legacy} va-t-elle dominer le monde ?
|
||||||
\footnote{Ce qui n'est pas encore fait}, et surtout l'ajout
|
Il faudrait normaliser l'endianess et le packing dans les
|
||||||
de données sur la prise de vue.
|
structuress\footnote{Directives du compilateur ?}, et surtout l'ajout
|
||||||
|
de données sur la prise de vue, du genre type de capteur, date et heure,
|
||||||
|
réglages divers. Nous appelerons ça les metadonnées, et
|
||||||
|
nous en parlons dans quelques pages.\dots
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -655,30 +692,35 @@ typedef struct {
|
|||||||
} FimgFileHead;
|
} FimgFileHead;
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
\dots Mais aussi pour faciliter l'ajout de métadonnées, telles que
|
|
||||||
la valeur maximale, la date de création, une longueur d'onde,
|
|
||||||
et bien plus encore.
|
|
||||||
|
|
||||||
Le champ \texttt{magic[8]} doit contenir une valeur magique~:
|
Le champ \texttt{magic[8]} doit contenir une valeur magique~:
|
||||||
les quatre premier octets doivent contenir les quatre caractères
|
les quatre premiers octets doivent contenir les quatre caractères
|
||||||
\texttt{'FIMG'}, et les quatre dernier doivent être à 0, sauf que,
|
\texttt{'FIMG'}, et les quatre derniers doivent être à 0, sauf que,
|
||||||
voir plus bas.
|
voir plus bas, le cinquième vas vous étonner.
|
||||||
Le champ \texttt{t} (le type de l'image) doit avoir les trois octets
|
Le champ \texttt{t} (le type de l'image) doit avoir les trois octets
|
||||||
de poids fort à 0. Vous trouverez les constantes de type dans le
|
de poids fort à 0\footnote{Pourquoi ? Je n'en sais rien.}.
|
||||||
|
|
||||||
|
Ensuite, nous aurons (dans le cas courant) : 1, 2 ou 4 blocs
|
||||||
|
de WxH pixels sous forme de Float32. La première ligne lue
|
||||||
|
est la ligne du haut de l'image. Les valeurs négatives sont
|
||||||
|
tolérées.
|
||||||
|
|
||||||
|
Vous trouverez les constantes de type pertinentes dans le
|
||||||
fichier \texttt{floatimg.h}, et quelques informations
|
fichier \texttt{floatimg.h}, et quelques informations
|
||||||
(non-)essentielles qui ne vous serviront probablement à rien.
|
(non-)essentielles qui ne vous serviront probablement à rien.
|
||||||
|
|
||||||
|
|
||||||
% ----------------------------------
|
% ----------------------------------
|
||||||
% new février 2022
|
% new février 2022
|
||||||
|
|
||||||
\subsection{Métadonnées}
|
\subsection{Métadonnées}
|
||||||
\index{metadata} \index{timestamp}
|
\index{metadata} \index{timestamp}
|
||||||
|
|
||||||
Attention, ce n'est pas encore une version déinitive, beaucoup de
|
Attention, ce n'est pas encore une version définitive, beaucoup de
|
||||||
choses restent à préciser sur le contenu de cette structure, mais
|
choses restent à préciser sur le contenu de cette structure, mais
|
||||||
l'essentiel est déja là. On reconnait un fichier avec metadata
|
l'essentiel est déja là. On reconnait un fichier avec metadata
|
||||||
quand l'octet \texttt{magic[4]} du premier header est égal à
|
quand l'octet \texttt{magic[4]} du premier header est égal à
|
||||||
\texttt{'a'}.
|
la lettre \texttt{'a'}.
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -695,6 +737,8 @@ Voyons maintenant chacun des champs de cette structure, en prenant bien
|
|||||||
en compte qu'à ce moment\footnote{4 avril 2022}, tout n'est pas figé.
|
en compte qu'à ce moment\footnote{4 avril 2022}, tout n'est pas figé.
|
||||||
Ceci dit, nous allons aussi retrouver de vieilles connaissances.
|
Ceci dit, nous allons aussi retrouver de vieilles connaissances.
|
||||||
|
|
||||||
|
\textbf{to be continued}
|
||||||
|
|
||||||
% ----------------------------------
|
% ----------------------------------
|
||||||
|
|
||||||
\subsection{Exportation \& Importation}\index{export}\label{export}
|
\subsection{Exportation \& Importation}\index{export}\label{export}
|
||||||
@@ -710,7 +754,7 @@ Et dans le sens inverse, il serait bien de savoir importer
|
|||||||
le monde extérieur dans nos sombres caves à pixel.
|
le monde extérieur dans nos sombres caves à pixel.
|
||||||
Il faut quand même reconnaitre que c'est un peu la jungle dans les
|
Il faut quand même reconnaitre que c'est un peu la jungle dans les
|
||||||
formats de fichiers d'image, ce qui explique le retard
|
formats de fichiers d'image, ce qui explique le retard
|
||||||
dans ce domaine\dots
|
du développement dans ce domaine\dots
|
||||||
|
|
||||||
\subsubsection{Vers PNM}\index{PNM}
|
\subsubsection{Vers PNM}\index{PNM}
|
||||||
|
|
||||||
@@ -746,7 +790,8 @@ mais on a quand même une bonne compression, ça compense.
|
|||||||
|
|
||||||
J'utilise \textsl{libpnglite} avec qui j'ai un peu de mal à suivre.
|
J'utilise \textsl{libpnglite} avec qui j'ai un peu de mal à suivre.
|
||||||
Mais je me soigne. Le mode 16 bits va bientôt arriver.
|
Mais je me soigne. Le mode 16 bits va bientôt arriver.
|
||||||
On peut aussi songer à l'export des metadatas.
|
On peut aussi songer à l'export des metadonnées, pour celles qui
|
||||||
|
sont compatibles avec le standard PNG.
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
int fimg_save_as_png(FloatImg *src, char *outname, int flags);
|
int fimg_save_as_png(FloatImg *src, char *outname, int flags);
|
||||||
@@ -754,8 +799,9 @@ int fimg_save_as_png(FloatImg *src, char *outname, int flags);
|
|||||||
|
|
||||||
Tous les flags doivent être à zéro. Sinon, ça foire parfois.
|
Tous les flags doivent être à zéro. Sinon, ça foire parfois.
|
||||||
Et en fait (mars 2021) je ne suis pas très content de
|
Et en fait (mars 2021) je ne suis pas très content de
|
||||||
\texttt{pnglite}, donc un de ces jours\footnote{Rendez-nous notre
|
\texttt{pnglite}, donc un de ces jours, je prendrais
|
||||||
Mixou !}, je prendrais cinq jours pour régler le souci.
|
\sout{cinq} quelques jours pour
|
||||||
|
régler ce souci en passant à la bibliothèque canonique.
|
||||||
|
|
||||||
\subsubsection{Vers TIFF}\index{TIFF}
|
\subsubsection{Vers TIFF}\index{TIFF}
|
||||||
|
|
||||||
@@ -801,6 +847,7 @@ fichier de configuration.
|
|||||||
int parse_WxH(char *str, int *pw, int *ph)
|
int parse_WxH(char *str, int *pw, int *ph)
|
||||||
int parse_double(char *str, double *dptr)
|
int parse_double(char *str, double *dptr)
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
% XXX rjouter quelques explication, please !
|
||||||
|
|
||||||
La fonction \texttt{int format\_from\_extension(char *fname)} examine un
|
La fonction \texttt{int format\_from\_extension(char *fname)} examine un
|
||||||
nom de fichier tel que \texttt{lena.xxx}, et retourne, si la partie
|
nom de fichier tel que \texttt{lena.xxx}, et retourne, si la partie
|
||||||
@@ -808,7 +855,7 @@ nom de fichier tel que \texttt{lena.xxx}, et retourne, si la partie
|
|||||||
déclarées dans floatimg.h
|
déclarées dans floatimg.h
|
||||||
le valeureux.
|
le valeureux.
|
||||||
Les extensions actuellement connues sont :
|
Les extensions actuellement connues sont :
|
||||||
fimg, png, pnm, pgm, fits et tiff.
|
fimg, png, pnm, pgm, fits et tiff. Le bmp est plus ou moins prévu\dots
|
||||||
|
|
||||||
To be continued\index{XXX}\dots
|
To be continued\index{XXX}\dots
|
||||||
|
|
||||||
@@ -836,7 +883,7 @@ J'ai commencé à étudier ces objets étranges quand j'ai commencé
|
|||||||
à travailler sur l'interpolator\index{interpolator} à l'automne 2020.
|
à travailler sur l'interpolator\index{interpolator} à l'automne 2020.
|
||||||
Hélas, j'ai vite réalisé que c'était assez délicat.
|
Hélas, j'ai vite réalisé que c'était assez délicat.
|
||||||
Pour ce genre de \textsl{usecase}, le numérique est pitoyable si on
|
Pour ce genre de \textsl{usecase}, le numérique est pitoyable si on
|
||||||
le compare au \textsc{Betamax}\index{Betamax}.
|
le compare au (hélas défunt) \textsc{Betamax}\index{Betamax}.
|
||||||
|
|
||||||
% =============================================================
|
% =============================================================
|
||||||
|
|
||||||
@@ -879,8 +926,10 @@ int fimg_filter_3x3(FloatImg *src, FloatImg *dst, FimgFilter3x3 *filtr)
|
|||||||
\end{lstlisting}
|
\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, qui fait souvent du portnawak.
|
||||||
quelques solutions de contournement : clamping ou shift ?
|
Quoique, il doit bien exister
|
||||||
|
quelques solutions de contournement :
|
||||||
|
valeur absolue, clamping ou shiftup ?
|
||||||
|
|
||||||
\textsl{To be continued\index{XXX}\dots}
|
\textsl{To be continued\index{XXX}\dots}
|
||||||
|
|
||||||
@@ -893,8 +942,8 @@ le répertoire \texttt{funcs/}.
|
|||||||
Elle aura donc accès aux \textsl{internals}%
|
Elle aura donc accès aux \textsl{internals}%
|
||||||
\footnote{que je peux décider de changer n'importe quand}
|
\footnote{que je peux décider de changer n'importe quand}
|
||||||
de \textsc{FloatImg},
|
de \textsc{FloatImg},
|
||||||
une chose qui est en principe interdit aux programmes
|
une chose qui est en principe interdite aux programmes
|
||||||
\textsl{enduser}. Soyez prudents.
|
\textsl{enduser}. Soyez donc prudents.
|
||||||
|
|
||||||
Cette fonction va faire quelque chose
|
Cette fonction va faire quelque chose
|
||||||
à partir d'une image source et d'une valeur, et écrire le
|
à partir d'une image source et d'une valeur, et écrire le
|
||||||
@@ -937,14 +986,17 @@ de fonctions prévues à cet effet, mais il fallait rester simple\dots
|
|||||||
% ===================================================================
|
% ===================================================================
|
||||||
\section{Les outils}\label{outils}
|
\section{Les outils}\label{outils}
|
||||||
|
|
||||||
\textsf{3615mavie} : sur des projets comme celui-ci, qui travaillent
|
\textsf{3615mavie} : pour des projets comme celui-ci, qui travaillent
|
||||||
in-fine sur des objets que l'on peut considérer comme « physiques »,
|
\textit{in-fine} sur des objets que l'on peut considérer
|
||||||
|
comme « physiques »,
|
||||||
il est important de passer à une utilisation
|
il est important de passer à une utilisation
|
||||||
normale\footnote{Il y a une vie en dehors de git.} et construire
|
normale\footnote{Il y a une vie en dehors de git et des compilations.}
|
||||||
des trucs qui mettent en action le code primitif pour partir
|
et construire
|
||||||
sur des bases saines.
|
des briques de base qui mettent en action le code primitif pour
|
||||||
|
partir sur des bases stables, documentées (ahem\dots), et
|
||||||
|
directement utilisables.
|
||||||
|
|
||||||
Ces machins ont en commun quelques options bien pratiques~:
|
Ces cliwares\index{cliware} ont en commun quelques options bien pratiques~:
|
||||||
\texttt{-h} pour avoir un résumé des options disponibles,
|
\texttt{-h} pour avoir un résumé des options disponibles,
|
||||||
\texttt{-v} qui augmente la puissance de bavardage, et
|
\texttt{-v} qui augmente la puissance de bavardage, et
|
||||||
\texttt{-K nn.nn} pour un paramètre flottant.
|
\texttt{-K nn.nn} pour un paramètre flottant.
|
||||||
@@ -994,7 +1046,11 @@ error in 'fimg_create_from_png' : read png -> -1 File error
|
|||||||
png2fimg : err -1, abort.
|
png2fimg : err -1, abort.
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Il faut peut-être envisager le passage à \texttt{libpng}\index{libpng}.
|
Il faut peut-être envisager le passage à \texttt{libpng}\index{libpng},
|
||||||
|
la bibliothèque actuellement utilisée (\texttt{pnglite}) ayant tendance
|
||||||
|
à borker en lecture sur certains fichiers pourtant corrects.
|
||||||
|
|
||||||
|
% ---------------------
|
||||||
|
|
||||||
\subsection{fimgstats}\index{fimgstats}\label{fimgstats}
|
\subsection{fimgstats}\index{fimgstats}\label{fimgstats}
|
||||||
|
|
||||||
@@ -1044,7 +1100,9 @@ sera lisible avec le sélecteur \texttt{-L}.
|
|||||||
|
|
||||||
Et pour les aventureux, la commande \texttt{xper} (abréviation
|
Et pour les aventureux, la commande \texttt{xper} (abréviation
|
||||||
de \textsl{expérimental}) permet de tester la plus récente tentative
|
de \textsl{expérimental}) permet de tester la plus récente tentative
|
||||||
de friture du moment.
|
de friture du moment. D'autre part un set bien plus complet d'effets
|
||||||
|
àlc est disponible dans les logiciels de flou temporel, décrits
|
||||||
|
plus loin dans ce document.
|
||||||
|
|
||||||
% ---------------------
|
% ---------------------
|
||||||
|
|
||||||
@@ -1079,7 +1137,7 @@ les valeurs négatives peuvent être la cause de \textsl{glitches}
|
|||||||
de qualitay.
|
de qualitay.
|
||||||
|
|
||||||
La liste des opérations est susceptible d'être agrémenté de quelques
|
La liste des opérations est susceptible d'être agrémenté de quelques
|
||||||
possibilités bie féroce\footnote{Stau tuned, flim at 11.}.
|
possibilités bien féroces\footnote{Stay tuned, flim at 11.}.
|
||||||
|
|
||||||
% -------------------------
|
% -------------------------
|
||||||
|
|
||||||
@@ -1177,7 +1235,8 @@ après la grande pandémie\dots
|
|||||||
|
|
||||||
Cet outil accumule\index{cumul} une quantité d'images flottantes
|
Cet outil accumule\index{cumul} une quantité d'images flottantes
|
||||||
(de même taille et de même type) afin d'obtenir
|
(de même taille et de même type) afin d'obtenir
|
||||||
un flou temporel de meilleure qualité. Aucune mise à l'échelle n'etant
|
un flou temporel de meilleure qualité.
|
||||||
|
Aucune mise à l'échelle n'etant
|
||||||
effectuée, les pixels de sortie peuvent atteindre des valeurs
|
effectuée, les pixels de sortie peuvent atteindre des valeurs
|
||||||
considérables\footnote{Faut-il prévoir une gestion des \textsf{overflows} ?}
|
considérables\footnote{Faut-il prévoir une gestion des \textsf{overflows} ?}
|
||||||
|
|
||||||
@@ -1249,7 +1308,7 @@ if (foo) {
|
|||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
À condition d'avoir bien réglé votre ulimit pour la génération d'un coredump,
|
À condition d'avoir bien réglé votre ulimit pour la génération d'un coredump,
|
||||||
vous aurez sous la main un fichier \textsc{core} qui vous permettra
|
vous aurez sous la main un fichier \texttt{core} qui vous permettra
|
||||||
de, par exemple, remonter la pile d'appel avec la commande \texttt{back} de
|
de, par exemple, remonter la pile d'appel avec la commande \texttt{back} de
|
||||||
gdb. Mais pour le moment, juste une infime partie du code est instrumentée
|
gdb. Mais pour le moment, juste une infime partie du code est instrumentée
|
||||||
avec ce dispositif.
|
avec ce dispositif.
|
||||||
@@ -1271,7 +1330,7 @@ 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é.
|
||||||
C'est par ces frottements de techniques ayant du sens que les
|
C'est par ces frottements de techniques ayant du sens que les
|
||||||
choses seront acquises, pour le pire, le meilleur et la
|
choses seront acquises, pour le pire, le meilleur et la
|
||||||
futilité du monde futur..
|
techno-futilité du monde futur..
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item Import/export au format \textsc{tiff}\index{TIFF} à continuer.
|
\item Import/export au format \textsc{tiff}\index{TIFF} à continuer.
|
||||||
@@ -1281,7 +1340,7 @@ futilité du monde futur..
|
|||||||
\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 Intégrer la fonderie, l'interpolator et le singlepass.
|
\item Intégrer la fonderie, l'interpolator et le singlepass.
|
||||||
\item Vérifier le gestion des images mono-canal.
|
\item Vérifier le gestion des images mono-canal et de la transparence.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
@@ -1295,7 +1354,7 @@ jamais négliger le traitement des éventuelles erreurs.
|
|||||||
Nous savons générer une image contenant des pixels aux valeurs
|
Nous savons générer une image contenant des pixels aux valeurs
|
||||||
probablement aléatoires, avec la commande \texttt{mkfimg},
|
probablement aléatoires, avec la commande \texttt{mkfimg},
|
||||||
qui utilise le \texttt{drand48}\index{drand48} de \textsc{posix}\index{POSIX}.
|
qui utilise le \texttt{drand48}\index{drand48} de \textsc{posix}\index{POSIX}.
|
||||||
Maintenant, posons-nous une question de statisticien : ue se passe-t-il si
|
Maintenant, posons-nous une question de statisticien : que se passe-t-il si
|
||||||
nous faisons la somme de plusieurs centaines de ces images ?
|
nous faisons la somme de plusieurs centaines de ces images ?
|
||||||
|
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
@@ -1362,7 +1421,7 @@ le premier pouvant salement brotcher une image, et le second capable de
|
|||||||
mélanger harmonieusement deux images, la balance est équilibrée.
|
mélanger harmonieusement deux images, la balance est équilibrée.
|
||||||
|
|
||||||
Il s'agit donc d'un petit programme écrit en Bash\index{bash}, un langage
|
Il s'agit donc d'un petit programme écrit en Bash\index{bash}, un langage
|
||||||
dont la connaissance est, pour moi, indispendable à qui veut faire des
|
dont la connaissance est, pour moi, indispensable à qui veut faire des
|
||||||
images kitchies\index{kitchy}. Mais ne vous inquiétez pas, c'est en
|
images kitchies\index{kitchy}. Mais ne vous inquiétez pas, c'est en
|
||||||
fait assez simple à comprendre. Et comprendre, c'est apprendre.
|
fait assez simple à comprendre. Et comprendre, c'est apprendre.
|
||||||
|
|
||||||
@@ -1383,10 +1442,12 @@ OFFS=$(( NBRE / 4 ))
|
|||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
|
|
||||||
Dans ce préliminaire logiciel, nous avons nommés le répertoire
|
Dans ce préliminaire logiciel, nous avons nommé le répertoire
|
||||||
\textsc{srcdir} contenant les captures d'image au format fimg, le répertoire
|
\textsc{srcdir} contenant les captures d'image au format fimg, le répertoire
|
||||||
\textsc{dstdir} dans lequel seront rangées les images calculées,
|
\textsc{dstdir} dans lequel seront rangées les images calculées,
|
||||||
et l'emplacement de deux fichiers de travail.
|
et l'emplacement de deux fichiers de travail, placés dans ce qui
|
||||||
|
peut être vu comme un \textsl{ramdisk}\index{ramdisk}\index{/dev/shm/}
|
||||||
|
et qui accélère un peu les opérations.
|
||||||
|
|
||||||
Les quelques lignes suivantes, qui semble bien magiques, ne sont en fait
|
Les quelques lignes suivantes, qui semble bien magiques, ne sont en fait
|
||||||
que de la magie Unix\index{Unix}. Elles nous permettent d'avoir
|
que de la magie Unix\index{Unix}. Elles nous permettent d'avoir
|
||||||
@@ -1432,12 +1493,12 @@ $sin(idx/16)$ afin d'avoir une oscillation du coefficient entre
|
|||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
# do the hard floating computation
|
# do the hard floating computation
|
||||||
#
|
#
|
||||||
fimgfx -v cos010 ${imgB} ${FTMP}
|
fimgfx -v cos010 ${imgB} ${FTMP}
|
||||||
fimgops -k ${K} ${FTMP} ${imgA} mix ${FDST}
|
fimgops -k ${K} ${FTMP} ${imgA} mix ${FDST}
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Étape suivante, étape cruciale : le brassage d'une multitude de
|
Étape suivante, étape cruciale : le brassage d'une multitude de
|
||||||
pixels flottants.
|
pixels flottants.
|
||||||
|
|
||||||
Tout d'abord, nous faisons subir à l'image-echo
|
Tout d'abord, nous faisons subir à l'image-echo
|
||||||
(\texttt{imgB}, définie au début du script) un distorsion
|
(\texttt{imgB}, définie au début du script) un distorsion
|
||||||
@@ -1455,8 +1516,8 @@ done
|
|||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
Et en fin de boucle, nous convertissons le résultat de nos
|
Et en fin de boucle, nous convertissons le résultat de nos
|
||||||
savants calculs au format PNG, et écrivons le fichier dans le répertoire
|
savants calculs au format PNG, et nous écrivons le fichier dans le
|
||||||
de destination fixé au début.
|
répertoire de destination fixé au début.
|
||||||
C'est le moment de passer la main à ffmpeg\index{ffmpeg}.
|
C'est le moment de passer la main à ffmpeg\index{ffmpeg}.
|
||||||
|
|
||||||
C'est juste une POC\index{POC}, et une implémentation bien plus
|
C'est juste une POC\index{POC}, et une implémentation bien plus
|
||||||
@@ -1464,6 +1525,9 @@ complète écrite en \textbf{C}\index{C} est déja en chantier,
|
|||||||
avec une complexité prévue à un niveau assez réjouissant.
|
avec une complexité prévue à un niveau assez réjouissant.
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
|
%
|
||||||
|
% V4L2 is a trap.
|
||||||
|
%
|
||||||
\section{Video for Linux}\index{v4l2}
|
\section{Video for Linux}\index{v4l2}
|
||||||
|
|
||||||
Donc, maintenant, nous savons un peu tripoter ces images flottantes.
|
Donc, maintenant, nous savons un peu tripoter ces images flottantes.
|
||||||
@@ -1479,11 +1543,11 @@ v4l2.
|
|||||||
|
|
||||||
\subsection{grabvidseq}\index{grabvidseq}\label{grabvidseq}
|
\subsection{grabvidseq}\index{grabvidseq}\label{grabvidseq}
|
||||||
|
|
||||||
Un logiciel en évolution (trop ?) lente, qui permet déja la capture
|
Un logiciel en évolution (vraiment trop) lente, qui permet déja
|
||||||
d'images en
|
la capture d'images en
|
||||||
\textsl{longue pose} selon la méthode du cumul\index{cumul}, et
|
\textsl{longue pose} selon la méthode du cumul\index{cumul}, et
|
||||||
devrait bientôt retrouver sa capacité à enregistrer des
|
devrait bientôt retrouver sa capacité à enregistrer des
|
||||||
séquences d'images.
|
séquences d'images. (\textsl{workaround}~: écrire une boucle en shell)
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
tth@debian:~/Devel/FloatImg/v4l2$ ./grabvidseq -h
|
tth@debian:~/Devel/FloatImg/v4l2$ ./grabvidseq -h
|
||||||
@@ -1519,8 +1583,8 @@ vaguement expliqué page \pageref{contraste}.
|
|||||||
|
|
||||||
L'option \texttt{-X} me permet d'intégrer des \textit{fritures}
|
L'option \texttt{-X} me permet d'intégrer des \textit{fritures}
|
||||||
expérimentales dans le binaire, et ne doit donc pas être
|
expérimentales dans le binaire, et ne doit donc pas être
|
||||||
utilisée dans des scripts si on a des visions à long (ou même)
|
utilisée dans des scripts si on a des visions à long
|
||||||
terme.
|
(ou même moyen) terme.
|
||||||
|
|
||||||
\subsubsection{Upscaling}\index{upscaling}\label{upscaling}
|
\subsubsection{Upscaling}\index{upscaling}\label{upscaling}
|
||||||
|
|
||||||
@@ -1554,22 +1618,30 @@ Options :
|
|||||||
Je me sens obligé d'avouer qu'il reste quelques points mystérieux dans
|
Je me sens obligé d'avouer qu'il reste quelques points mystérieux dans
|
||||||
l'\textsc{api} de \textsc{v4l2}, et donc, que ce que raconte
|
l'\textsc{api} de \textsc{v4l2}, et donc, que ce que raconte
|
||||||
ce logiciel doit être pris avec des pincettes. En particulier
|
ce logiciel doit être pris avec des pincettes. En particulier
|
||||||
la liste des résolutions disponibles.
|
des choses essentielles comme la liste des résolutions disponibles.
|
||||||
|
|
||||||
\subsection{nc-camcontrol}
|
\subsection{nc-camcontrol}
|
||||||
|
|
||||||
Ajustement \textsl{Brightness Contrast Saturation Hue\dots}
|
Ajustement \textsl{Brightness Contrast Saturation Hue\dots}
|
||||||
|
|
||||||
|
Probablement pilotable au joystick\index{joystick} et surtout
|
||||||
|
par OSC (Open Sound Control).
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
\section{À l'extérieur}
|
\section{À l'extérieur}
|
||||||
|
|
||||||
Il existe une foultitude de logiciels (composants ou end-yuser) et
|
Il existe une foultitude de logiciels (composants ou end-yuser) et
|
||||||
il est souvent nécessaire de pouvoir comminiquer facilement
|
il est souvent nécessaire de pouvoir communiquer facilement
|
||||||
avec eux.
|
avec eux. Nous avons déja quelques possibilité d'exportation,
|
||||||
|
mais passer par cette étape intermédiaire est parfois délicat
|
||||||
|
à gérer dans un \textsl{pipedeprod} autrement bien huilé.
|
||||||
|
De même, nos capacités d'importation sont vraiment trop
|
||||||
|
réduites, Jpeg et PNG étant les deux priorités.
|
||||||
|
|
||||||
\subsection{ImageMagick}\index{ImageMagick}
|
\subsection{ImageMagick}\index{ImageMagick}
|
||||||
|
|
||||||
Pour afficher notre format .fimg exotique avec \texttt{display}, vous
|
Pour afficher notre format .fimg exotique avec \texttt{display}, un
|
||||||
|
des éléments du package ImageMagick, 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}~:
|
||||||
|
|
||||||
@@ -1581,17 +1653,20 @@ devez mettre ce bout de XML\index{XML} dans le fichier
|
|||||||
\end{lstlisting}
|
\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 \texttt{identify}\index{identify},
|
||||||
|
qui a tendance à
|
||||||
raconter un peu n'importe quoi, puisqu'elle se base sur le
|
raconter un peu n'importe quoi, puisqu'elle se base sur le
|
||||||
résultat de la conversion\dots
|
résultat de la conversion.
|
||||||
Je compte donc sur le bouquin de \textsl{Brunus} pour avancer\dots
|
Je compte donc sur le bouquin de \textsl{Brunus}\index{Brunus}
|
||||||
|
pour avancer\dots
|
||||||
|
|
||||||
\subsection{Gimp}\index{Gimp}
|
\subsection{Gimp}\index{Gimp}
|
||||||
|
|
||||||
Mmmmm... Ça semble un peu plus compliqué.
|
Mmmmm... Ça semble un peu plus compliqué.
|
||||||
La documentation à ce sujet me semble ésotérique.
|
La documentation à ce sujet me semble ésotérique.
|
||||||
D'un autre coté, il
|
D'un autre coté, il
|
||||||
faut faire ça en \textbf{C}, ce qui ne peut pas être négatif.
|
faut faire ça en \textbf{C}, ce qui ne peut pas être totalement négatif.
|
||||||
|
Sauf pour les riiRistes.
|
||||||
|
|
||||||
\subsection{ffmpeg}\index{ffmpeg}
|
\subsection{ffmpeg}\index{ffmpeg}
|
||||||
|
|
||||||
@@ -1604,60 +1679,182 @@ ffmpeg -nostdin \
|
|||||||
-c:v libx264 \
|
-c:v libx264 \
|
||||||
-pix_fmt yuv420p \
|
-pix_fmt yuv420p \
|
||||||
-tune film \
|
-tune film \
|
||||||
|
-metadata artist='---[ tTh ]---' \
|
||||||
|
-metadata title='awesome video' \
|
||||||
stereo.mp4
|
stereo.mp4
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
|
||||||
|
Il existe environ un gazillion d'options pour encoder avec ffmpeg.
|
||||||
|
Bon courage pour toutes les explorer, voire même juste les comprendre.
|
||||||
|
|
||||||
\subsection{Et encore ?}\index{krita}\index{geeqie}
|
\subsection{Et encore ?}\index{krita}\index{geeqie}
|
||||||
|
|
||||||
Il y a d'autres logiciels pour lesquels écrire une fonction d'importation
|
Il y a d'autres logiciels pour lesquels écrire une fonction d'importation
|
||||||
serait bien~: \textsl{Geeqie}, un visualiseur d'image fort pratique, ou
|
serait bien~: \textsl{Geeqie}, un visualiseur d'image fort pratique, ou
|
||||||
\textsl{Krita} qui semble avoir les faveurs de
|
\textsl{Krita} qui semble avoir les faveurs de
|
||||||
dessinateurs de talent\footnote{Oui, David, c'est à toi que je pense.}.
|
dessinateurs de talent.
|
||||||
|
Ce qui nous conduit à une question importante~: quels sont les logiciels
|
||||||
|
qui gèrent le chargement d'image par un système de
|
||||||
|
\textsl{plugin}\index{plugin},
|
||||||
|
parce que recompiler tout Gimp juste pour ça, c'est un peu overkill.
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
\section{Le flou temporel}
|
\section{Le flou temporel}
|
||||||
|
|
||||||
Et si nous jouions sur l'axe du temps ?
|
\textit{\hspace{7em}Et si nous jouions sur l'axe du temps ?}
|
||||||
|
|
||||||
Nous avons plus ou moins la magie du cumul sur la prise de vue
|
Nous avons déja plus ou moins la magie du cumul sur la prise de vue
|
||||||
d'\textbf{image} en enchainant plusieurs capture d'image.
|
d'\textbf{image} en enchainant plusieurs captures d'image accumulées
|
||||||
|
en une seule.
|
||||||
Maintenant, voyons ce que l'on peut faire à partir de plusieurs images.
|
Maintenant, voyons ce que l'on peut faire à partir de plusieurs images.
|
||||||
On peut d'abord penser faire une moyenne (ou la somme, en fait) de toutes
|
On peut d'abord penser faire une moyenne (ou la somme, en fait) de toutes
|
||||||
ces images. Mais ce n'est qu'une façon déguisée de faire du cumul.
|
ces images. Mais ce n'est qu'une façon déguisée de faire du cumul.
|
||||||
C'est à ce moment que nous changeons l'axe de vue du défi.
|
C'est à ce moment que nous changeons l'axe de vue du défi.
|
||||||
|
|
||||||
Par ailleurs, il m'a semblé pertinent d'inclure dans le projet une
|
Par ailleurs, il m'a semblé pertinent d'inclure dans le projet une
|
||||||
foultitude d'effets spéciaux.
|
foultitude d'effets spéciaux%
|
||||||
|
\footnote{\textsl{aka} IBM\index{IBM} (image brotching module)}.
|
||||||
|
Qui manquent cruellement de possibilités de paramétrage.
|
||||||
|
Mais peuvent être enchainés dans ce que j'appelle des
|
||||||
|
\textsl{filter-chains}~: ces effets seront appliqués dans
|
||||||
|
l'ordre aux image traitées soit en entrée soit en sortie.
|
||||||
|
Je pense qu'un schéma\footnote{omg, apprendre un nouveau truc en
|
||||||
|
\LaTeX, quel challenge étourdissant !} s'impose.
|
||||||
|
|
||||||
\subsection{\textsl{moving average}}
|
|
||||||
|
|
||||||
\texttt{./fonderie} : Basé sur la moyenne mobile, avec une structure de
|
\subsection{\texttt{./fonderie} : \textsl{moving average}}
|
||||||
|
|
||||||
|
Basé sur la moyenne mobile, avec une structure de
|
||||||
fifo\index{fifo} particulièrement mal conçue.
|
fifo\index{fifo} particulièrement mal conçue.
|
||||||
|
Qui, en fait, n'est pas vraiment un fifo, mais plutôt un buffer
|
||||||
|
circulaire. Pour chaque image source, elle est lue, passe dans la chaine de
|
||||||
|
filtre d'entrée et est insérée dans ce buffer.
|
||||||
|
Ensuite on calcule la moyenne des images contenues dans ce buffer.
|
||||||
|
Et pour conclure, cette image moyennée passe au travers de la
|
||||||
|
chaine de filtre de sortie, avant d'être enregistrée en PNG\index{PNG}
|
||||||
|
dans le répertoire de destination.
|
||||||
|
|
||||||
|
\begin{verbatim}
|
||||||
|
*** fonderie compiled Jan 23 2023, 10:43:56, pid 23366
|
||||||
|
options:
|
||||||
|
-E input:filter:chain
|
||||||
|
-F output:filter:chain
|
||||||
|
-I input glob pattern
|
||||||
|
-L list available filters
|
||||||
|
-O output directory
|
||||||
|
-T fifo size
|
||||||
|
-v increase verbosity
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
Euh, c'est quoi un '\textsl{input glob pattern}' ?
|
||||||
|
|
||||||
|
C'est ce qui vous permet
|
||||||
|
de sélectionner un peu les images que vous voulez traiter, exactement
|
||||||
|
comme vous pourriez le faire avec un shell classique.
|
||||||
|
Par exemple pour choisir une image sur dix, le glob-pattern sera
|
||||||
|
'\texttt{frames/????0.fimg}', et vous trouverez les explications détaillées
|
||||||
|
dans le manuel~: \texttt{glob(7)}, et \texttt{glob(3)} pour la
|
||||||
|
fonction utilisée.
|
||||||
|
|
||||||
|
% -------------------------------------------------------------------
|
||||||
|
|
||||||
\subsection{Interpolator}\index{interpolator}
|
\subsection{Interpolator}\index{interpolator}
|
||||||
|
|
||||||
Juste des calculs pas si simple que ça.
|
Pour le moment, juste des calculs pas si simple que ça.
|
||||||
|
Je pense qu'il faudra
|
||||||
|
se lancer dans des calculs splinesques pour améliorer les choses dans
|
||||||
|
la création des images intermédiaires.
|
||||||
|
Voyons d'abord le principe actuel.
|
||||||
|
|
||||||
|
Nous avons une série de centaines, voire de milliers, de photos.
|
||||||
|
En parcourant cette liste, nous allons en prélever une sur $N$,
|
||||||
|
et entre celle-ci et la
|
||||||
|
précédente prélevée, nous allons calculer par interpolation
|
||||||
|
\textbf{linéaire} $N - 1$ images intermédiaires, et les
|
||||||
|
intercaler entre nos deux sélections pour générer le
|
||||||
|
flux de sortie,
|
||||||
|
ce qui devrait nous donner un ralenti de bon aloi.
|
||||||
|
|
||||||
|
\begin{verbatim}
|
||||||
|
usage:
|
||||||
|
interpolator [options] <inglob> <outdir> <nbsteep>
|
||||||
|
options:
|
||||||
|
-E i:bla:k input filter chain
|
||||||
|
-F name:j output filter chain
|
||||||
|
-n make negative
|
||||||
|
-S nn mysterious sort
|
||||||
|
-L list available filters
|
||||||
|
-v increase verbosity
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
L'option « mysterious sort » mérite bien son nom. Cette friture a
|
||||||
|
été écrite il y a bien longtemps pour un projet précis, et les
|
||||||
|
résultats ont été décevants. Je pense qu'il est toxique de
|
||||||
|
l'utiliser pour le moment\footnote{Ou le repenser différent ?}.
|
||||||
|
|
||||||
|
% -------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
\subsection{Singlepass}
|
\subsection{Singlepass}
|
||||||
|
|
||||||
Ce programme \texttt{singlepass} prétend vous permettre de tester
|
Ce programme \texttt{singlepass} prétend vous permettre de tester
|
||||||
tous les filtres disponibles, dont on peut avoir la liste
|
tous les filtres disponibles, et dont on peut avoir la liste
|
||||||
avec l'option \texttt{-L}\footnote{liste hélas peu machinable.}
|
avec l'option \texttt{-L}\footnote{liste hélas peu machinable.}
|
||||||
|
|
||||||
\subsection{Déviance}
|
\begin{verbatim}
|
||||||
|
usage:
|
||||||
|
-F define:the:filter:chain
|
||||||
|
-g input glob pattern
|
||||||
|
-L list available filters
|
||||||
|
-O /output/directory (default ./p8)
|
||||||
|
-r N repetiiing factor
|
||||||
|
-v spit more messages
|
||||||
|
\end{verbatim}
|
||||||
|
|
||||||
|
Il n'y a pas de moyenne mobile, pas d'interpolation, mais un facteur de
|
||||||
|
répétition qui permet de dupliquer $N$ fois une image dans le flux de
|
||||||
|
sortie. Si vous globez \texttt{rush/????[02468]}, vous prenez
|
||||||
|
en compte une image sur deux de la séquence capturée,
|
||||||
|
alors un facteur de répétition à $2$ conservera
|
||||||
|
la 'vitesse' de la séquence, mais avec une petite saccade régulière
|
||||||
|
de bon aloi \textit{:)}
|
||||||
|
|
||||||
|
% -------------------------------------------------------------------
|
||||||
|
|
||||||
|
\subsection{Déviance dans le flou ?}
|
||||||
|
|
||||||
Là, nous tombons dans de la \textsl{troiD}\index{3d} de haut niveau,
|
Là, nous tombons dans de la \textsl{troiD}\index{3d} de haut niveau,
|
||||||
avec plein de maths compliquées
|
avec plein de maths compliquées à l'intérieur.
|
||||||
à l'intérieur.
|
|
||||||
Et surtout quelque chose qui n'est encore qu'une idée abstraite,
|
Et surtout quelque chose qui n'est encore qu'une idée abstraite,
|
||||||
mais il y aura du zbuffer dedans.
|
mais il y aura du zbuffer\index{zbuffer} dedans.
|
||||||
|
|
||||||
|
% ===================================================================
|
||||||
|
|
||||||
|
\section{Expérimentations} \index{experimental}
|
||||||
|
|
||||||
|
Il m'arrive parfois d'avoir de vagues idées d'image, et donc de logiciel,
|
||||||
|
qui tournent dans un coin de la tête.
|
||||||
|
Parfois je songe à une fonction qui me
|
||||||
|
serait bien utile, mais j'ai des doutes sur son
|
||||||
|
\textsc{api}\footnote{Application Programming Interface}\index{api}
|
||||||
|
qui soit à la fois simple et complète. Je fais donc des essais.
|
||||||
|
Parfois j'imagine confusément un algorithme\index{algorithme} tordu
|
||||||
|
et sans but précis. Je le \textit{runne} et je le \textit{re-runne}
|
||||||
|
un gazillion de fois dans mon cerveau processique.
|
||||||
|
Quel va être son facteur $O$ ? Je fais donc des essais.
|
||||||
|
|
||||||
|
\subsection{movepixels}
|
||||||
|
|
||||||
|
\subsection{muxplanes}
|
||||||
|
|
||||||
% ===================================================================
|
% ===================================================================
|
||||||
|
|
||||||
\section{Et pour la suite ?}
|
\section{Et pour la suite ?}
|
||||||
|
|
||||||
En fait, je fait de la photo par la méthode du « cumul »\index{cumul}
|
En fait, je fait de la photo par la méthode du « cumul »\index{cumul}
|
||||||
depuis plusieurs années. Une webcam\index{webcam},
|
depuis plusieurs années, au début avec vgrabbj et convert,
|
||||||
|
puis avec floatimg et ses satellites.
|
||||||
|
Une webcam\index{webcam},
|
||||||
un Linux\index{Linux}, et ça \textsl{juste marche}.
|
un Linux\index{Linux}, et ça \textsl{juste marche}.
|
||||||
Sauf que c'est quand même un peu galère à déplacer, il faut
|
Sauf que c'est quand même un peu galère à déplacer, il faut
|
||||||
avoir un shell pour déclencher, c'est pas facile à utiliser
|
avoir un shell pour déclencher, c'est pas facile à utiliser
|
||||||
@@ -1666,8 +1863,9 @@ en mode portnawak\dots
|
|||||||
L'idée est donc de construire un appareil autonome, basé sur un Raspi et
|
L'idée est donc de construire un appareil autonome, basé sur un Raspi et
|
||||||
une webcam \textsc{usb}\index{USB}, pilotable par \textsc{lirc}\index{LIRC},
|
une webcam \textsc{usb}\index{USB}, pilotable par \textsc{lirc}\index{LIRC},
|
||||||
alimenté par une (grosse) batterie et permettant d'aller
|
alimenté par une (grosse) batterie et permettant d'aller
|
||||||
faire des images au bord d'un lac ou dans la campagne de l'Ariège.
|
faire des images au bord d'un lac ou dans la campagne du Gers%
|
||||||
Et, comme le dit la sagesse populaire : « fimg at 11 ».
|
\footnote{Aux Bourtoulots, par exemple.}.
|
||||||
|
Et comme le dit la sagesse populaire : « fimg at 11 ».
|
||||||
|
|
||||||
% -------------------------------------------------------------------
|
% -------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
13
essai.c
13
essai.c
@@ -18,6 +18,8 @@ int verbosity;
|
|||||||
void fait_un_dessin(FloatImg *dessin)
|
void fait_un_dessin(FloatImg *dessin)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// fprintf(stderr, "je dessine dans %p\n", dessin);
|
||||||
|
|
||||||
fimg_draw_something(dessin);
|
fimg_draw_something(dessin);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +28,7 @@ void help(void)
|
|||||||
{
|
{
|
||||||
puts("Options :");
|
puts("Options :");
|
||||||
puts("\t-d WxH\timage size");
|
puts("\t-d WxH\timage size");
|
||||||
|
puts("\t-v\tincrease verbosity");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
@@ -57,19 +60,19 @@ fimg_drand48(&fimgB, 100.0);
|
|||||||
foo = fimg_dump_to_file(&fimgB, "B.fimg", 0);
|
foo = fimg_dump_to_file(&fimgB, "B.fimg", 0);
|
||||||
|
|
||||||
fimg_timer_set(0);
|
fimg_timer_set(0);
|
||||||
#define NBP 500
|
#define NBP 5
|
||||||
for (foo=0; foo<NBP; foo++) {
|
for (foo=0; foo<NBP; foo++) {
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
printf("%5d / %5d\n", foo, NBP);
|
printf("%5d / %5d\n", foo, NBP);
|
||||||
}
|
}
|
||||||
fait_un_dessin(&fimgB);
|
fait_un_dessin(&fimgB);
|
||||||
fimg_add_3(&fimgA, &fimgB, &fimgA);
|
fimg_add_3(&fimgA, &fimgB, &fimgA);
|
||||||
// fimg_mul(&fimgA, &fimgB, &fimgA);
|
// fimg_mul(&fimgA, &fimgB, &fimgA);
|
||||||
}
|
}
|
||||||
tb = fimg_timer_get(0);
|
tb = fimg_timer_get(0);
|
||||||
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
fprintf(stderr, "%s = %.2f seconds, %.2f s/p\n", __func__, tb, tb/(double)NBP);
|
||||||
foo = fimg_save_as_pnm(&fimgA, "drand48.pnm", 0);
|
foo = fimg_save_as_pnm(&fimgA, "out.pnm", 0);
|
||||||
foo = fimg_dump_to_file(&fimgA, "drand48.fimg", 0);
|
foo = fimg_dump_to_file(&fimgA, "out.fimg", 0);
|
||||||
|
|
||||||
fimg_destroy(&fimgA);
|
fimg_destroy(&fimgA);
|
||||||
fimg_destroy(&fimgB);
|
fimg_destroy(&fimgB);
|
||||||
|
|||||||
14
experiment/.gitignore
vendored
Normal file
14
experiment/.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
*.fimg
|
||||||
|
*.o
|
||||||
|
*.pnm
|
||||||
|
*.data
|
||||||
|
|
||||||
|
assemblage
|
||||||
|
extracteur
|
||||||
|
fimg2obj
|
||||||
|
mnt
|
||||||
|
movepixels
|
||||||
|
muxplanes
|
||||||
|
tcache
|
||||||
@@ -3,28 +3,31 @@
|
|||||||
# some ugly experiments, do not use in production
|
# some ugly experiments, do not use in production
|
||||||
#
|
#
|
||||||
|
|
||||||
COPT = -Wall -Wextra -fpic -g -DDEBUG_LEVEL=1 -lm
|
COPT = -Wall -Wextra -fpic -g -DDEBUG_LEVEL=0 -lm
|
||||||
DEPS = ../floatimg.h ../libfloatimg.a Makefile
|
DEPS = ../floatimg.h ../libfloatimg.a Makefile
|
||||||
LIBS = ../libfloatimg.a -ltiff -lpnglite -lcfitsio -lm
|
LIBS = ../libfloatimg.a -ltiff -lpnglite -lcfitsio -lm
|
||||||
|
|
||||||
all: assemblage extracteur muxplanes movepixels
|
all: assemblage muxplanes movepixels mnt
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
assemblage: assemblage.c ${DEPS}
|
assemblage: assemblage.c ${DEPS}
|
||||||
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
|
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
|
||||||
|
|
||||||
extracteur: extracteur.c ${DEPS}
|
|
||||||
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
|
|
||||||
|
|
||||||
muxplanes: muxplanes.c ${DEPS}
|
muxplanes: muxplanes.c ${DEPS}
|
||||||
gcc $(COPT) $< ${LIBS} -o $@
|
gcc $(COPT) $< ${LIBS} -o $@
|
||||||
|
|
||||||
movepixels: movepixels.c ${DEPS}
|
movepixels: movepixels.c ${DEPS}
|
||||||
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
|
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
|
||||||
|
|
||||||
|
mnt: mnt.c ${DEPS}
|
||||||
|
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
|
||||||
|
|
||||||
|
fimg2obj: fimg2obj.c $(DEPS)
|
||||||
|
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# CACHE ENGINE
|
# CACHE ENGINE (wip)
|
||||||
|
|
||||||
cachengn.o: cachengn.c cachengn.h Makefile
|
cachengn.o: cachengn.c cachengn.h Makefile
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# EXPÉRIMENTATIONS ÀLC
|
# Expérimentations ÀLC
|
||||||
|
|
||||||
Attention, tout ce qui se trouve dans ce répertoire ne sont que des
|
Attention, tout ce qui se trouve dans ce répertoire ne sont que des
|
||||||
essais. Certains aboutissent, et sont migrés vers `funcs/` ou
|
essais. Certains aboutissent, et sont migrés vers `lib/`, `funcs/` ou
|
||||||
`tools/`, d'autre échouent et restent trainer dans le coin en attente
|
`tools/`, d'autre échouent et restent trainer dans le coin en attente
|
||||||
du retour de l'inspiration.
|
du retour de l'inspiration.
|
||||||
|
|
||||||
@@ -9,4 +9,21 @@ Le contenu de ce répertoire doit donc être considéré comme
|
|||||||
**volatile**. Si vous y trouvez votre bonheur, il serait sage
|
**volatile**. Si vous y trouvez votre bonheur, il serait sage
|
||||||
d'en faire une copie personnelle...
|
d'en faire une copie personnelle...
|
||||||
|
|
||||||
|
## MNT
|
||||||
|
|
||||||
|
Modèles numériques de terrain. Rien ne marche. Plein de maths.
|
||||||
|
Un [code](mnt.c) complexe.
|
||||||
|
|
||||||
|
## fimg2obj
|
||||||
|
|
||||||
|
Création d'un fichier .OBJ (de Wavefront) à partir d'une image
|
||||||
|
flottante afin d'avoir des vues en 3d pertinentes, bien qu'assez
|
||||||
|
futiles.
|
||||||
|
|
||||||
|
## système de cache
|
||||||
|
|
||||||
|
`new: Mon Jul 17 12:49:20 UTC 2023`
|
||||||
|
|
||||||
|
En cours : définition d'à peu-près tout ce qu'il reste à faire
|
||||||
|
pour avoir quelque chose qui fonctionne.
|
||||||
|
Plus d'information dans le [.h](cachengn.h).
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ if (foo) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foo = fimg_export_picture(&grande, outname, 0);
|
foo = fimg_export_picture(&grande, outname, 0);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: error %d export '%s'\n", __func__,
|
fprintf(stderr, "%s: error %d export '%s'\n", __func__,
|
||||||
|
|||||||
@@ -3,23 +3,143 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
#include "cachengn.h"
|
#include "cachengn.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
static int nombre_slots = -1;
|
||||||
|
static int index_slot = -1;
|
||||||
|
static FimgCacheEntry *le_cache = NULL;
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
||||||
void cachengn_print_version(int k)
|
void cachengn_print_version(int k)
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("this is the version ZERO !!!\n");
|
printf("\t!!! this is the version ZERO !!!\n");
|
||||||
|
|
||||||
|
fprintf(stderr, "sizeof cache entry: %ld\n", sizeof(FimgCacheEntry));
|
||||||
|
|
||||||
|
if (k) fimg_print_version(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
int init_empty_cache(int iw, int ih, int szc, int nbre)
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int init_empty_cache(int iw, int ih, int szc, int wtfparam)
|
||||||
{
|
{
|
||||||
return -1;
|
int idx;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %d %d %d %d )\n", __func__,
|
||||||
|
iw, ih, szc, wtfparam);
|
||||||
|
|
||||||
|
/* MOLLYGUARD : don't init TWICE, please */
|
||||||
|
if (NULL != le_cache) {
|
||||||
|
fprintf(stderr, "%s: there is a cache at %p\n", __func__,
|
||||||
|
le_cache);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate an prepare memory */
|
||||||
|
if ( NULL==(le_cache=calloc(szc, sizeof(FimgCacheEntry))) ) {
|
||||||
|
fprintf(stderr, "%s: no memory, sorry...\n", __func__);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
fprintf(stderr, " slot array at %p\n", le_cache);
|
||||||
|
for (idx=0; idx<szc; idx++) {
|
||||||
|
le_cache[idx].flags = 0xF0;
|
||||||
|
le_cache[idx].index = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update private cache metadata */
|
||||||
|
nombre_slots = szc;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
FloatImg *give_me_thiz_picz(char *fname, int notused)
|
||||||
|
{
|
||||||
|
int idx, foo, freeslot;
|
||||||
|
FloatImg img;
|
||||||
|
char *nptr;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
||||||
|
|
||||||
|
/* please add molly guard ! */
|
||||||
|
|
||||||
|
if (notused)
|
||||||
|
fprintf(stderr, "in %s, notused was %d\n", __func__, notused);
|
||||||
|
|
||||||
|
/* is the floatimg already in the cahce ? */
|
||||||
|
for (idx=0; idx<nombre_slots; idx++) {
|
||||||
|
nptr = le_cache[idx].filename;
|
||||||
|
if (NULL!=nptr && (! strcmp(fname, nptr))) {
|
||||||
|
fprintf(stderr, "found '%s' at %d\n", nptr, idx);
|
||||||
|
return le_cache[idx].image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we not have this picture in our cache, so we need a free
|
||||||
|
slot for it */
|
||||||
|
freeslot = -1;
|
||||||
|
for (idx=0; idx<nombre_slots; idx++) {
|
||||||
|
if (NULL==le_cache[idx].image) {
|
||||||
|
freeslot = idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "freeslot = %d\n", freeslot);
|
||||||
|
|
||||||
|
/* check if we can read this file */
|
||||||
|
foo = access(fname, R_OK); /* XXX */
|
||||||
|
if (foo) {
|
||||||
|
perror("give_me_thiz_picz");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "file '%s' is readble\n", fname);
|
||||||
|
|
||||||
|
/* try to load the requested file */
|
||||||
|
foo = fimg_create_from_dump(fname, &img);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "oups on %s\n", fname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* OK, we have all the pixels in core memory */
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int liste_le_cache(unsigned int flags)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( Ox%X )\n", __func__, flags);
|
||||||
|
|
||||||
|
/* please add molly guard here */
|
||||||
|
|
||||||
|
fprintf(stderr, "cache at %p : %d slots, idx = %d\n",
|
||||||
|
le_cache, nombre_slots, index_slot);
|
||||||
|
|
||||||
|
for (idx=0; idx<nombre_slots; idx++) {
|
||||||
|
fprintf(stderr, "%5d ", idx);
|
||||||
|
fprintf(stderr, "0x%02x ", le_cache[idx].flags);
|
||||||
|
fprintf(stderr, "%p ", le_cache[idx].image);
|
||||||
|
fprintf(stderr, "%s\n", le_cache[idx].filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|||||||
@@ -4,4 +4,26 @@
|
|||||||
|
|
||||||
void cachengn_print_version(int k);
|
void cachengn_print_version(int k);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int flags;
|
||||||
|
char *filename;
|
||||||
|
FloatImg *image;
|
||||||
|
int index;
|
||||||
|
} FimgCacheEntry;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parameters:
|
||||||
|
* - iw, ik : image size
|
||||||
|
* - szc : number of slots
|
||||||
|
* - nbre : WTF isthat?
|
||||||
|
*/
|
||||||
int init_empty_cache(int iw, int ih, int szc, int nbre);
|
int init_empty_cache(int iw, int ih, int szc, int nbre);
|
||||||
|
|
||||||
|
|
||||||
|
/* /!\ the floatimg returned must be view as readonly */
|
||||||
|
FloatImg *give_me_thiz_picz(char *fname, int notused);
|
||||||
|
|
||||||
|
|
||||||
|
/* utilities functions */
|
||||||
|
int liste_le_cache(unsigned int flags);
|
||||||
|
|||||||
@@ -1,132 +0,0 @@
|
|||||||
/*
|
|
||||||
* another ugly experiment
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "../floatimg.h"
|
|
||||||
|
|
||||||
int verbosity;
|
|
||||||
|
|
||||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
|
||||||
|
|
||||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
|
||||||
int essai_extraction(FloatImg *in, FloatImg *out, FimgArea51 *rect)
|
|
||||||
{
|
|
||||||
int foo;
|
|
||||||
int xs, ys, xd, yd;
|
|
||||||
int count;
|
|
||||||
float rgb[3];
|
|
||||||
|
|
||||||
if (verbosity) {
|
|
||||||
fimg_describe(in, "source");
|
|
||||||
fimg_describe(out, "destination");
|
|
||||||
print_rectangle((char *)__func__, rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
for (yd=0; yd<rect->h; yd++) {
|
|
||||||
ys = yd + rect->y;
|
|
||||||
if ((ys<0) || (ys>=in->height)) continue;
|
|
||||||
for (xd=0; xd<rect->w; xd++) {
|
|
||||||
xs = xd + rect->x;
|
|
||||||
if ((xs<0) || (xs>=in->width)) continue;
|
|
||||||
fimg_get_rgb(in, xs, ys, rgb);
|
|
||||||
fimg_put_rgb(out, xd, yd, rgb);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fprintf(stderr, "%s: %d pix moved\n", __func__, count);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
|
||||||
void help(int k)
|
|
||||||
{
|
|
||||||
puts("Usage:\n\textracteur in.fimg w,h,x,y out.???");
|
|
||||||
}
|
|
||||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int foo, opt;
|
|
||||||
FloatImg src, dst;
|
|
||||||
FimgArea51 zone;
|
|
||||||
char *infile = "foo.fimg";
|
|
||||||
char *outfile = "out.fimg";
|
|
||||||
|
|
||||||
verbosity = 0;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
for (foo=0; foo<argc; foo++) {
|
|
||||||
fprintf(stderr, "%9d %s\n", foo, argv[foo]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, "*** Extracteur %s %s\n", __DATE__, __TIME__);
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
|
||||||
switch(opt) {
|
|
||||||
case 'h': help(0), exit(0); break;
|
|
||||||
case 'v': verbosity++; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (3 != argc-optind) {
|
|
||||||
fprintf(stderr, "---- %s errcli c=%d %d ----\n", argv[0],
|
|
||||||
argc, argc-optind);
|
|
||||||
help(1);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbosity) {
|
|
||||||
fprintf(stderr, "*** %s %s %s\n", argv[0], __DATE__, __TIME__);
|
|
||||||
fimg_print_version(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
infile = argv[optind]; outfile = argv[optind+2];
|
|
||||||
fprintf(stderr, "%s %s -> %s\n", argv[0], infile, outfile);
|
|
||||||
|
|
||||||
foo = fimg_create_from_dump(infile, &src);
|
|
||||||
if (foo) {
|
|
||||||
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
|
|
||||||
foo, infile);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (4 != parse_rectangle( argv[optind+1], &zone, 0) ) {
|
|
||||||
fprintf(stderr, "%s: error in parsing of '%s'\n",
|
|
||||||
argv[0], argv[optind+1]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// zone.w = src.width / 2; zone.h = src.height / 2;
|
|
||||||
// zone.x = src.width / 4 ; zone.y = src.height / 4;
|
|
||||||
|
|
||||||
if (verbosity) print_rectangle(argv[0], &zone);
|
|
||||||
|
|
||||||
foo = fimg_create(&dst, zone.w, zone.h, FIMG_TYPE_RGB);
|
|
||||||
if (foo) {
|
|
||||||
fprintf(stderr, "NO PICZ EPIC FAIL %d\n", foo);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
foo = fimg_extractor(&src, &dst, &zone);
|
|
||||||
if (foo) {
|
|
||||||
fprintf(stderr, "EXTRACTOR EPIC FAIL %d\n", foo);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
foo = fimg_export_picture(&dst, outfile, 0);
|
|
||||||
if (foo) {
|
|
||||||
fprintf(stderr, "export '%s' -> err %d\n", outfile, foo);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
|
||||||
67
experiment/fimg2obj.c
Normal file
67
experiment/fimg2obj.c
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* another ugly experiment
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||||
|
|
||||||
|
int convert_fimg_to_obj(char *fimgfname, char *objfname, int mode)
|
||||||
|
{
|
||||||
|
FloatImg src;
|
||||||
|
int foo, x, y;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
|
||||||
|
fimgfname, objfname, mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (mode) {
|
||||||
|
fprintf(stderr, "in %s(), mode must be 0, was %d\n", __func__, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(fimgfname, &src);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d loading %f\n", foo, fimgfname);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo, opt;
|
||||||
|
char *infile = "foo.fimg";
|
||||||
|
|
||||||
|
fprintf(stderr, "*** fimg2obj (%s %s)\n", __DATE__, __TIME__);
|
||||||
|
|
||||||
|
verbosity = 0;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (foo=0; foo<argc; foo++) {
|
||||||
|
fprintf(stderr, "%9d %s\n", foo, argv[foo]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foo = convert_fimg_to_obj(infile, "foo.obj", 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "convertor give us %d\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
|
||||||
239
experiment/mnt.c
Normal file
239
experiment/mnt.c
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
/*
|
||||||
|
* Modeles Numeriques de Terrain -- UGLY CODE INSIDE !!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------- */
|
||||||
|
/* for debug purpose */
|
||||||
|
int printf_histo_gray(char *fname, int histo[], int nbre)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__,
|
||||||
|
fname, histo, nbre);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (NULL == (fp = fopen(fname, "w"))) {
|
||||||
|
perror(fname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
for (idx=0; idx<nbre; idx++) {
|
||||||
|
fprintf(fp, "%6d %8d\n", idx, histo[idx]);
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/* ------------------------------------------------------------------- */
|
||||||
|
/* for debug purpose */
|
||||||
|
int calcul_histo_gray(FloatImg *img, char *fname, int nbslots, float *pmax)
|
||||||
|
{
|
||||||
|
int offset, nbpix, ival;
|
||||||
|
float pixel, minp, maxp;
|
||||||
|
int *counts;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p '%s' %d )\n", __func__,
|
||||||
|
img, fname, nbslots);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (FIMG_TYPE_GRAY != img->type) {
|
||||||
|
fprintf(stderr, "%s: image is not in greylevel\n", __func__);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate memory for histogram computation */
|
||||||
|
counts = calloc(nbslots, sizeof(int));
|
||||||
|
if (NULL == counts) {
|
||||||
|
fprintf(stderr, "malloc fail in %s\n", __func__);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
nbpix = img->width * img->height;
|
||||||
|
minp = 1e30, maxp = -1e30;
|
||||||
|
|
||||||
|
for (offset=0; offset<nbpix; offset++) {
|
||||||
|
pixel = img->R[offset];
|
||||||
|
if (pixel < minp) minp = pixel;
|
||||||
|
if (pixel > maxp) maxp = pixel;
|
||||||
|
}
|
||||||
|
// fprintf(stderr, " values = %g < %g\n", minp, maxp);
|
||||||
|
|
||||||
|
*pmax = maxp; /* copy value for the caller */
|
||||||
|
|
||||||
|
/* calcul de l'histogramme avec scaling */
|
||||||
|
for (offset=0; offset<nbpix; offset++) {
|
||||||
|
pixel = img->R[offset];
|
||||||
|
ival = (int)((pixel * (float)nbslots) / maxp);
|
||||||
|
counts[ival]++;
|
||||||
|
// fprintf(stderr, "%6d %10.6f %i\n", offset, pixel, ival);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != fname)
|
||||||
|
{
|
||||||
|
printf_histo_gray(fname, counts, nbslots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* garbage collect stuff */
|
||||||
|
free(counts);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* Second try - ahem?
|
||||||
|
*/
|
||||||
|
int brotche_mnt_style(FloatImg *src, FloatImg *dst)
|
||||||
|
{
|
||||||
|
FloatImg tmp;
|
||||||
|
int x, y, foo;
|
||||||
|
int offset;
|
||||||
|
float z1, z2, z3, z4;
|
||||||
|
float a, b, c;
|
||||||
|
float pente, minp, maxp, seuil;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* trying some preprocessor filters
|
||||||
|
*/
|
||||||
|
foo = fimg_lissage_3x3(src);
|
||||||
|
if (foo) fprintf(stderr, " lissage 1 -> %d\n", foo);
|
||||||
|
foo = fimg_lissage_3x3(src);
|
||||||
|
if (foo) fprintf(stderr, " lissage 2 -> %d\n", foo);
|
||||||
|
|
||||||
|
foo = fimg_killborders(src);
|
||||||
|
if (foo) fprintf(stderr, " killborder -> %d\n", foo);
|
||||||
|
|
||||||
|
#define W (src->width)
|
||||||
|
#define DX 1.0
|
||||||
|
#define DY 1.0
|
||||||
|
|
||||||
|
/* allocate a graylevel image for storing la 'pente' */
|
||||||
|
memset(&tmp, 0, sizeof(FloatImg));
|
||||||
|
foo = fimg_create(&tmp, src->width, src->height, FIMG_TYPE_GRAY);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "create tmp pic --> %d\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calcul de la pente : a vérifier ! */
|
||||||
|
for (y=0; y<(src->height-1); y++) {
|
||||||
|
for (x=0; x<(src->width-1); x++) {
|
||||||
|
offset = (y * W) + x;
|
||||||
|
z1 = src->R[offset];
|
||||||
|
z2 = src->R[offset+1];
|
||||||
|
z3 = src->R[offset+W];
|
||||||
|
z4 = src->R[offset+W+1];
|
||||||
|
a = ( z1 + z2 + z3 + z4) / 4.0;
|
||||||
|
b = (-z1 + z2 - z3 + z4) / 2.0 / DX;
|
||||||
|
c = (-z1 - z2 + z3 + z4) / 2.0 / DY;
|
||||||
|
pente = atanf(sqrt(b*b + c*c));
|
||||||
|
tmp.R[offset] = pente;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = calcul_histo_gray(&tmp, "histogramme.data", 499, &maxp);
|
||||||
|
if (foo) fprintf(stderr, "<<< calcul histo -> %d\n", foo);
|
||||||
|
|
||||||
|
minp = 1e10;
|
||||||
|
seuil = 0.700 * maxp;
|
||||||
|
fprintf(stderr, " seuil = %f\n", seuil);
|
||||||
|
|
||||||
|
/* ésotérisme, quand tu nous tiens... */
|
||||||
|
for (offset=0; offset<(src->width*src->height); offset++) {
|
||||||
|
pente = tmp.R[offset];
|
||||||
|
if (pente > seuil) {
|
||||||
|
if (pente < minp) minp = pente;
|
||||||
|
}
|
||||||
|
if (pente > maxp) maxp = pente;
|
||||||
|
}
|
||||||
|
// fprintf(stderr, " minp = %f maxp = %f\n", minp, maxp);
|
||||||
|
|
||||||
|
/* recopie dans l'image destination avec translation hauteur */
|
||||||
|
fimg_clear(dst);
|
||||||
|
for (offset=0; offset<(src->width*src->height); offset++) {
|
||||||
|
pente = tmp.R[offset] - minp;
|
||||||
|
if (pente < 0.0) {
|
||||||
|
dst->R[offset] = -pente;
|
||||||
|
dst->G[offset] = -pente;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dst->B[offset] = pente;
|
||||||
|
dst->G[offset] = pente;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_killborders(dst);
|
||||||
|
if (foo) fprintf(stderr, " killborder -> %d\n", foo);
|
||||||
|
|
||||||
|
/* clean the memory */
|
||||||
|
fimg_destroy(&tmp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ------------------------------------------------------------------- */
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
FloatImg src, dst;
|
||||||
|
char *infile, *outfile;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
verbosity = 1; /* FIXME */
|
||||||
|
|
||||||
|
if (3 != argc) {
|
||||||
|
fprintf(stderr, "'%s' need 2 args : infile & outfile\n", argv[0]);
|
||||||
|
fimg_print_version(0);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
infile = argv[1]; outfile = argv[2];
|
||||||
|
|
||||||
|
if (verbosity) fprintf(stderr,"*** MNT %s -> %s\n", infile, outfile);
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(infile, &src);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d loading image '%s'\n", foo, infile);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_clone(&src, &dst, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d cloning image\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
fimg_clear(&dst);
|
||||||
|
|
||||||
|
foo = brotche_mnt_style(&src, &dst);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "something weird happen %d\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&dst, outfile, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d exporting to %s\n", foo, outfile);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clean the memory */
|
||||||
|
fimg_destroy(&src);
|
||||||
|
fimg_destroy(&dst);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ------------------------------------------------------------------- */
|
||||||
@@ -65,12 +65,11 @@ for (yd=0; yd<pdst->height; yd++) {
|
|||||||
fimg_get_rgb(pshift, xd, yd, disp);
|
fimg_get_rgb(pshift, xd, yd, disp);
|
||||||
|
|
||||||
xs = xd + ((disp[0]/dltr*MULT) - OFFS);
|
xs = xd + ((disp[0]/dltr*MULT) - OFFS);
|
||||||
ys = yd + ((disp[2]/dltb*MULT) - OFFS);
|
ys = yd + ((disp[1]/dltb*MULT) - OFFS);
|
||||||
|
|
||||||
if ( xs<0 || xs>psrc->width ||
|
if ( xs<0 || xs>psrc->width ||
|
||||||
ys<0 || ys>psrc->height ) {
|
ys<0 || ys>psrc->height ) {
|
||||||
rgb[0] = maxv; /* fucking bug XXX */
|
rgb[0] = rgb[1] = rgb[2] = 0.0;
|
||||||
rgb[1] = rgb[2] = 0.0;
|
|
||||||
outside++;
|
outside++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -79,7 +78,6 @@ for (yd=0; yd<pdst->height; yd++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fimg_put_rgb(pdst, xd, yd, rgb);
|
fimg_put_rgb(pdst, xd, yd, rgb);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -89,7 +87,10 @@ for (yd=0; yd<pdst->height; yd++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* High level operateur, taking care of opening/closing
|
||||||
|
* files and doing memory management
|
||||||
|
*/
|
||||||
int move_the_pixels(char *infile, char *statfile, char *outfile, int k)
|
int move_the_pixels(char *infile, char *statfile, char *outfile, int k)
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
@@ -145,9 +146,10 @@ srcfile = argv[1];
|
|||||||
dstfile = argv[2];
|
dstfile = argv[2];
|
||||||
verbosity = 0;
|
verbosity = 0;
|
||||||
|
|
||||||
foo = move_the_pixels(srcfile, "cumul.fimg", dstfile, 3);
|
/* XXX the static picture file MUST be selectable by the yuser ! */
|
||||||
|
foo = move_the_pixels(srcfile, "reference.fimg", dstfile, 3);
|
||||||
|
|
||||||
// fprintf(stderr, "move pixels %s -> %s = %d\n", srcfile, dstfile, foo);
|
fprintf(stderr, "move pixels %s -> %s = %d\n", srcfile, dstfile, foo);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* another ugly experiment
|
* another ugly experiment (please explain)
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -14,9 +14,8 @@ int verbosity;
|
|||||||
/* --------------------------------------------------------------- */
|
/* --------------------------------------------------------------- */
|
||||||
|
|
||||||
int triplane_muxer(FloatImg *sr, FloatImg *sg, FloatImg *sb,
|
int triplane_muxer(FloatImg *sr, FloatImg *sg, FloatImg *sb,
|
||||||
FloatImg *dst, int flages)
|
FloatImg *dst)
|
||||||
{
|
{
|
||||||
int foo;
|
|
||||||
int sz;
|
int sz;
|
||||||
|
|
||||||
if (FIMG_TYPE_RGB != dst->type) {
|
if (FIMG_TYPE_RGB != dst->type) {
|
||||||
@@ -48,6 +47,10 @@ FloatImg imr, img, imb, dest;
|
|||||||
|
|
||||||
fprintf(stderr, "muxing: %s %s %s -> %s\n", fr, fg, fb, dst);
|
fprintf(stderr, "muxing: %s %s %s -> %s\n", fr, fg, fb, dst);
|
||||||
|
|
||||||
|
if (flags) {
|
||||||
|
fprintf(stderr, "%s: flag non 0 ?\n", __FILE__);
|
||||||
|
}
|
||||||
|
|
||||||
foo = fimg_create_from_dump(fr, &imr);
|
foo = fimg_create_from_dump(fr, &imr);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
|
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
|
||||||
@@ -55,18 +58,18 @@ if (foo) {
|
|||||||
}
|
}
|
||||||
foo = fimg_create_from_dump(fg, &img);
|
foo = fimg_create_from_dump(fg, &img);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
|
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
foo = fimg_create_from_dump(fb, &imb);
|
foo = fimg_create_from_dump(fb, &imb);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
|
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fb);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fimg_clone(&imr, &dest, 0);
|
fimg_clone(&imr, &dest, 0);
|
||||||
|
|
||||||
foo = triplane_muxer(&imr, &img, &imb, &dest, 0);
|
foo = triplane_muxer(&imr, &img, &imb, &dest);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: err %d\n", __func__, foo);
|
fprintf(stderr, "%s: err %d\n", __func__, foo);
|
||||||
return foo;
|
return foo;
|
||||||
|
|||||||
0
experiment/remotegrab.c
Normal file
0
experiment/remotegrab.c
Normal file
@@ -3,24 +3,45 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
#include "cachengn.h"
|
#include "cachengn.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
#define IMGW 320
|
#define IMGW 320
|
||||||
#define IMGH 240
|
#define IMGH 240
|
||||||
#define SIZE 20
|
|
||||||
|
#define SIZE 5 // number of slots
|
||||||
#define NBRI 1000
|
#define NBRI 1000
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
|
FloatImg *picz;
|
||||||
|
char *fname = "quux.fimg";
|
||||||
|
|
||||||
fprintf(stderr, "Test of the cache engin - %s %s\n", __DATE__, __TIME__);
|
fprintf(stderr, "\nTest of the cache engin - %s %s\n",
|
||||||
|
__DATE__, __TIME__);
|
||||||
cachengn_print_version(1);
|
cachengn_print_version(1);
|
||||||
|
|
||||||
foo = init_empty_cache(IMGW, IMGH, SIZE, NBRI);
|
foo = init_empty_cache(IMGW, IMGH, SIZE, NBRI);
|
||||||
fprintf(stderr, "init_empty_cache --> %d\n", foo);
|
fprintf(stderr, " init_empty_cache --> %d\n", foo);
|
||||||
|
|
||||||
|
foo = liste_le_cache((unsigned int)'U');
|
||||||
|
fprintf(stderr, " liste le cache --> %d\n", foo);
|
||||||
|
|
||||||
|
picz = give_me_thiz_picz(fname, 0);
|
||||||
|
if (NULL == picz) {
|
||||||
|
fprintf(stderr, " error 'givemeapicz' on '%s'\n", fname);
|
||||||
|
}
|
||||||
|
|
||||||
|
picz = give_me_thiz_picz(fname, 0);
|
||||||
|
if (NULL == picz) {
|
||||||
|
fprintf(stderr, " error 'givemeapicz' on '%s'\n", fname);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
70
floatimg.h
70
floatimg.h
@@ -20,13 +20,40 @@
|
|||||||
* https://git.tetalab.org/tTh/FloatImg
|
* https://git.tetalab.org/tTh/FloatImg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FIMG_VERSION (202)
|
#define FIMG_VERSION (245)
|
||||||
#define RELEASE_NAME ("noname")
|
#define RELEASE_NAME ("noname")
|
||||||
|
#define PATCH_LEVEL ("aaaa")
|
||||||
|
|
||||||
|
|
||||||
/* XXX add a test for stdint.h / uint32_t XXX */
|
/* XXX add a test for stdint.h / uint32_t XXX */
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* new 11 mars 2022, and a lot of iterations
|
||||||
|
* around the concept of metadata for my work.
|
||||||
|
*
|
||||||
|
* we MUST look at packing and endianess problems NOW
|
||||||
|
* and we can think about a fixed size of this datablock
|
||||||
|
*/
|
||||||
|
#define MAGIC_MDATA 0xfe007007
|
||||||
|
typedef struct {
|
||||||
|
uint32_t magic;
|
||||||
|
uint32_t padding;
|
||||||
|
|
||||||
|
struct timeval timestamp; // #include <stdlib.h>
|
||||||
|
uint64_t cpid; // process id of the creator
|
||||||
|
int32_t count;
|
||||||
|
float fval;
|
||||||
|
char idcam[32];
|
||||||
|
int32_t origin; // enum ?
|
||||||
|
uint32_t reserved[8];
|
||||||
|
} FimgMetaData;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in memory descriptor of a floating image
|
* in memory descriptor of a floating image
|
||||||
|
* ----------------------------------------
|
||||||
*/
|
*/
|
||||||
#define MAGIC_FIMG 0x00F11F00
|
#define MAGIC_FIMG 0x00F11F00
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -37,6 +64,7 @@ typedef struct {
|
|||||||
float fval;
|
float fval;
|
||||||
int count;
|
int count;
|
||||||
float *R, *G, *B, *A;
|
float *R, *G, *B, *A;
|
||||||
|
FimgMetaData mdatas; // added 20230912
|
||||||
int reserved;
|
int reserved;
|
||||||
} FloatImg;
|
} FloatImg;
|
||||||
|
|
||||||
@@ -44,33 +72,13 @@ typedef struct {
|
|||||||
* fimg file header (short version)
|
* fimg file header (short version)
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char magic[8]; // this is not an asciiz !
|
char magic[8]; /* this is not an asciiz ! */
|
||||||
int32_t w, h, t;
|
int32_t w, h, t;
|
||||||
/*
|
/*
|
||||||
* what about the packing ?
|
* what about the packing ?
|
||||||
*/
|
*/
|
||||||
} FimgFileHead;
|
} FimgFileHead;
|
||||||
|
|
||||||
/*
|
|
||||||
* new 11 mars 2022, and a lot of iterations
|
|
||||||
* around the concept of metadata for my work.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
char magic[8]; // this is not an asciiz !
|
|
||||||
struct timeval timestamp;
|
|
||||||
uint64_t cpid; // process id of the creator
|
|
||||||
int32_t count;
|
|
||||||
float fval;
|
|
||||||
char idcam[32];
|
|
||||||
int32_t origin; // enum ?
|
|
||||||
uint32_t reserved[8];
|
|
||||||
|
|
||||||
} FimgMetaData;
|
|
||||||
/*
|
|
||||||
* we MUST look at packing and endianess problems NOW
|
|
||||||
* and we can think about a fised size of this datablock
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define MAGIC_AREA51 0xA5EA0051
|
#define MAGIC_AREA51 0xA5EA0051
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -153,6 +161,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
int fimg_killborders(FloatImg *img);
|
int fimg_killborders(FloatImg *img);
|
||||||
int fimg_lissage_2x2(FloatImg *img);
|
int fimg_lissage_2x2(FloatImg *img);
|
||||||
|
int fimg_lissage_3x3(FloatImg *img);
|
||||||
int fimg_show_filter(char *title, FimgFilter3x3 *filtr);
|
int fimg_show_filter(char *title, FimgFilter3x3 *filtr);
|
||||||
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
|
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
|
||||||
|
|
||||||
@@ -174,14 +183,15 @@ int fimg_binarize(FloatImg *pimg, int notused);
|
|||||||
int fimg_trinarize(FloatImg *pimg, int notused);
|
int fimg_trinarize(FloatImg *pimg, int notused);
|
||||||
|
|
||||||
/* module sfx3.c */
|
/* module sfx3.c */
|
||||||
|
int fimg_make_rndfluffy_lines(FloatImg *src, FloatImg *dst, int rndt);
|
||||||
int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused);
|
int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused);
|
||||||
|
|
||||||
/* module sfx4.c */
|
/* module sfx4.c */
|
||||||
int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
|
int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
|
||||||
int fimg_split_level(FloatImg *src, FloatImg *dst, int notused);
|
int fimg_split_level(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
int fimg_make_triptyq(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
|
||||||
/* funcs/rotate.c module */
|
/* funcs/rotate.c module */
|
||||||
/* #coronamaison */
|
|
||||||
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
|
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
|
||||||
int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k);
|
int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k);
|
||||||
@@ -218,6 +228,11 @@ int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
|
|||||||
/* funcs/falsecolors.c */
|
/* funcs/falsecolors.c */
|
||||||
int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf);
|
int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf);
|
||||||
|
|
||||||
|
/* funcs/fmorpho.c */
|
||||||
|
int fimg_filtre_morpho_0(FloatImg *sfimg, FloatImg *dfimg, int index);
|
||||||
|
|
||||||
|
int fimg_auto_thermique(FloatImg *src, FloatImg *dst, int k);
|
||||||
|
|
||||||
/* --> funcs/plasmas.c */
|
/* --> funcs/plasmas.c */
|
||||||
int fimg_prototype_plasma(FloatImg *img, double time, int type);
|
int fimg_prototype_plasma(FloatImg *img, double time, int type);
|
||||||
|
|
||||||
@@ -245,7 +260,6 @@ int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused);
|
|||||||
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect);
|
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect);
|
||||||
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
|
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
|
||||||
|
|
||||||
|
|
||||||
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
|
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
|
||||||
int xpos, int ypos, int flags);
|
int xpos, int ypos, int flags);
|
||||||
|
|
||||||
@@ -254,7 +268,7 @@ int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
|
|||||||
/* module funcs/rampes.c */
|
/* module funcs/rampes.c */
|
||||||
int fimg_hdeg_a(FloatImg *img, double dcoef);
|
int fimg_hdeg_a(FloatImg *img, double dcoef);
|
||||||
int fimg_vdeg_a(FloatImg *img, double dcoef);
|
int fimg_vdeg_a(FloatImg *img, double dcoef);
|
||||||
int fimg_do_stripes(FloatImg *img, int mode);
|
int fimg_do_stripes(FloatImg *img, float fmax, int mode);
|
||||||
|
|
||||||
/* FIMG native file module */
|
/* FIMG native file module */
|
||||||
int fimg_fileinfos(char *fname, int *datas);
|
int fimg_fileinfos(char *fname, int *datas);
|
||||||
@@ -269,6 +283,9 @@ int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused);
|
|||||||
int fimg_default_metadata(FimgMetaData *pmd, int bla);
|
int fimg_default_metadata(FimgMetaData *pmd, int bla);
|
||||||
int fimg_get_metadata_from_file(char *fname, FimgMetaData *pmd);
|
int fimg_get_metadata_from_file(char *fname, FimgMetaData *pmd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FITS, an image fileformat for astronomy
|
||||||
|
*/
|
||||||
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
|
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
|
||||||
int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);
|
int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);
|
||||||
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
|
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
|
||||||
@@ -277,7 +294,6 @@ int fimg_save_plane_as_fits(FloatImg *src, char *oname, char plane, int flags);
|
|||||||
int fimg_write_as_tiff(FloatImg *src, char *fname, int flags);
|
int fimg_write_as_tiff(FloatImg *src, char *fname, int flags);
|
||||||
int fimg_save_as_exr(FloatImg *src, char *outname, int flags);
|
int fimg_save_as_exr(FloatImg *src, char *outname, int flags);
|
||||||
|
|
||||||
|
|
||||||
/* mathematics operations */
|
/* mathematics operations */
|
||||||
float fimg_get_plane_maxvalue(FloatImg *psrc, char plane);
|
float fimg_get_plane_maxvalue(FloatImg *psrc, char plane);
|
||||||
float fimg_get_maxvalue(FloatImg *head);
|
float fimg_get_maxvalue(FloatImg *head);
|
||||||
@@ -293,6 +309,8 @@ void fimg_drand48(FloatImg *fi, float kmul);
|
|||||||
long fimg_count_negativ(FloatImg *fi);
|
long fimg_count_negativ(FloatImg *fi);
|
||||||
long fimg_clamp_negativ(FloatImg *fi);
|
long fimg_clamp_negativ(FloatImg *fi);
|
||||||
|
|
||||||
|
int fimg_max_of_max(FloatImg *img, float maxes[3]);
|
||||||
|
|
||||||
/* various funcs modules */
|
/* various funcs modules */
|
||||||
int fimg_load_from_png(char *filename, FloatImg *fimg);
|
int fimg_load_from_png(char *filename, FloatImg *fimg);
|
||||||
int fimg_create_from_png(char *filename, FloatImg *fimg);
|
int fimg_create_from_png(char *filename, FloatImg *fimg);
|
||||||
|
|||||||
10
funcs/.gitignore
vendored
Normal file
10
funcs/.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
tpnm
|
||||||
|
t
|
||||||
|
*.o
|
||||||
|
*.png
|
||||||
|
*.gif
|
||||||
|
*.fits
|
||||||
|
*.tiff
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +9,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 rectangle.o \
|
fimg-libpnm.o rampes.o rectangle.o \
|
||||||
sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \
|
sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \
|
||||||
falsecolors.o \
|
falsecolors.o thermocolor.o fmorpho.o \
|
||||||
geometry.o rotate.o fimg-openexr.o \
|
geometry.o rotate.o fimg-openexr.o \
|
||||||
equalize.o fimg-fits.o saturation.o histogram.o \
|
equalize.o fimg-fits.o saturation.o histogram.o \
|
||||||
fimg-dicom.o \
|
fimg-dicom.o \
|
||||||
@@ -19,6 +19,11 @@ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
|
|||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
|
all: t
|
||||||
|
|
||||||
|
tests.o: tests.c tests.h $(DEPS)
|
||||||
|
gcc $(COPT) -I/usr/include/netpbm -c $<
|
||||||
|
|
||||||
t: t.c $(DEPS) ../libfloatimg.a tests.o
|
t: t.c $(DEPS) ../libfloatimg.a tests.o
|
||||||
gcc $(COPT) $< \
|
gcc $(COPT) $< \
|
||||||
tests.o \
|
tests.o \
|
||||||
@@ -28,8 +33,9 @@ t: t.c $(DEPS) ../libfloatimg.a tests.o
|
|||||||
-ltiff \
|
-ltiff \
|
||||||
-lz -lm -o $@
|
-lz -lm -o $@
|
||||||
|
|
||||||
tests.o: tests.c tests.h $(DEPS)
|
tpnm: tpnm.c Makefile fimg-libpnm.o
|
||||||
gcc $(COPT) -I/usr/include/netpbm -c $<
|
gcc $(COPT) -I/usr/include/netpbm \
|
||||||
|
fimg-libpnm.o -lnetpbm $< -o $@
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
# upper-level functions
|
# upper-level functions
|
||||||
@@ -60,6 +66,9 @@ incrustator.o: incrustator.c $(DEPS)
|
|||||||
displacement.o: displacement.c $(DEPS)
|
displacement.o: displacement.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
fmorpho.o: fmorpho.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
fimg-png.o: fimg-png.c $(DEPS)
|
fimg-png.o: fimg-png.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
@@ -141,6 +150,8 @@ exporter.o: exporter.c $(DEPS)
|
|||||||
falsecolors.o: falsecolors.c $(DEPS)
|
falsecolors.o: falsecolors.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
|
thermocolor.o: thermocolor.c $(DEPS)
|
||||||
|
gcc $(COPT) -c $<
|
||||||
|
|
||||||
hsv.o: hsv.c $(DEPS)
|
hsv.o: hsv.c $(DEPS)
|
||||||
gcc $(COPT) -c $<
|
gcc $(COPT) -c $<
|
||||||
|
|||||||
@@ -2,34 +2,43 @@
|
|||||||
|
|
||||||
Plein de fonctions qu'il serait bon de documenter :)
|
Plein de fonctions qu'il serait bon de documenter :)
|
||||||
|
|
||||||
## PNG
|
|
||||||
|
|
||||||
__Attention__ : la bibliothèque `pnglite`actuellement utilisée pour lire
|
|
||||||
les fichiers PNG n'accepte que **certains** types de fichiers.
|
|
||||||
Et en particulier, elle brotche sur ceux produits par ImageMagick !
|
|
||||||
|
|
||||||
## FITS
|
|
||||||
|
|
||||||
Un Format de fichier utilisé en astronomie.
|
|
||||||
|
|
||||||
https://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node1.html
|
|
||||||
|
|
||||||
## DICOM
|
|
||||||
|
|
||||||
https://en.wikipedia.org/wiki/DICOM et ça semble bien compliqué :(
|
|
||||||
|
|
||||||
## Contours
|
## Contours
|
||||||
|
|
||||||
Détecter des contours est une activité respectable. Mais difficile.
|
Détecter des contours est une activité respectable. Mais difficile.
|
||||||
|
Une recherche dans la littérature s'impose.
|
||||||
|
|
||||||
## Exporter
|
## Exporter
|
||||||
|
|
||||||
Une méta-fonction qui va sauvegarder (dans la mesure de ses conséquences)
|
`fimg_exporter` est une méta-fonction qui va sauvegarder (dans la mesure de ses conséquences)
|
||||||
une image en fonction de l'extension du nom de fichier.
|
une image en fonction de l'extension du nom de fichier fourni.
|
||||||
|
|
||||||
|
### PNG
|
||||||
|
|
||||||
|
__Attention__ : la bibliothèque `pnglite` actuellement utilisée pour lire
|
||||||
|
les fichiers PNG n'accepte que certains types de fichiers.
|
||||||
|
Et en particulier, elle brotche sur ceux produits par ImageMagick !
|
||||||
|
|
||||||
|
### FITS
|
||||||
|
|
||||||
|
Ce [format de fichier](https://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node1.html)
|
||||||
|
est utilisé en astronomie.
|
||||||
|
Son support est actuellement minimaliste.
|
||||||
|
|
||||||
|
|
||||||
|
### DICOM
|
||||||
|
|
||||||
|
https://en.wikipedia.org/wiki/DICOM et ça semble bien compliqué,
|
||||||
|
donc ça reste pour le moment au stade de vague projet :(
|
||||||
|
|
||||||
## Sfx
|
## Sfx
|
||||||
|
|
||||||
Effets spéciaux divers.
|
Effets spéciaux divers. Ils sont répartis dans plusieurs fichiers
|
||||||
|
(`sfx[0-4].c`) sans raison de classement apparente.
|
||||||
|
|
||||||
|
Certains peuvent être directement utilisés
|
||||||
|
avec l'outil [../tools/fimgfx.c](fimgfx).
|
||||||
|
Leur paramétrage est trop sommaire.
|
||||||
|
|
||||||
La fonction `fimg_pixelize_h_rnd` est issue d'une idée qui m'est venue
|
La fonction `fimg_pixelize_h_rnd` est issue d'une idée qui m'est venue
|
||||||
dans la roulotte de TerreBlanque. Elle a besoin de recherches sur la
|
dans la roulotte de TerreBlanque. Elle a besoin de recherches sur la
|
||||||
@@ -38,3 +47,7 @@ dynamique temporelle, et d'une FSM à trois états.
|
|||||||
## Dithering
|
## Dithering
|
||||||
|
|
||||||
Work in progress...
|
Work in progress...
|
||||||
|
|
||||||
|
Une difficulté dans ce domaine, c'est la *floattitude* des pixels,
|
||||||
|
sur laquelle il est difficile d'appliquer des operations binaires,
|
||||||
|
comme le XOR.
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
|||||||
psrc, pdst, k);
|
psrc, pdst, k);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX useless message ?
|
||||||
|
*/
|
||||||
if (k) { fprintf(stderr, "k=%d in %s\n", k, __func__); }
|
if (k) { fprintf(stderr, "k=%d in %s\n", k, __func__); }
|
||||||
|
|
||||||
fimg_clear(pdst);
|
fimg_clear(pdst);
|
||||||
@@ -102,6 +105,9 @@ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
|||||||
psrc, pdst, k);
|
psrc, pdst, k);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX useless message ?
|
||||||
|
*/
|
||||||
if (k) { fprintf(stderr, "k=%d in %s\n", k, __func__); }
|
if (k) { fprintf(stderr, "k=%d in %s\n", k, __func__); }
|
||||||
|
|
||||||
fimg_clear(pdst);
|
fimg_clear(pdst);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ float minmax[6];
|
|||||||
float rgb[3];
|
float rgb[3];
|
||||||
float dltr, dltg, dltb; /* delta des minmax */
|
float dltr, dltg, dltb; /* delta des minmax */
|
||||||
float dispx, dispy;
|
float dispx, dispy;
|
||||||
|
|
||||||
int dstx, dsty;
|
int dstx, dsty;
|
||||||
int in, out;
|
int in, out;
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ if (foo) {
|
|||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fimg_print_minmax(minmax, (char *)__func__);
|
fimg_print_minmax(minmax, (char *)__func__);
|
||||||
}
|
}
|
||||||
dltr = minmax[1] - minmax[0];
|
// dltr = minmax[1] - minmax[0];
|
||||||
dltg = minmax[3] - minmax[2];
|
dltg = minmax[3] - minmax[2];
|
||||||
dltb = minmax[5] - minmax[4];
|
dltb = minmax[5] - minmax[4];
|
||||||
|
|
||||||
@@ -83,9 +82,7 @@ for (y=0; y<psrc->height; y++) {
|
|||||||
fimg_put_rgb(pdst, dstx, dsty, rgb);
|
fimg_put_rgb(pdst, dstx, dsty, rgb);
|
||||||
in++;
|
in++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out);
|
if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out);
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__, psrc, pdst, flags);
|
|||||||
|
|
||||||
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
|
if (flags) { fprintf(stderr, "flags: 0x%04x in %s\n", flags, __func__); }
|
||||||
|
|
||||||
|
if (fimg_images_not_compatible(psrc, pdst)) {
|
||||||
|
fprintf(stderr, "%s: shit happen\n", __func__);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
for (y=0; y<psrc->height; y++) {
|
for (y=0; y<psrc->height; y++) {
|
||||||
|
|
||||||
for (x=0; x<psrc->width; x++)
|
for (x=0; x<psrc->width; x++)
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ fprintf(stderr, "%8.3f %8.3f %8.3f\n", M[6], M[7], M[8]);
|
|||||||
|
|
||||||
sum = 0.0;
|
sum = 0.0;
|
||||||
for (idx=0; idx<9; idx++) sum += M[idx];
|
for (idx=0; idx<9; idx++) sum += M[idx];
|
||||||
fprintf(stderr, " sum %8.3f\n", sum);
|
fprintf(stderr, " sum: %8.3f\n", sum);
|
||||||
fprintf(stderr, " mult %8.3f\n", filtr->mult);
|
fprintf(stderr, " mult: %8.3f\n", filtr->mult);
|
||||||
fprintf(stderr, " offset %8.3f\n", filtr->offset);
|
fprintf(stderr, " offset: %8.3f\n", filtr->offset);
|
||||||
|
|
||||||
value = (sum * filtr->mult) + filtr->offset;
|
value = (sum * filtr->mult) + filtr->offset;
|
||||||
fprintf(stderr, " value %8.3f ???\n", value);
|
fprintf(stderr, " value: %8.3f\n", value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ float *M; /* alias of filter matrix */
|
|||||||
double dval;
|
double dval;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, src, dst, filtr);
|
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, src, dst, filtr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (src->type != FIMG_TYPE_RGB) {
|
if (src->type != FIMG_TYPE_RGB) {
|
||||||
@@ -59,12 +59,12 @@ if (dst->type != FIMG_TYPE_RGB) {
|
|||||||
return -99;
|
return -99;
|
||||||
}
|
}
|
||||||
if (fimg_images_not_compatible(src, dst)) {
|
if (fimg_images_not_compatible(src, dst)) {
|
||||||
fprintf(stderr, "%s: src & dst not comatibles\n", __func__);
|
fprintf(stderr, "%s: src & dst not compatibles\n", __func__);
|
||||||
return -98;
|
return -98;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity > 1) {
|
if (verbosity > 1) {
|
||||||
fimg_show_filter("essai", filtr);
|
fimg_show_filter((char *)__func__, filtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* aliasing some vars for cleaner code */
|
/* aliasing some vars for cleaner code */
|
||||||
@@ -73,9 +73,7 @@ w = src->width; h = src->height;
|
|||||||
M = filtr->matrix;
|
M = filtr->matrix;
|
||||||
|
|
||||||
for (y=1; y < h-1; y++) {
|
for (y=1; y < h-1; y++) {
|
||||||
|
|
||||||
for (x=1; x < w-1; x++) {
|
for (x=1; x < w-1; x++) {
|
||||||
|
|
||||||
of = x + (y * w);
|
of = x + (y * w);
|
||||||
|
|
||||||
dval = M[0] * pr[of-(w+1)] +
|
dval = M[0] * pr[of-(w+1)] +
|
||||||
@@ -142,9 +140,7 @@ if (img->type != FIMG_TYPE_RGB) {
|
|||||||
pr = img->R; pg = img->G; pb = img->B;
|
pr = img->R; pg = img->G; pb = img->B;
|
||||||
|
|
||||||
for (y=1; y < img->height-1; y++) {
|
for (y=1; y < img->height-1; y++) {
|
||||||
|
|
||||||
for (x=1; x < img->width-1; x++) {
|
for (x=1; x < img->width-1; x++) {
|
||||||
|
|
||||||
offset = x + (y * img->width);
|
offset = x + (y * img->width);
|
||||||
|
|
||||||
cr = pr[offset] + pr[offset+1] +
|
cr = pr[offset] + pr[offset+1] +
|
||||||
@@ -159,7 +155,6 @@ for (y=1; y < img->height-1; y++) {
|
|||||||
pr[offset] = cr / 4.0;
|
pr[offset] = cr / 4.0;
|
||||||
pg[offset] = cg / 4.0;
|
pg[offset] = cg / 4.0;
|
||||||
pb[offset] = cb / 4.0;
|
pb[offset] = cb / 4.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +195,6 @@ for (idx=0; idx<h; idx++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
o = w * (h - 1);
|
o = w * (h - 1);
|
||||||
|
|
||||||
for (idx=0; idx<w; idx++) {
|
for (idx=0; idx<w; idx++) {
|
||||||
#if FAST
|
#if FAST
|
||||||
img->R[idx] = 0.0;
|
img->R[idx] = 0.0;
|
||||||
@@ -222,6 +216,10 @@ int fimg_lissage_2x2(FloatImg *img)
|
|||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
||||||
|
#endif
|
||||||
|
|
||||||
foo = fimg_lissage_2x2_a(img);
|
foo = fimg_lissage_2x2_a(img);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: fail %d\n", __func__, foo);
|
fprintf(stderr, "%s: fail %d\n", __func__, foo);
|
||||||
@@ -233,4 +231,54 @@ fimg_killborders(img);
|
|||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* XXX inplace filtering is a BAD IDEA
|
||||||
|
*/
|
||||||
|
int fimg_lissage_3x3(FloatImg *img)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
FloatImg tmp;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static FimgFilter3x3 lowpass = {
|
||||||
|
{
|
||||||
|
1.0, 2.0, 1.0,
|
||||||
|
2.0, 4.0, 2.0,
|
||||||
|
1.0, 2.0, 1.0,
|
||||||
|
},
|
||||||
|
16.0, 0.0
|
||||||
|
};
|
||||||
|
|
||||||
|
foo = fimg_clone(img, &tmp, 1);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: clone -> %d\n", __func__, foo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
foo = fimg_filter_3x3(&tmp, img, &lowpass);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: lowpass -> %d\n", __func__, foo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_copy_data(&tmp, img);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: copy data -> %d\n", __func__, foo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_destroy(&tmp);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: destroy -> %d\n", __func__, foo);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_killborders(img);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ if (fits_create_file(&fptr, outname, &status)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
naxes[0] = src->width; naxes[1] = src->height;
|
naxes[0] = src->width; naxes[1] = src->height;
|
||||||
if (verbosity) fimg_describe(src, "to be saved as FITS");
|
if (verbosity > 1) fimg_describe(src, "to be saved as FITS");
|
||||||
|
|
||||||
if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) {
|
if ( fits_create_img(fptr, bitpix, naxis, naxes, &status) ) {
|
||||||
fits_report_error(stderr, status);
|
fits_report_error(stderr, status);
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ extern int verbosity;
|
|||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
static void print_struct_pam(struct pam *ppam, char *text)
|
static void print_struct_pam(struct pam *ppam, char *text)
|
||||||
{
|
{
|
||||||
printf(" text %s\n", text);
|
printf("\ttext %s\n", text);
|
||||||
printf(" size %d\n", ppam->size);
|
printf("\tsize %d\n", ppam->size);
|
||||||
|
|
||||||
printf(" format %d\n", ppam->format);
|
printf("\tformat %d 0x%04x\n", ppam->format, ppam->format);
|
||||||
printf(" plainformat %d\n", ppam->plainformat);
|
printf("\tplainformat %d\n", ppam->plainformat);
|
||||||
printf(" width & height %d %d\n", ppam->width, ppam->height);
|
printf("\twidth & height %d %d\n", ppam->width, ppam->height);
|
||||||
printf(" depth %d\n", ppam->depth);
|
printf("\tdepth %d\n", ppam->depth);
|
||||||
printf(" maxval %lu\n", ppam->maxval);
|
printf("\tmaxval %lu\n", ppam->maxval);
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -36,13 +36,14 @@ FILE *fp;
|
|||||||
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname);
|
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
printf(" --- infos for '%s' ------------\n", fname);
|
||||||
|
|
||||||
if (NULL==(fp=fopen(fname, "r"))) {
|
if (NULL==(fp=fopen(fname, "r"))) {
|
||||||
perror(fname);
|
perror(fname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pnm_readpaminit(fp, &inpam, sizeof(inpam));
|
pnm_readpaminit(fp, &inpam, sizeof(inpam));
|
||||||
|
|
||||||
print_struct_pam(&inpam, fname);
|
print_struct_pam(&inpam, fname);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ unsigned char *bytes, *bptr;
|
|||||||
double maximum, fk;
|
double maximum, fk;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %-25s ( %p '%s' 0x%x )\n", __func__, src, outname, flags);
|
fprintf(stderr, ">>> %s ( %p '%s' 0x%x )\n", __func__, src, outname, flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (flags) {
|
if (flags) {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ if (verbosity) {
|
|||||||
tiff = TIFFOpen(fname, "w");
|
tiff = TIFFOpen(fname, "w");
|
||||||
if (NULL==tiff) {
|
if (NULL==tiff) {
|
||||||
fprintf(stderr, "erreur TIFFOpen\n");
|
fprintf(stderr, "erreur TIFFOpen\n");
|
||||||
|
free(linebuff);
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
89
funcs/fmorpho.c
Normal file
89
funcs/fmorpho.c
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* --------
|
||||||
|
|
||||||
|
* F M O R P H O
|
||||||
|
*
|
||||||
|
* nouveau 30 septembre 2022 / integration 28 octobre 2022
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- !*/
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
} deltas[] =
|
||||||
|
{ { -1, -1, },
|
||||||
|
{ 0, -1, },
|
||||||
|
{ 1, -1, },
|
||||||
|
{ -1, 0, },
|
||||||
|
{ 0, 0, },
|
||||||
|
{ 1, 0, },
|
||||||
|
{ -1, 1, },
|
||||||
|
{ 0, 1, },
|
||||||
|
{ 1, 1 }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int x, y; // not used
|
||||||
|
float r, g, b;
|
||||||
|
float fgris;
|
||||||
|
int rang;
|
||||||
|
} fpixel;
|
||||||
|
|
||||||
|
static fpixel pixels[9];
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- !*/
|
||||||
|
static int comparaison_fgris(const void *A, const void *B)
|
||||||
|
{
|
||||||
|
return ((fpixel *)A)->fgris > ((fpixel *)B)->fgris;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- !*/
|
||||||
|
/*
|
||||||
|
* this is a klugy approch, sorry.
|
||||||
|
*/
|
||||||
|
int fimg_filtre_morpho_0(FloatImg *sfimg, FloatImg *dfimg, int index)
|
||||||
|
{
|
||||||
|
int xs, ys, loop9;
|
||||||
|
int xp, yp;
|
||||||
|
float rgb[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, sfimg, dfimg, index);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( (index<0) || (index>8)) {
|
||||||
|
fprintf(stderr, " %s: bad index %d\n", __func__, index);
|
||||||
|
#if MUST_ABORT
|
||||||
|
fflush(stderr); abort();
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_clear(dfimg);
|
||||||
|
|
||||||
|
for (ys=1; ys<sfimg->height-1; ys++) {
|
||||||
|
for (xs=1; xs<sfimg->width-1; xs++) {
|
||||||
|
for (loop9=0; loop9<9; loop9++) {
|
||||||
|
xp = xs + deltas[loop9].x;
|
||||||
|
yp = ys + deltas[loop9].y;
|
||||||
|
fimg_get_rgb(sfimg, xp, yp, rgb);
|
||||||
|
pixels[loop9].fgris = rgb[0] + rgb[1] + rgb[2];
|
||||||
|
pixels[loop9].rang = loop9;
|
||||||
|
}
|
||||||
|
qsort(&pixels, 9, sizeof(fpixel), comparaison_fgris);
|
||||||
|
rgb[0] = rgb[1] = rgb[2] = pixels[index].fgris;
|
||||||
|
fimg_put_rgb(dfimg, xs, ys, rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- !*/
|
||||||
@@ -110,18 +110,28 @@ for (y=0; y<hd; y++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* this function can be optimized with direct pixel copy
|
||||||
|
*/
|
||||||
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect)
|
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect)
|
||||||
{
|
{
|
||||||
int xs, ys, xd, yd;
|
int xs, ys, xd, yd;
|
||||||
int count;
|
int count;
|
||||||
float rgb[3];
|
float rgb[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, in, out, rect);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (verbosity > 1) {
|
if (verbosity > 1) {
|
||||||
fimg_describe(in, "extractor: source");
|
fimg_describe(in, "extractor: source");
|
||||||
fimg_describe(out, "extractor: destination");
|
fimg_describe(out, "extractor: destination");
|
||||||
// print_rectangle(rect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* some sanity controls, please ! XXX
|
||||||
|
*/
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for (yd=0; yd<rect->h; yd++) {
|
for (yd=0; yd<rect->h; yd++) {
|
||||||
ys = yd + rect->y;
|
ys = yd + rect->y;
|
||||||
@@ -135,7 +145,7 @@ for (yd=0; yd<rect->h; yd++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fprintf(stderr, "%s: %d pix moved\n", __func__, count);
|
if (verbosity > 1) fprintf(stderr, "%s: %d pix moved\n", __func__, count);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ static int check_boundaries(FloatImg *from, FloatImg *to, FimgArea51 *a51)
|
|||||||
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, from, to, a51);
|
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, from, to, a51);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fimg_printdims("from", from);
|
if (verbosity > 1) {
|
||||||
fimg_printdims("to ", to);
|
fimg_printdims("from", from);
|
||||||
|
fimg_printdims("to ", to);
|
||||||
|
}
|
||||||
|
|
||||||
/* just a small molly-guard */
|
/* just a small molly-guard */
|
||||||
if ( (a51->w < 0) || (a51->h < 0) ) {
|
if ( (a51->w < 0) || (a51->h < 0) ) {
|
||||||
@@ -47,6 +49,9 @@ return -1;
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* See also: fimg_extractor() in geometry.c
|
||||||
|
*/
|
||||||
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
|
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
|
||||||
int xpos, int ypos, int flags)
|
int xpos, int ypos, int flags)
|
||||||
{
|
{
|
||||||
@@ -78,7 +83,8 @@ if (foo) {
|
|||||||
|
|
||||||
if ( (xpos < 0) || (xpos > pdst->width - psrc->width) ||
|
if ( (xpos < 0) || (xpos > pdst->width - psrc->width) ||
|
||||||
(ypos < 0) || (ypos > pdst->height - psrc->height) ) {
|
(ypos < 0) || (ypos > pdst->height - psrc->height) ) {
|
||||||
fprintf(stderr, "%s: boudary error\n", __func__);
|
fprintf(stderr, "%s: boudary error, x=%d y=%d\n", __func__,
|
||||||
|
xpos, ypos);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
*********************************************
|
||||||
|
* SEGFAULT SI IMAGE TROP PETITE *
|
||||||
|
*********************************************
|
||||||
|
*/
|
||||||
|
|
||||||
int fimg_test_pattern(FloatImg *fimg, int type, double dval)
|
int fimg_test_pattern(FloatImg *fimg, int type, double dval)
|
||||||
{
|
{
|
||||||
@@ -26,6 +31,8 @@ if (fimg->type != FIMG_TYPE_RGB) {
|
|||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "ENTERING %s\n", __func__);
|
||||||
|
|
||||||
if (type) {
|
if (type) {
|
||||||
fprintf(stderr, "%s : %d %f\n", __func__, type, dval);
|
fprintf(stderr, "%s : %d %f\n", __func__, type, dval);
|
||||||
}
|
}
|
||||||
@@ -50,7 +57,7 @@ for (x=0; x<fimg->width; x++) {
|
|||||||
fimg_plot_rgb(fimg, x, y, fr, fg, fb);
|
fimg_plot_rgb(fimg, x, y, fr, fg, fb);
|
||||||
}
|
}
|
||||||
|
|
||||||
k = fimg->height / 4;
|
k = (fimg->height / 4) + 20;
|
||||||
for (x=0; x<fimg->width; x++) {
|
for (x=0; x<fimg->width; x++) {
|
||||||
val = ((double)x / (double)fimg->width) * dval;
|
val = ((double)x / (double)fimg->width) * dval;
|
||||||
for (y=0; y<20; y++) {
|
for (y=0; y<20; y++) {
|
||||||
@@ -60,6 +67,27 @@ for (x=0; x<fimg->width; x++) {
|
|||||||
// fprintf(stderr, " %6d %f\n", x, val);
|
// fprintf(stderr, " %6d %f\n", x, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
k = (fimg->height / 4) + 90;
|
||||||
|
for (x=0; x<fimg->width; x++) {
|
||||||
|
val = ((x%8)<4) ? dval : 0.0;
|
||||||
|
for (y=0; y<20; y++) {
|
||||||
|
fimg_plot_rgb(fimg, x, k+y, val, val, val);
|
||||||
|
fimg_plot_rgb(fimg, x, k+y+20, dval-val, dval-val, dval-val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
k = (fimg->height / 4) + 140;
|
||||||
|
for (x=0; x<fimg->width; x++) {
|
||||||
|
for (y=0; y<20; y++) {
|
||||||
|
val = drand48() * dval;
|
||||||
|
fimg_plot_rgb(fimg, x, k+y, val, val, val);
|
||||||
|
fimg_plot_rgb(fimg, x, k+y+20, dval-val, dval-val, dval-val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "ALIVE %s\n", __func__);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ switch(largeur) {
|
|||||||
case 8: case 16: case 32:
|
case 8: case 16: case 32:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "pixeliz bad width %d\n", largeur);
|
fprintf(stderr, "%s: bad width %d\n", __func__, largeur);
|
||||||
return -77;
|
return -77;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +91,7 @@ if (verbosity) {
|
|||||||
|
|
||||||
foo = fimg_pixelize_h_0(psrc, pdst, flag ? largeur : 32);
|
foo = fimg_pixelize_h_0(psrc, pdst, flag ? largeur : 32);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "PANIC in %s\n", __func__);
|
fprintf(stderr, "pixelize_h_0 give err %d in %s\n", foo, __func__);
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count--; /* nice trick bro */
|
count--; /* nice trick bro */
|
||||||
|
|||||||
@@ -62,15 +62,18 @@ for (x=0; x<img->width; x++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/* nouveau 19 septembre 2022 */
|
/* nouveau 19 septembre 2022
|
||||||
|
*
|
||||||
|
* 6 octobre 2023 : rajout du parametre 'fmax'
|
||||||
|
*/
|
||||||
|
|
||||||
int fimg_do_stripes(FloatImg *img, int mode)
|
int fimg_do_stripes(FloatImg *img, float fmax, int mode)
|
||||||
{
|
{
|
||||||
int x, y, quad;
|
int x, y, quad;
|
||||||
float *ligne;
|
float *ligne;
|
||||||
float fr, fg, fb;
|
float fr, fg, fb;
|
||||||
|
|
||||||
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, img, mode);
|
fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__, img, fmax, mode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* allocate and fill a lookup table
|
* allocate and fill a lookup table
|
||||||
@@ -79,8 +82,10 @@ if (NULL==(ligne=malloc(img->width*sizeof(float)))) {
|
|||||||
fprintf(stderr, "%s: malloc fail\n", __func__);
|
fprintf(stderr, "%s: malloc fail\n", __func__);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
for (x=0; x<img->width; x++)
|
for (x=0; x<img->width; x++) {
|
||||||
ligne[x] = (float)x / (float)img->width;
|
ligne[x] = (float)x / (float)img->width;
|
||||||
|
ligne[x] *= fmax;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* build the pixels
|
* build the pixels
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
@@ -22,8 +23,18 @@ int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused)
|
|||||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused);
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (notused) {
|
||||||
|
fprintf(stderr, "%s parameter notused is %d, must be 0\n",
|
||||||
|
__func__, notused);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "!!!!!! %s is a wip !!!!!\n", __func__);
|
fprintf(stderr, "!!!!!! %s is a wip !!!!!\n", __func__);
|
||||||
|
|
||||||
|
if (fimg_images_not_compatible(src, dst)) {
|
||||||
|
fprintf(stderr, "%s: compatibility fatalerror\n", __func__);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* bon, maintenant, il faut plonger dans du code du
|
* bon, maintenant, il faut plonger dans du code du
|
||||||
* siecle dernier et l'adapter a ce nouveau contexte
|
* siecle dernier et l'adapter a ce nouveau contexte
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ return 0;
|
|||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/*
|
/*
|
||||||
* parameter fval is not used, why ?
|
* parameter fval is used for what ?
|
||||||
*/
|
*/
|
||||||
int fimg_killcolors_b(FloatImg *fimg, float fval)
|
int fimg_killcolors_b(FloatImg *fimg, float fval)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,4 +103,7 @@ for (foo=0; foo<size; foo++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* ici, il manque le quaternize :)
|
||||||
|
*/
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|||||||
44
funcs/sfx3.c
44
funcs/sfx3.c
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
@@ -16,6 +17,45 @@
|
|||||||
|
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
/* new Sun 29 Jan 2023 10:01:39 PM CET
|
||||||
|
|
||||||
|
*/
|
||||||
|
int fimg_make_rndfluffy_lines(FloatImg *src, FloatImg *dst, int rndt)
|
||||||
|
{
|
||||||
|
int x, y, ol;
|
||||||
|
float accu;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%p' '%p' %d )\n", __func__,
|
||||||
|
src, dst, rndt);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fimg_images_not_compatible(src, dst)) {
|
||||||
|
/* be hard for the lamers */
|
||||||
|
fprintf(stderr, "compatibility OUPS in %s\n", __func__);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (y=0; y<src->height; y++) {
|
||||||
|
ol = y * src->width;
|
||||||
|
if (rndt < (rand() % 100)) {
|
||||||
|
accu = 0.0;
|
||||||
|
for (x=0; x<src->width; x++) accu += src->R[ol + x];
|
||||||
|
accu /= (float)src->width;
|
||||||
|
for (x=0; x<src->width; x++) dst->R[ol + x] = accu;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (x=0; x<src->width; x++) {
|
||||||
|
dst->R[ol+x] = src->R[ol+x];
|
||||||
|
dst->G[ol+x] = src->G[ol+x];
|
||||||
|
dst->B[ol+x] = src->B[ol+x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused)
|
int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused)
|
||||||
{
|
{
|
||||||
@@ -29,8 +69,8 @@ fprintf(stderr, ">>> %s ( %p %p %f 0x%04x )\n", __func__,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (notused) {
|
if (notused) {
|
||||||
fprintf(stderr, "notused was %d, must be 0 in %s\n",
|
fprintf(stderr, "%s: notused was %d, must be 0\n",
|
||||||
notused, __func__);
|
__func__, notused);
|
||||||
}
|
}
|
||||||
|
|
||||||
halfval = fimg_get_maxvalue(src) / 2.0;
|
halfval = fimg_get_maxvalue(src) / 2.0;
|
||||||
|
|||||||
34
funcs/sfx4.c
34
funcs/sfx4.c
@@ -83,4 +83,38 @@ for(idx=0; idx<surface; idx++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
|
int fimg_make_triptyq(FloatImg *src, FloatImg *dst, int notused)
|
||||||
|
{
|
||||||
|
int x, y, sh, foo, ow;
|
||||||
|
float r, g, b, in[3];
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__, src, dst, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fimg_images_not_compatible(src, dst)) {
|
||||||
|
fprintf(stderr, "%s : compatibility error\n", __func__);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_clear(dst);
|
||||||
|
|
||||||
|
ow = src->width / 3;
|
||||||
|
for (y=0; y<src->height; y++) {
|
||||||
|
for (x=0; x<src->width/3; x++) {
|
||||||
|
r = g = b = 0.0;
|
||||||
|
for (sh=0; sh<3; sh++) {
|
||||||
|
foo = fimg_get_rgb(src, (x*3)+sh, y, in);
|
||||||
|
r+=in[0], g+=in[1], b+=in[2];
|
||||||
|
}
|
||||||
|
for (sh=0; sh<3; sh++) {
|
||||||
|
fimg_plot_rgb(dst, x, y, r, 0, 0);
|
||||||
|
fimg_plot_rgb(dst, x+ow, y, 0, g, 0);
|
||||||
|
fimg_plot_rgb(dst, x+(2*ow), y, 0, 0, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
|
|||||||
36
funcs/t.c
36
funcs/t.c
@@ -25,7 +25,8 @@ enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
|
|||||||
Displace, ReadPNG, Plasmas, Hilight, OpenEXR,
|
Displace, ReadPNG, Plasmas, Hilight, OpenEXR,
|
||||||
Geometrie, FileType, Mirror, KillRGB,
|
Geometrie, FileType, Mirror, KillRGB,
|
||||||
Pixelize,SplitLevel, DecompRgbz, DecompRgbg,
|
Pixelize,SplitLevel, DecompRgbz, DecompRgbg,
|
||||||
Rectangle, Dicom, Fakolor0, Fakolor3 };
|
Rectangle, Dicom, Fakolor0, Fakolor3,
|
||||||
|
Fmorpho0, Fluffy, ThermoCol, TriPtyq };
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
int Cmd;
|
int Cmd;
|
||||||
@@ -62,6 +63,10 @@ Command commands[] = {
|
|||||||
{ "dicom", Dicom },
|
{ "dicom", Dicom },
|
||||||
{ "fakolor0", Fakolor0 },
|
{ "fakolor0", Fakolor0 },
|
||||||
{ "fakolor3", Fakolor3 },
|
{ "fakolor3", Fakolor3 },
|
||||||
|
{ "fmorpho0", Fmorpho0 },
|
||||||
|
{ "fluffy", Fluffy },
|
||||||
|
{ "thermocol", ThermoCol },
|
||||||
|
{ "triptyq", TriPtyq },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -99,13 +104,17 @@ fprintf(stderr, "options:\n");
|
|||||||
fprintf(stderr, "\t-k 1.414\tset float value\n");
|
fprintf(stderr, "\t-k 1.414\tset float value\n");
|
||||||
fprintf(stderr, "\t-l\t\tlist tests\n");
|
fprintf(stderr, "\t-l\t\tlist tests\n");
|
||||||
fprintf(stderr, "\t-o \t\toutfile\n");
|
fprintf(stderr, "\t-o \t\toutfile\n");
|
||||||
|
fprintf(stderr, "\t-v \t\tincrease verbosity\n");
|
||||||
|
|
||||||
fprintf(stderr, "commands:\n");
|
if (verbosity) {
|
||||||
pcmd = commands;
|
fprintf(stderr, "commands:\n");
|
||||||
while (pcmd->name) {
|
pcmd = commands;
|
||||||
fprintf(stderr, "\t%-15s %d\n", pcmd->name, pcmd->Cmd);
|
while (pcmd->name) {
|
||||||
pcmd++;
|
fprintf(stderr, "\t%-15s %d\n", pcmd->name, pcmd->Cmd);
|
||||||
|
pcmd++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "\ncompiled on "__DATE__" at "__TIME__"\n");
|
fprintf(stderr, "\ncompiled on "__DATE__" at "__TIME__"\n");
|
||||||
|
|
||||||
if (k) fimg_print_version(k);
|
if (k) fimg_print_version(k);
|
||||||
@@ -253,6 +262,21 @@ switch(opt) {
|
|||||||
case Fakolor0:
|
case Fakolor0:
|
||||||
foo = essai_0_fausses_couleurs(outfile, 0);
|
foo = essai_0_fausses_couleurs(outfile, 0);
|
||||||
break;
|
break;
|
||||||
|
case Fmorpho0:
|
||||||
|
foo = essai_fmorpho_0(filename, "/tmp/fmorpho", 0);
|
||||||
|
break;
|
||||||
|
case Fluffy:
|
||||||
|
foo = essai_rndfluffy(filename, outfile, 0);
|
||||||
|
break;
|
||||||
|
case ThermoCol:
|
||||||
|
foo = essai_thermocol(filename, outfile);
|
||||||
|
fprintf(stderr, "retour thermocolor = %d\n", foo);
|
||||||
|
break;
|
||||||
|
case TriPtyq:
|
||||||
|
foo = essai_triptyq(filename, outfile);
|
||||||
|
fprintf(stderr, "retour triptyq = %d\n", foo);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "'%s' is a bad command\n", command);
|
fprintf(stderr, "'%s' is a bad command\n", command);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
171
funcs/tests.c
171
funcs/tests.c
@@ -1,4 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* --------
|
||||||
|
|
||||||
* tests des fonctions diverses - subroutines
|
* tests des fonctions diverses - subroutines
|
||||||
see also: t.c
|
see also: t.c
|
||||||
*/
|
*/
|
||||||
@@ -17,6 +20,102 @@
|
|||||||
|
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
||||||
|
#define W 1024
|
||||||
|
#define H 768
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* new Mon Apr 1 15:35:57 UTC 2024 -> sfx4.c */
|
||||||
|
int essai_triptyq(char *infile, char *outfile)
|
||||||
|
{
|
||||||
|
FloatImg src, dst;
|
||||||
|
int idx, foo;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %s %s )\n", __func__, infile, outfile);
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(infile, &src);
|
||||||
|
if (0 != foo) {
|
||||||
|
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
|
||||||
|
foo, infile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
fimg_clone(&src, &dst, 1);
|
||||||
|
|
||||||
|
foo = fimg_make_triptyq(&src, &dst, 0);
|
||||||
|
if (0 != foo) {
|
||||||
|
fprintf(stderr, "%s: make_triptyq -> %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&dst, outfile, 0);
|
||||||
|
if (0 != foo) {
|
||||||
|
fprintf(stderr, "%s: err %d exporting to '%s'\n", __func__,
|
||||||
|
foo, outfile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* nouveau 30 octobre 2022 --> fmorpho.c
|
||||||
|
*/
|
||||||
|
int essai_fmorpho_0(char *infile, char *basefname, int k)
|
||||||
|
{
|
||||||
|
FloatImg src, dst;
|
||||||
|
int idx, foo;
|
||||||
|
char fname[100];
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, infile, basefname, k);
|
||||||
|
|
||||||
|
if (k) {
|
||||||
|
fprintf(stderr, "%s k=%d must be 0\n", __func__, k);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL == infile ) {
|
||||||
|
foo = fimg_create(&src, W, H, FIMG_TYPE_RGB);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: create -> %d\n",__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
foo = fimg_test_pattern(&src, 0, 254.99);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: test_pattern -> %d\n",__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foo = fimg_create_from_dump(infile, &src);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: error %d loading '%s'\n", __func__, foo, infile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_save_as_pnm(&src, "foo.pnm", 0);
|
||||||
|
|
||||||
|
foo = fimg_clone(&src, &dst, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: clone -> %d\n",__func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx=0; idx<9; idx++) {
|
||||||
|
sprintf(fname, "%s%04d.pnm", basefname, idx);
|
||||||
|
fprintf(stderr, " ---> %s\n", fname);
|
||||||
|
foo = fimg_filtre_morpho_0(&src, &dst, idx);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: got a %d at round %d\n", __func__, foo, idx);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
fimg_save_as_pnm(&dst, fname, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_destroy(&src); fimg_destroy(&dst);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/* nouveau 18 mai 2022 */
|
/* nouveau 18 mai 2022 */
|
||||||
int essai_0_fausses_couleurs(char *dstfile, int type)
|
int essai_0_fausses_couleurs(char *dstfile, int type)
|
||||||
@@ -24,8 +123,6 @@ int essai_0_fausses_couleurs(char *dstfile, int type)
|
|||||||
FloatImg src, dst;
|
FloatImg src, dst;
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
#define W 1024
|
|
||||||
#define H 768
|
|
||||||
fprintf(stderr, "\nEssais fausses couleurs (type %d) -> '%s'\n", type, dstfile);
|
fprintf(stderr, "\nEssais fausses couleurs (type %d) -> '%s'\n", type, dstfile);
|
||||||
|
|
||||||
foo = fimg_create(&src, W, H, FIMG_TYPE_RGB);
|
foo = fimg_create(&src, W, H, FIMG_TYPE_RGB);
|
||||||
@@ -253,6 +350,42 @@ if (foo) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* new Sun Feb 12 10:34:06 CET 2023
|
||||||
|
*/
|
||||||
|
int essai_rndfluffy(char *infile, char *outfile, int k)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
FloatImg src, dst;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
|
||||||
|
infile, outfile, k);
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(infile, &src);
|
||||||
|
if (0 != foo) {
|
||||||
|
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
|
||||||
|
foo, infile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
fprintf(stderr, " %s loaded.\n", infile);
|
||||||
|
|
||||||
|
fimg_clone(&src, &dst, 0);
|
||||||
|
fprintf(stderr, " %p cloned.\n", &src);
|
||||||
|
|
||||||
|
foo = fimg_make_rndfluffy_lines(&src, &dst, 80);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "err %d while making fluffy\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&dst, outfile, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err %d exporting %s\n", __func__, foo, outfile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
fimg_destroy(&src); fimg_destroy(&dst);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int essai_split_level(char *inf, char *outf, int flags)
|
int essai_split_level(char *inf, char *outf, int flags)
|
||||||
{
|
{
|
||||||
@@ -1073,3 +1206,37 @@ fimg_destroy(&dst);
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* dans ma nouvelle maison du Gers, le 20 mars 2024 */
|
||||||
|
int essai_thermocol(char *infile, char *outfile)
|
||||||
|
{
|
||||||
|
FloatImg src, dst;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, infile, outfile);
|
||||||
|
|
||||||
|
memset(&src, 0, sizeof(FloatImg));
|
||||||
|
foo = fimg_create_from_dump(infile, &src);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&dst, 0, sizeof(FloatImg));
|
||||||
|
foo = fimg_clone(&src, &dst, 0);
|
||||||
|
if (foo) return -888;
|
||||||
|
|
||||||
|
foo = fimg_auto_thermique(&src, &dst, 0);
|
||||||
|
|
||||||
|
foo = fimg_export_picture(&dst, outfile, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s : err %d saving result to %s\n", __func__,
|
||||||
|
foo, outfile);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_destroy(&src);
|
||||||
|
fimg_destroy(&dst);
|
||||||
|
|
||||||
|
return 793;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ int essai_miroir(char *inf, char *outf, int flags);
|
|||||||
int essai_killrgb(char *inf, char *outf);
|
int essai_killrgb(char *inf, char *outf);
|
||||||
int essai_decomprgb_color(char *inf, char *outf);
|
int essai_decomprgb_color(char *inf, char *outf);
|
||||||
int essai_decomprgb_gray(char *inf, char *outf);
|
int essai_decomprgb_gray(char *inf, char *outf);
|
||||||
|
int essai_rndfluffy(char *infile, char *outfile, int k); /* sfx3.c */
|
||||||
int essai_split_level(char *inf, char *outf, int flags);
|
int essai_split_level(char *inf, char *outf, int flags);
|
||||||
|
|
||||||
int essai_displacement(char *infile, char *outfile);
|
int essai_displacement(char *infile, char *outfile);
|
||||||
@@ -29,11 +30,14 @@ int essai_detect_type(void);
|
|||||||
int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */
|
int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */
|
||||||
int essai_histogramme(char *fname, int k);
|
int essai_histogramme(char *fname, int k);
|
||||||
int essai_0_fausses_couleurs(char *dstfile, int type);
|
int essai_0_fausses_couleurs(char *dstfile, int type);
|
||||||
|
int essai_thermocol(char *infile, char *outfile);
|
||||||
|
int essai_triptyq(char *infile, char *outfile);
|
||||||
|
|
||||||
int essai_lecture_png(char *fname, char *outfile, int notused);
|
int essai_lecture_png(char *fname, char *outfile, int notused);
|
||||||
|
|
||||||
int essai_highlights(char *inf, char *outf, int ikoef, float fkoef);
|
int essai_highlights(char *inf, char *outf, int ikoef, float fkoef);
|
||||||
int essai_openexr(char *inf, char *outf, int flags);
|
int essai_openexr(char *inf, char *outf, int flags);
|
||||||
|
int essai_fmorpho_0(char *infile, char *basefname, int k);
|
||||||
|
|
||||||
int essai_pixelize(char *infile, char *outfile);
|
int essai_pixelize(char *infile, char *outfile);
|
||||||
|
|
||||||
|
|||||||
67
funcs/thermocolor.c
Normal file
67
funcs/thermocolor.c
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* FLOATIMG
|
||||||
|
* fabriquer une pseudo-image thermique
|
||||||
|
*
|
||||||
|
* new: Wed Mar 20 16:55:09 UTC 2024 dans ma maison du Gers
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
extern int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* parameter k in not used, but may be in the futur.
|
||||||
|
*/
|
||||||
|
int fimg_auto_thermique(FloatImg *src, FloatImg *dst, int k)
|
||||||
|
{
|
||||||
|
// int x, y, off;
|
||||||
|
int idx, surface;
|
||||||
|
|
||||||
|
float seuil, gray;
|
||||||
|
double graymean;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, k);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (0!=k) {
|
||||||
|
fprintf(stderr, "%s: k must be 0, was %d\n", __func__, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
surface = src->width * src->height;
|
||||||
|
// fprintf(stderr, "surface = %d\n", surface);
|
||||||
|
|
||||||
|
graymean = 0.0;
|
||||||
|
for (idx=0; idx<surface; idx++) {
|
||||||
|
gray = src->R[idx] + src->G[idx] + src->B[idx];
|
||||||
|
graymean += (double)gray;
|
||||||
|
}
|
||||||
|
seuil = (float) (graymean / surface);
|
||||||
|
// fprintf(stderr, "graymean = %f seuil = %f\n", graymean, seuil);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* please, explain this number brotching
|
||||||
|
*/
|
||||||
|
for (idx=0; idx<surface; idx++) {
|
||||||
|
gray = src->R[idx] + src->G[idx] + src->B[idx];
|
||||||
|
if (gray > seuil) {
|
||||||
|
dst->R[idx] = gray - seuil;
|
||||||
|
dst->B[idx] = seuil / 8.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dst->G[idx] = gray;
|
||||||
|
dst->B[idx] = seuil / 8.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
|
* testbed for using the Netpbm library
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pam.h>
|
|
||||||
|
#include <pam.h> /* Portable Any Map */
|
||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,13 @@ return -1;
|
|||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int print_rectangle(char *str, FimgArea51 *rect)
|
int print_rectangle(char *str, FimgArea51 *rect)
|
||||||
{
|
{
|
||||||
printf("rect @ %p '%s':\n\t %dx%d at %d,%d\n", rect, str,
|
if (MAGIC_AREA51 != rect->magic) {
|
||||||
|
fprintf(stderr, "%s: bad magic number 0x%08X\n", __func__,
|
||||||
|
rect->magic);
|
||||||
|
return -666;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("rect @ %p '%s' :\n\t %dx%d at %d,%d\n", rect, str,
|
||||||
rect->w, rect->h, rect->x, rect->y);
|
rect->w, rect->h, rect->x, rect->y);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -120,22 +126,28 @@ int parse_rectangle(char *str, FimgArea51 *r, int notused)
|
|||||||
{
|
{
|
||||||
int x, y, w, h, foo;
|
int x, y, w, h, foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %s %p %d )\n", __func__, str, r, notused);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (notused) {
|
if (notused) {
|
||||||
fprintf(stderr, "notused was %d, must be 0 in %s\n",
|
fprintf(stderr, "notused was %d, must be 0 in %s\n",
|
||||||
notused, __func__);
|
notused, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity)
|
if (verbosity > 1) fprintf(stderr, "%s: parsing '%s'\n", __func__, str);
|
||||||
fprintf(stderr, "parsing %s\n", str);
|
|
||||||
|
|
||||||
foo = sscanf(str, "%d,%d,%d,%d", &w, &h, &x, &y);
|
foo = sscanf(str, "%d,%d,%d,%d", &w, &h, &x, &y);
|
||||||
if (4 == foo) {
|
if (4 == foo) {
|
||||||
r->x = x, r->y = y, r->w = w, r->h = h;
|
r->x = x, r->y = y, r->w = w, r->h = h;
|
||||||
|
r->magic = MAGIC_AREA51;
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r->magic = 0xBAD;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int format_from_extension(char *fname)
|
int format_from_extension(char *fname)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash -v
|
#!/bin/bash -v
|
||||||
|
|
||||||
|
set -e ; set -u
|
||||||
|
|
||||||
cp libfloatimg.a /usr/local/lib
|
cp libfloatimg.a /usr/local/lib
|
||||||
cp floatimg.h /usr/local/include
|
cp floatimg.h /usr/local/include
|
||||||
|
|
||||||
@@ -8,7 +10,8 @@ cp tools/mkfimg tools/fimg2pnm tools/fimgops \
|
|||||||
tools/png2fimg tools/fimgstats tools/fimgfx \
|
tools/png2fimg tools/fimgstats tools/fimgfx \
|
||||||
tools/cumulfimgs tools/fimg2text \
|
tools/cumulfimgs tools/fimg2text \
|
||||||
tools/fimghalfsize \
|
tools/fimghalfsize \
|
||||||
tools/fimgmetadata \
|
tools/fimgmetadata tools/fimgfilters \
|
||||||
|
tools/fimgextract \
|
||||||
/usr/local/bin
|
/usr/local/bin
|
||||||
|
|
||||||
cp v4l2/grabvidseq v4l2/video-infos \
|
cp v4l2/grabvidseq v4l2/video-infos \
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
# Fimg tools
|
# Floatimg, the base/core library
|
||||||
|
|
||||||
Need more explanations...
|
## Data structures
|
||||||
|
|
||||||
|
Image's pixels (floating point number, a `float` for C)
|
||||||
|
are ordonned as an array of lines of single
|
||||||
|
componant values. Every componant is in a separate array,
|
||||||
|
who are *glued* together by an in-memory image descriptor.
|
||||||
|
|
||||||
|
```
|
||||||
## Converting to/from rgb or gray
|
#define MAGIC_FIMG 0x00F11F00
|
||||||
|
typedef struct {
|
||||||
|
uint32_t magic;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int type;
|
||||||
|
float fval;
|
||||||
|
int count;
|
||||||
|
float *R, *G, *B, *A;
|
||||||
|
FimgMetaData mdatas; // added 20230912
|
||||||
|
int reserved;
|
||||||
|
} FloatImg;
|
||||||
|
```
|
||||||
|
For the current state of this struc, look at the main
|
||||||
|
[header file](../floatimg.h), located at the root of the project.
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,17 @@ extern int verbosity; /* must be declared around main() */
|
|||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
int fimg_add_alpha_chan(FloatImg *img)
|
int fimg_add_alpha_chan(FloatImg *img)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
||||||
|
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
int fimg_kill_alpha_chan(FloatImg *img)
|
int fimg_kill_alpha_chan(FloatImg *img)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
|
||||||
|
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -116,13 +116,17 @@ int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval)
|
|||||||
int nbre, idx;
|
int nbre, idx;
|
||||||
double dval;
|
double dval;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %g )\n", __func__, s, d, maxval);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (s->type != FIMG_TYPE_RGB) {
|
if (s->type != FIMG_TYPE_RGB) {
|
||||||
fprintf(stderr, "%s: type %d invalide\n",
|
fprintf(stderr, "%s: type %d invalide\n",
|
||||||
__func__, s->type);
|
__func__, s->type);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL==d) { d = s; }
|
if (NULL==d) { d = s; } /* In place */
|
||||||
else {
|
else {
|
||||||
if (d->type != FIMG_TYPE_RGB) {
|
if (d->type != FIMG_TYPE_RGB) {
|
||||||
fprintf(stderr, "%s: dst type %d invalide\n",
|
fprintf(stderr, "%s: dst type %d invalide\n",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ extern int verbosity; /* must be declared around main() */
|
|||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/*
|
/*
|
||||||
* floating resultat img MUST be allocated before calling this func.
|
* floating resultat img MUST be allocated before calling this func.
|
||||||
|
* and MUST be of type 'gray image'.
|
||||||
*/
|
*/
|
||||||
int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k)
|
int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k)
|
||||||
{
|
{
|
||||||
@@ -43,15 +44,12 @@ if (FIMG_TYPE_RGB != src->type) {
|
|||||||
if (FIMG_TYPE_GRAY != dst->type) {
|
if (FIMG_TYPE_GRAY != dst->type) {
|
||||||
fprintf(stderr, "%s : bad dst type %d on %p\n", __func__,
|
fprintf(stderr, "%s : bad dst type %d on %p\n", __func__,
|
||||||
dst->type, dst);
|
dst->type, dst);
|
||||||
/*
|
/* may be we can convert dst picture on the fly ? */
|
||||||
* may be we can convert dst picture on the fly ?
|
|
||||||
*/
|
|
||||||
return -9;
|
return -9;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* entering the main processing loop */
|
/* entering the main processing loop */
|
||||||
nbb = src->width * src->height;
|
nbb = src->width * src->height;
|
||||||
|
|
||||||
for (foo=0; foo<nbb; foo++) {
|
for (foo=0; foo<nbb; foo++) {
|
||||||
dst->R[foo] = ( (src->R[foo] * kr) +
|
dst->R[foo] = ( (src->R[foo] * kr) +
|
||||||
(src->G[foo] * kg) +
|
(src->G[foo] * kg) +
|
||||||
@@ -79,7 +77,6 @@ if (FIMG_TYPE_RGB != src->type || FIMG_TYPE_RGB != dst->type) {
|
|||||||
|
|
||||||
/* entering the main processing loop */
|
/* entering the main processing loop */
|
||||||
nbb = src->width * src->height;
|
nbb = src->width * src->height;
|
||||||
|
|
||||||
for (foo=0; foo<nbb; foo++) {
|
for (foo=0; foo<nbb; foo++) {
|
||||||
dst->R[foo] = dst->G[foo] = dst->B[foo] =
|
dst->R[foo] = dst->G[foo] = dst->B[foo] =
|
||||||
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;
|
(src->R[foo] + src->G[foo] + src->B[foo]) / 3.0;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ fprintf(stderr, ">>> %-25s ( %p )\n", __func__, fimg);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (NULL == fimg) {
|
if (NULL == fimg) {
|
||||||
fprintf(stderr, "%s : parameter is null\n", __func__);
|
fprintf(stderr, "%s : descriptor address is null\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ if (memcmp(filehead.magic, "FIMG", 4)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX preparer la gestion des metadata */
|
/* XXX preparer la gestion des metadata */
|
||||||
if ('a' == filehead.magic[4]) {
|
if ('a' == filehead.magic[4] && verbosity > 1) {
|
||||||
fprintf(stderr,"\n\t****** %s have metadata\n\n", fname);
|
fprintf(stderr,"*** %s have metadata\n", fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
datas[0] = filehead.w;
|
datas[0] = filehead.w;
|
||||||
@@ -87,15 +87,15 @@ if (FIMG_TYPE_RGB != fimg->type) {
|
|||||||
/* OK, we have to make a fake metadata chunk, if the caller
|
/* OK, we have to make a fake metadata chunk, if the caller
|
||||||
* don't have one. Ugly, and nice */
|
* don't have one. Ugly, and nice */
|
||||||
if (NULL == pmd) {
|
if (NULL == pmd) {
|
||||||
fprintf(stderr, ">>> %s making faked metadata\n", __func__);
|
// fprintf(stderr, ">>> %s making faked metadata\n", __func__);
|
||||||
foo = fimg_default_metadata(&fakemd, 3);
|
foo = fimg_default_metadata(&fakemd, 3);
|
||||||
fprintf(stderr, "fakemd is at %p\n", &fakemd);
|
// fprintf(stderr, "fakemd is at %p\n", &fakemd);
|
||||||
pmd = &fakemd;
|
pmd = &fakemd;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* OK, get some funky metadatas */
|
/* OK, get some funky metadatas */
|
||||||
// fprintf(stderr, "%s get metadatas\n", __func__);
|
fprintf(stderr, "%s: acqu fval=%f count=%d\n", __func__,
|
||||||
fprintf(stderr, "acqu fval=%f count=%d\n", pmd->fval, pmd->count);
|
pmd->fval, pmd->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen(fname, "w");
|
fp = fopen(fname, "w");
|
||||||
@@ -178,11 +178,17 @@ if (FIMG_TYPE_RGB != fimg->type) {
|
|||||||
return -8;
|
return -8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fprintf(stderr, "'%s' try to open '%s'\n", __func__, fname);
|
||||||
fp = fopen(fname, "w");
|
fp = fopen(fname, "w");
|
||||||
if (NULL==fp) {
|
// fprintf(stderr, " fp at %p\n", fp);
|
||||||
|
|
||||||
|
if (NULL == fp) {
|
||||||
perror(fname);
|
perror(fname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// fprintf(stderr, "file '%s' opened\n", fname);
|
||||||
|
}
|
||||||
|
|
||||||
memset(&filehead, 0, sizeof(filehead));
|
memset(&filehead, 0, sizeof(filehead));
|
||||||
memcpy(filehead.magic, "FIMG", 4);
|
memcpy(filehead.magic, "FIMG", 4);
|
||||||
@@ -195,6 +201,9 @@ if (1 != foo) {
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
// fprintf(stderr, "'%s' write header --> %d\n", __func__, foo);
|
||||||
|
|
||||||
|
|
||||||
nbre = fimg->width * fimg->height; /* pixels per frame */
|
nbre = fimg->width * fimg->height; /* pixels per frame */
|
||||||
|
|
||||||
foo = fwrite(fimg->R, sizeof(float), nbre, fp);
|
foo = fwrite(fimg->R, sizeof(float), nbre, fp);
|
||||||
@@ -251,7 +260,8 @@ if ( (filehead.w != where->width) ||
|
|||||||
|
|
||||||
/* XXX preparer la gestion des metadata */
|
/* XXX preparer la gestion des metadata */
|
||||||
if ('a' == filehead.magic[4]) {
|
if ('a' == filehead.magic[4]) {
|
||||||
fprintf(stderr,"****** %s have metadata\n", fname);
|
if (verbosity > 1) fprintf(stderr,"%s say %s have metadata\n",
|
||||||
|
__func__, fname);
|
||||||
foo = fseek(fp, (long)sizeof(FimgMetaData), SEEK_CUR);
|
foo = fseek(fp, (long)sizeof(FimgMetaData), SEEK_CUR);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: seek error\n", __func__);
|
fprintf(stderr, "%s: seek error\n", __func__);
|
||||||
@@ -296,7 +306,8 @@ fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* may be we can crash coredump here if the head
|
* may be we can crash coredump here if the head
|
||||||
* descriptor from caller is not blank ?
|
* descriptor from caller is not blank ? Or just
|
||||||
|
* display a warning ?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fp = fopen(fname, "r");
|
fp = fopen(fname, "r");
|
||||||
@@ -327,12 +338,15 @@ if (foo) {
|
|||||||
/*
|
/*
|
||||||
* Oh boy, we have to skeep the metadata chunck
|
* Oh boy, we have to skeep the metadata chunck
|
||||||
*/
|
*/
|
||||||
if ('a' == filehead.magic[4]) {
|
if ('a' == filehead.magic[4]) {
|
||||||
if (verbosity)
|
if (verbosity > 1)
|
||||||
{ fprintf(stderr, "%s: %s has metadata\n", __func__, fname); }
|
{ fprintf(stderr, "in %s, %s has metadata\n", __func__, fname); }
|
||||||
|
/* old school processing...
|
||||||
foo = fseek(fp, (long)sizeof(FimgMetaData), SEEK_CUR);
|
foo = fseek(fp, (long)sizeof(FimgMetaData), SEEK_CUR);
|
||||||
if (foo) {
|
*/
|
||||||
fprintf(stderr, "%s : shit hit the fan\n", __func__);
|
foo = fread(&head->mdatas, sizeof(FimgMetaData), 1, fp);
|
||||||
|
if (1 != foo) {
|
||||||
|
fprintf(stderr, "%s: shit hit the fan %d\n", __func__, foo);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,37 @@ for (idx=0; idx<surface; idx++) {
|
|||||||
else if (fval > mmvals[5]) mmvals[5] = fval;
|
else if (fval > mmvals[5]) mmvals[5] = fval;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -0;
|
return 0;
|
||||||
|
}
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
/* new: Fri Oct 6 19:51:28 UTC 2023
|
||||||
|
*
|
||||||
|
* can compute the maxima of a lot of pictures...
|
||||||
|
*/
|
||||||
|
|
||||||
|
int fimg_max_of_max(FloatImg *img, float maxes[3])
|
||||||
|
{
|
||||||
|
float localmax[3];
|
||||||
|
int idx, surface;
|
||||||
|
float fval;
|
||||||
|
|
||||||
|
localmax[0] = localmax[1] = localmax[2] = -1e9;
|
||||||
|
|
||||||
|
surface = img->width * img->height;
|
||||||
|
for (idx=0; idx<surface; idx++) {
|
||||||
|
fval = img->R[idx];
|
||||||
|
if (fval > localmax[0]) localmax[0] = fval;
|
||||||
|
fval = img->G[idx];
|
||||||
|
if (fval > localmax[1]) localmax[1] = fval;
|
||||||
|
fval = img->B[idx];
|
||||||
|
if (fval > localmax[2]) localmax[2] = fval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localmax[0] > maxes[0]) maxes[0] = localmax[0];
|
||||||
|
if (localmax[1] > maxes[1]) maxes[1] = localmax[1];
|
||||||
|
if (localmax[2] > maxes[2]) maxes[2] = localmax[2];
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
int fimg_meanvalues(FloatImg *head, float means[4])
|
int fimg_meanvalues(FloatImg *head, float means[4])
|
||||||
@@ -144,7 +174,7 @@ for (idx=0; idx<4; idx++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
/* d'après Wikipedia Fr :
|
/* d'apres Wikipedia Fr :
|
||||||
| c = 0
|
| c = 0
|
||||||
| s = x1
|
| s = x1
|
||||||
| pour j de 2 à n
|
| pour j de 2 à n
|
||||||
@@ -171,9 +201,7 @@ if (head->type != FIMG_TYPE_RGB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (foo=0; foo<(head->width*head->height); foo++) {
|
for (foo=0; foo<(head->width*head->height); foo++) {
|
||||||
add = head->R[foo];
|
add = head->R[foo] + head->G[foo] + head->B[foo];
|
||||||
add += head->G[foo];
|
|
||||||
add += head->B[foo];
|
|
||||||
head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0;
|
head->R[foo] = head->G[foo] = head->B[foo] = add / 3.0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -380,7 +408,6 @@ for (idx=0; idx<surface; idx++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Warning: this function is _very_ slow */
|
/* Warning: this function is _very_ slow */
|
||||||
void fimg_drand48(FloatImg *fi, float kmul)
|
void fimg_drand48(FloatImg *fi, float kmul)
|
||||||
{
|
{
|
||||||
@@ -396,12 +423,14 @@ if (fi->type != FIMG_TYPE_RGB) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nbre = fi->width * fi->height;
|
nbre = fi->width * fi->height;
|
||||||
|
|
||||||
|
fprintf(stderr, "in %s, drand48() is %f\n", __func__, drand48());
|
||||||
|
|
||||||
for (idx=0; idx<nbre; idx++) {
|
for (idx=0; idx<nbre; idx++) {
|
||||||
fi->R[idx] = drand48() * kmul;
|
fi->R[idx] = drand48() * kmul;
|
||||||
fi->G[idx] = drand48() * kmul;
|
fi->G[idx] = drand48() * kmul;
|
||||||
fi->B[idx] = drand48() * kmul;
|
fi->B[idx] = drand48() * kmul;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ fprintf(stderr, ">>> %s ( %p %p %p %f )\n", __func__,
|
|||||||
s1, s2, d, coef);
|
s1, s2, d, coef);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* sanity check here ? or may be ask the
|
||||||
|
caller to do it himself ?
|
||||||
|
*/
|
||||||
|
if ( (coef < 0.0) || (coef >= 1.0) ){
|
||||||
|
fprintf(stderr, "%s: coef %f out of range\n", __func__, coef);
|
||||||
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
foo = fimg_images_not_compatible(s1, s2);
|
foo = fimg_images_not_compatible(s1, s2);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "compat s1 s2 -> %d\n", foo);
|
fprintf(stderr, "compat s1 s2 -> %d\n", foo);
|
||||||
@@ -66,6 +74,9 @@ switch (s1->type) {
|
|||||||
gray_interpolate (s1, s2, d, coef); break;
|
gray_interpolate (s1, s2, d, coef); break;
|
||||||
case FIMG_TYPE_RGB:
|
case FIMG_TYPE_RGB:
|
||||||
rgb_interpolate (s1, s2, d, coef); break;
|
rgb_interpolate (s1, s2, d, coef); break;
|
||||||
|
case FIMG_TYPE_RGBA:
|
||||||
|
fprintf(stderr, "WTF?\n");
|
||||||
|
return -18;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s, %d is a bad type\n", __func__, s1->type);
|
fprintf(stderr, "%s, %d is a bad type\n", __func__, s1->type);
|
||||||
return -18;
|
return -18;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* metadata.c
|
* metadata.c
|
||||||
|
* ----------
|
||||||
|
*
|
||||||
|
* This is not a stable version. You must expect problems,
|
||||||
|
* and the first one was time_t 32 vs. 64 bits.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -14,22 +19,6 @@
|
|||||||
|
|
||||||
extern int verbosity; /* must be declared around main() */
|
extern int verbosity; /* must be declared around main() */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
|
||||||
/*
|
|
||||||
* specific function because magic field is NOT an asciiz !
|
|
||||||
*/
|
|
||||||
static void puts_magic_8(char *ptr, FILE *fp)
|
|
||||||
{
|
|
||||||
int foo;
|
|
||||||
|
|
||||||
fputs("magic = ", fp);
|
|
||||||
fputc('[', fp);
|
|
||||||
for (foo=0; foo<8; foo++) {
|
|
||||||
fputc(ptr[foo], fp);
|
|
||||||
}
|
|
||||||
fputc(']', fp); fputc('\n', fp);
|
|
||||||
fflush(fp);
|
|
||||||
}
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused)
|
int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused)
|
||||||
{
|
{
|
||||||
@@ -46,16 +35,16 @@ if (notused) {
|
|||||||
notused, __func__);
|
notused, __func__);
|
||||||
}
|
}
|
||||||
if (NULL != title) {
|
if (NULL != title) {
|
||||||
fprintf(stderr, "==== metadate for %s\n", title);
|
fprintf(stderr, "======== metadata for %s\n", title);
|
||||||
}
|
}
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fprintf(stderr, "sizeof(metadata) = %ld\n", \
|
fprintf(stderr, "sizeof(metadata) = %ld\n", \
|
||||||
sizeof(FimgMetaData));
|
sizeof(FimgMetaData));
|
||||||
puts_magic_8(pmd->magic, stderr);
|
fprintf(stderr, " Magic [%08x]\n", pmd->magic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SHOW TIMESTAMP HERE */
|
/* SHOW TIMESTAMP HERE */
|
||||||
fprintf(stderr, "seconds sc. epoch = %ld\n", pmd->timestamp.tv_sec);
|
fprintf(stderr, "secs from epoch = %ld\n", pmd->timestamp.tv_sec);
|
||||||
fprintf(stderr, "date & time = %s", ctime(&pmd->timestamp.tv_sec));
|
fprintf(stderr, "date & time = %s", ctime(&pmd->timestamp.tv_sec));
|
||||||
doubletime = (double)pmd->timestamp.tv_sec + \
|
doubletime = (double)pmd->timestamp.tv_sec + \
|
||||||
(double)pmd->timestamp.tv_usec / 1e6;
|
(double)pmd->timestamp.tv_usec / 1e6;
|
||||||
@@ -75,13 +64,19 @@ fputc('\n', stderr);
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* those values may be loaded from a config file ?
|
||||||
|
*/
|
||||||
int fimg_default_metadata(FimgMetaData *pmd, int bla)
|
int fimg_default_metadata(FimgMetaData *pmd, int bla)
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
struct timeval tvl;
|
struct timeval tvl;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pmd, bla);
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(pmd, 0, sizeof(FimgMetaData));
|
memset(pmd, 0, sizeof(FimgMetaData));
|
||||||
memcpy(pmd->magic, "metadata", 8);
|
|
||||||
|
|
||||||
/* set timestamp here ? */
|
/* set timestamp here ? */
|
||||||
/* CHALLENGE ACCEPTED */
|
/* CHALLENGE ACCEPTED */
|
||||||
@@ -99,10 +94,11 @@ else {
|
|||||||
memcpy(&(pmd->timestamp), &tvl, sizeof(struct timeval));
|
memcpy(&(pmd->timestamp), &tvl, sizeof(struct timeval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pmd->magic = MAGIC_MDATA;
|
||||||
pmd->cpid = getpid(); // we are the creator, no ?
|
pmd->cpid = getpid(); // we are the creator, no ?
|
||||||
pmd->count = 1; // mmmm...
|
pmd->count = 1; // mmmm...
|
||||||
pmd->fval = 255.0; // Ok
|
pmd->fval = 255.0; // Ok
|
||||||
strcpy(pmd->idcam, "<noname>");
|
strcpy(pmd->idcam, "<noname camera>");
|
||||||
pmd->origin = 0xdeadbeef; // classic joke, sorry
|
pmd->origin = 0xdeadbeef; // classic joke, sorry
|
||||||
pmd->reserved[0] = bla;
|
pmd->reserved[0] = bla;
|
||||||
pmd->reserved[7] = 0x55445544; // magic number is a crime
|
pmd->reserved[7] = 0x55445544; // magic number is a crime
|
||||||
@@ -154,12 +150,13 @@ if (1 != foo) {
|
|||||||
|
|
||||||
fclose(fp); /* got all needed datas */
|
fclose(fp); /* got all needed datas */
|
||||||
|
|
||||||
if (memcmp(metadata.magic, "metadata", 8)) {
|
if (MAGIC_MDATA != metadata.magic) {
|
||||||
fprintf(stderr, "'%s' invalid metadata\n", fname);
|
fprintf(stderr, "%s: magic was %08X, wtf?\n", __func__,
|
||||||
puts_magic_8(metadata.magic, stderr);
|
metadata.magic);
|
||||||
return -6;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
memcpy(pmd, &metadata, sizeof(FimgMetaData));
|
memcpy(pmd, &metadata, sizeof(FimgMetaData));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
3
lib/t.c
3
lib/t.c
@@ -23,8 +23,7 @@ int foo;
|
|||||||
fprintf(stderr, "-------- %s ( %s ) --------\n", __func__, fname);
|
fprintf(stderr, "-------- %s ( %s ) --------\n", __func__, fname);
|
||||||
|
|
||||||
foo = fimg_default_metadata(&Md, 0);
|
foo = fimg_default_metadata(&Md, 0);
|
||||||
|
foo = fimg_show_metadata(&Md, "default from t.c", 0);
|
||||||
// foo = fimg_show_metadata(&Md, "default from t.c", 0);
|
|
||||||
|
|
||||||
foo = fimg_get_metadata_from_file(fname, &Md);
|
foo = fimg_get_metadata_from_file(fname, &Md);
|
||||||
fprintf(stderr, "%s : get metadata -> %d\n", fname, foo);
|
fprintf(stderr, "%s : get metadata -> %d\n", fname, foo);
|
||||||
|
|||||||
7
scripts/.gitignore
vendored
Normal file
7
scripts/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
*.fits
|
||||||
|
*.tiff
|
||||||
|
*.tif
|
||||||
|
*.png
|
||||||
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
# Exemples de scripts
|
# Exemples de scripts
|
||||||
|
|
||||||
_Attention_, ce ne sont que des exemples, pas forcément adaptés
|
_Attention_, ce ne sont que des exemples, pas forcément adaptés
|
||||||
à une utilisation dans le monde réel.
|
à une utilisation dans le monde réel. Mais vous pouvez vous en
|
||||||
|
inspirer pour vos usecases personnels.
|
||||||
|
|
||||||
## shoot.sh
|
## shoot.sh
|
||||||
|
|
||||||
@@ -20,5 +21,13 @@ en dur dans le code.
|
|||||||
Comment générer des videos psychotiques avec un peu de bash.
|
Comment générer des videos psychotiques avec un peu de bash.
|
||||||
Ce script est expliqué dans la documentation PDF.
|
Ce script est expliqué dans la documentation PDF.
|
||||||
|
|
||||||
|
## capture.sh & conf.sh
|
||||||
|
|
||||||
|
Ce [script](./capture.sh) sert à capturer une séquence d'image depuis
|
||||||
|
une webcam.
|
||||||
|
Deux choses à noter : il utilise un fichier de configuration
|
||||||
|
(`source [./conf.sh](./conf.sh)) pour ajuster son fonctionnement, et il
|
||||||
|
extrait juste une portion de l'image capturée. Une belle avancée,
|
||||||
|
puisque cela ajoute quelques possibilités de recadrage dès
|
||||||
|
la prise de vue.
|
||||||
|
|
||||||
|
|||||||
30
scripts/capture.sh
Executable file
30
scripts/capture.sh
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# CAPTURE
|
||||||
|
|
||||||
|
source ./conf.sh
|
||||||
|
|
||||||
|
DEVICE="/dev/video0"
|
||||||
|
GOPT=" -v -s 1920x1080 -p 0 -n 10"
|
||||||
|
OUTD=$GRABDIR
|
||||||
|
TMPG="/dev/shm/tmpgrab.fimg"
|
||||||
|
|
||||||
|
for idx in $(seq 0 2399)
|
||||||
|
do
|
||||||
|
|
||||||
|
# take the picz
|
||||||
|
${GRAB} -d ${DEVICE} ${GOPT} -o ${TMPG}
|
||||||
|
|
||||||
|
# display $TMPG
|
||||||
|
|
||||||
|
# only take the good spot
|
||||||
|
fimg=$(printf "%s/%05d.fimg" ${OUTD} ${idx})
|
||||||
|
${EXTR} -o ${fimg} ${TMPG} 800,600,560,240
|
||||||
|
|
||||||
|
# display ${fimg} ; exit
|
||||||
|
|
||||||
|
echo
|
||||||
|
sleep $DELAY_GRAB
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
34
scripts/conf.sh
Normal file
34
scripts/conf.sh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
# Sat Jul 8 10:41:58 UTC 2023
|
||||||
|
|
||||||
|
#
|
||||||
|
# location of some tools
|
||||||
|
#
|
||||||
|
|
||||||
|
GRAB="$HOME/Devel/FloatImg/v4l2/grabvidseq"
|
||||||
|
MKFX="$HOME/Devel/FloatImg/tools/fimgfx"
|
||||||
|
MDAT="$HOME/Devel/FloatImg/tools/fimgmetadata"
|
||||||
|
EXTR="$HOME/Devel/FloatImg/tools/fimgextract"
|
||||||
|
|
||||||
|
INTERPOLATOR="$HOME/Devel/FloatImg/Fonderie/interpolator"
|
||||||
|
FONDERIE="$HOME/Devel/FloatImg/Fonderie/fonderie"
|
||||||
|
SINGLEPASS="$HOME/Devel/FloatImg/Fonderie/singlepass"
|
||||||
|
|
||||||
|
#
|
||||||
|
# working directories
|
||||||
|
#
|
||||||
|
GRABDIR="rush"
|
||||||
|
GIFDIR="gif89a"
|
||||||
|
|
||||||
|
#
|
||||||
|
# text plotting conf
|
||||||
|
FONT="Noto-Sans-Bold"
|
||||||
|
KERNING=1
|
||||||
|
SIGNATURE="... tTh 2023 ..."
|
||||||
|
|
||||||
|
#
|
||||||
|
# filter chains for fondulations
|
||||||
|
#
|
||||||
|
IF="cos01:colmixa:pow2"
|
||||||
|
OF="shiftln0:liss3x3"
|
||||||
|
|
||||||
27
scripts/demo-fimgfx.sh
Executable file
27
scripts/demo-fimgfx.sh
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source="00000.fimg"
|
||||||
|
tmpimg="/dev/shm/demofx.fimg"
|
||||||
|
|
||||||
|
effects=$(fimgfx -l)
|
||||||
|
|
||||||
|
for fx in $effects
|
||||||
|
do
|
||||||
|
|
||||||
|
echo "============= " $fx
|
||||||
|
dst="${fx}.png"
|
||||||
|
echo " " ${source} ${dst}
|
||||||
|
|
||||||
|
fimgfx -v ${fx} ${source} ${tmpimg}
|
||||||
|
|
||||||
|
convert $tmpimg \
|
||||||
|
-fill black -stroke white \
|
||||||
|
-strokewidth 1 \
|
||||||
|
-pointsize 34 \
|
||||||
|
-font "Noto-Sans-Bold" \
|
||||||
|
-gravity South-East \
|
||||||
|
-annotate +32+10 "${fx}" \
|
||||||
|
${dst}
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
@@ -26,9 +26,9 @@ for idx in $(seq 0 $NBRE)
|
|||||||
do
|
do
|
||||||
# build the two input filenames ...
|
# build the two input filenames ...
|
||||||
#
|
#
|
||||||
imgA=$(printf "$SRCDIR/%04d.fimg" $idx)
|
imgA=$(printf "$SRCDIR/%05d.fimg" $idx)
|
||||||
vb=$(( $(( idx + OFFS )) % NBRE))
|
vb=$(( $(( idx + OFFS )) % NBRE))
|
||||||
imgB=$(printf "$SRCDIR/%04d.fimg" $vb)
|
imgB=$(printf "$SRCDIR/%05d.fimg" $vb)
|
||||||
|
|
||||||
# ... and the output filename
|
# ... and the output filename
|
||||||
#
|
#
|
||||||
|
|||||||
24
tools/.gitignore
vendored
Normal file
24
tools/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fimg2png
|
||||||
|
fimgextract
|
||||||
|
fimg2pnm
|
||||||
|
fimg2tiff
|
||||||
|
fimg2fits
|
||||||
|
fimg2text
|
||||||
|
fimgstats
|
||||||
|
fimghalfsize
|
||||||
|
mkfimg
|
||||||
|
png2fimg
|
||||||
|
addtga2fimg
|
||||||
|
addpnm2fimg
|
||||||
|
cumulfimgs
|
||||||
|
fimgops
|
||||||
|
fimgfx
|
||||||
|
fimgmetadata
|
||||||
|
fimgfilters
|
||||||
|
|
||||||
|
*.gif
|
||||||
|
*.png
|
||||||
|
*.tiff
|
||||||
@@ -13,12 +13,18 @@ DEPS = ../floatimg.h ../libfloatimg.a Makefile
|
|||||||
all: fimg2pnm mkfimg png2fimg fimgstats fimg2png \
|
all: fimg2pnm mkfimg png2fimg fimgstats fimg2png \
|
||||||
fimg2tiff fimg2text fimg2fits \
|
fimg2tiff fimg2text fimg2fits \
|
||||||
addpnm2fimg cumulfimgs fimgops fimgfx \
|
addpnm2fimg cumulfimgs fimgops fimgfx \
|
||||||
fimgmetadata \
|
fimgmetadata fimgfilters \
|
||||||
fimghalfsize
|
fimghalfsize fimgextract
|
||||||
|
|
||||||
|
fimgfilters: fimgfilters.c $(DEPS)
|
||||||
|
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||||
|
|
||||||
fimgmetadata: fimgmetadata.c $(DEPS)
|
fimgmetadata: fimgmetadata.c $(DEPS)
|
||||||
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||||
|
|
||||||
|
fimgextract: fimgextract.c $(DEPS)
|
||||||
|
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||||
|
|
||||||
fimgstats: fimgstats.c $(DEPS)
|
fimgstats: fimgstats.c $(DEPS)
|
||||||
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||||
|
|
||||||
@@ -30,7 +36,7 @@ mkfimg: mkfimg.c $(DEPS)
|
|||||||
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||||
|
|
||||||
fimgops: fimgops.c $(DEPS)
|
fimgops: fimgops.c $(DEPS)
|
||||||
gcc $(COPT) $< ../libfloatimg.a -o $@
|
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||||
|
|
||||||
fimgfx: fimgfx.c $(DEPS)
|
fimgfx: fimgfx.c $(DEPS)
|
||||||
gcc $(COPT) $< ../libfloatimg.a \
|
gcc $(COPT) $< ../libfloatimg.a \
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Images en virgule flottante, les outils.
|
# Images en virgule flottante, les outils.
|
||||||
|
|
||||||
Dans tous les cas, vous pouvez utiliser l'option `-h` pour avoir des
|
Dans tous les cas, vous pouvez utiliser l'option `-v`
|
||||||
explications sur ce que vous pouvez faire, et l'option `-v` pour suivre
|
(qui est bien mieux en premier sur la ligne de commande)
|
||||||
l'avancée des travaux.
|
pour suivre l'avancée des travaux et l'option `-h` pour
|
||||||
|
avoir des explications sur ce que vous pouvez faire,
|
||||||
|
|
||||||
## mkfimg
|
## mkfimg
|
||||||
|
|
||||||
@@ -11,7 +12,22 @@ Un [../scripts/demo-mkfimg.sh](script) permet de créer toutes
|
|||||||
les images disponibles.
|
les images disponibles.
|
||||||
|
|
||||||
L'option `-m` rajoute des méta-données, cette option
|
L'option `-m` rajoute des méta-données, cette option
|
||||||
**ne** doit **pas** encore être utilisée dans la vrai vie.
|
**ne** doit **pas** encore être utilisée dans la vrai vie, ymmv.
|
||||||
|
|
||||||
|
## cumulfimg
|
||||||
|
|
||||||
|
Procède à l'accumulation de plusieurs images flottantes,
|
||||||
|
c'est-à-dire en faire la moyenne.
|
||||||
|
Le nom par défaut du fichier résultant est `out.fimg`, mais peut
|
||||||
|
être changé avec l'option `-o`. Avec `-g` l'image de sortie
|
||||||
|
sera en niveau de gris.
|
||||||
|
|
||||||
|
Ce logicel gagnerait peut-être à utiliser un accumulateur
|
||||||
|
intermédiaire en double précision pour les cas limite,
|
||||||
|
ou une [méthode](https://orlp.net/blog/taming-float-sums/)
|
||||||
|
plus adaptée.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## fimgops
|
## fimgops
|
||||||
```
|
```
|
||||||
@@ -24,26 +40,56 @@ options:
|
|||||||
|
|
||||||
## fimgfx
|
## fimgfx
|
||||||
|
|
||||||
effects:
|
Available effects:
|
||||||
|
|
||||||
cos01 cos010 pow2 sqrt gray0 cmixa xper desat ctr2x2 mirror
|
cos01 cos010 pow2 sqrt gray0 cmixa xper desat ctr2x2 mirror
|
||||||
shift0 trimul classtrial binarize trinarize hilightr
|
shift0 trimul classtrial binarize trinarize hilightr
|
||||||
|
abs clamp fakol0 morph0 morph4 morph8 thermocol
|
||||||
|
|
||||||
|
Un [../scripts/demo-fimgfx.sh](script) permet de créer toutes
|
||||||
|
les images avec les effets disponibles.
|
||||||
|
Vous vous rendrez vite compte que certains ne semblent rien faire,
|
||||||
|
mais regardez plus attentivement...
|
||||||
|
|
||||||
## fimgstats
|
## fimgstats
|
||||||
|
|
||||||
Compute some useless numbers...
|
Compute some useless numbers, specially for the enduser...
|
||||||
|
|
||||||
## fimg2pnm - fimg2png - fimg2tiff - fimg2fips
|
## fimg2pnm - fimg2png - fimg2tiff - fimg2fips
|
||||||
|
|
||||||
Exportation d'image flottante vers divers formats. Certains d'entre eux
|
Exportation d'image flottante vers divers (et trop rares) formats.
|
||||||
ne sont gérés que de façon très rudimentaire.
|
Certains d'entre eux ne sont gérés que de façon très rudimentaire.
|
||||||
|
|
||||||
## fimg2text
|
## fimg2text
|
||||||
|
|
||||||
Nouveau de l'année 2020+1 : exfiltrer toutes des données d'une image flottante
|
Nouveau de l'année 2020+1 : exfiltrer toutes des données d'une image flottante
|
||||||
afin de les rendre machinables. Voir aussi *fimgmetadata*.
|
afin de les rendre machinables. Voir aussi *fimgmetadata*.
|
||||||
|
|
||||||
|
```
|
||||||
|
tth@redlady:~/Devel/FloatImg/tools$ ./fimg2text bar.fimg | head -5
|
||||||
|
0 0 123.701111 269.273682 10.732136
|
||||||
|
1 0 109.500832 265.568481 26.176439
|
||||||
|
2 0 128.529694 292.033844 37.591236
|
||||||
|
3 0 98.910492 234.900467 17.132524
|
||||||
|
4 0 187.679092 386.155609 36.663834
|
||||||
|
```
|
||||||
|
|
||||||
## fimgmetadata
|
## fimgmetadata
|
||||||
|
|
||||||
Nouveau avril 2022. Need more doc...
|
Affichage des informations diverses stockées dans un fichier `.fimg`,
|
||||||
Voir aussi *fimg2text*.
|
comme la date de prise de vue ou les réglages du logiciel
|
||||||
|
de capture.
|
||||||
|
|
||||||
|
Expect problems with `time_t` on 32 vs. 64 bits. Fix in
|
||||||
|
progress.
|
||||||
|
|
||||||
|
## fimgextract
|
||||||
|
|
||||||
|
En avril 2024, il sert à tester une nouvelle fonctionnalité :
|
||||||
|
la recopie des méta-données de l'image source.
|
||||||
|
|
||||||
|
$ fimgextract [options] source.fimg width,height,xpos,ypos
|
||||||
|
|
||||||
|
Les options utiles : `-o out.fimg` pour nommer le fichier de
|
||||||
|
sortie, et `-m` qui demande la recopie des metadatas.
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
|
|
||||||
@@ -40,12 +41,14 @@ void help(int v)
|
|||||||
puts("");
|
puts("");
|
||||||
puts("$ cumulfimgs a.fimg b.fimg c-fimg ...");
|
puts("$ cumulfimgs a.fimg b.fimg c-fimg ...");
|
||||||
puts("cumulator options :");
|
puts("cumulator options :");
|
||||||
|
puts("\t-a\tcompute average");
|
||||||
puts("\t-g\tconvert to gray level");
|
puts("\t-g\tconvert to gray level");
|
||||||
|
puts("\t-m\tcompute the max of the maxes");
|
||||||
puts("\t-o\tname of output file");
|
puts("\t-o\tname of output file");
|
||||||
puts("\t-s\trescale end image");
|
puts("\t-s\trescale end image");
|
||||||
puts("\t-v\tincrease verbosity");
|
puts("\t-v\tincrease verbosity");
|
||||||
puts("");
|
puts("");
|
||||||
if (verbosity) { puts("Xperiment"); fimg_print_version(v); }
|
fimg_print_version(v);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
@@ -59,21 +62,24 @@ int to_gray = 0;
|
|||||||
int experiment = 0;
|
int experiment = 0;
|
||||||
int rescale = 0;
|
int rescale = 0;
|
||||||
int src_loaded = 0;
|
int src_loaded = 0;
|
||||||
|
int minmax = 0;
|
||||||
|
|
||||||
char *output_file = "out.fimg";
|
char *output_file = "out.fimg";
|
||||||
FloatImg accu, temp;
|
FloatImg accu, temp;
|
||||||
float vals[6];
|
float vals[3];
|
||||||
|
|
||||||
g_width = g_height = 0;
|
g_width = g_height = 0;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "gho:svx")) != -1) {
|
while ((opt = getopt(argc, argv, "ghmo:svx")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'g': to_gray = 1; break;
|
case 'g': to_gray = 1; break;
|
||||||
case 'h': help(1); break;
|
case 'h': help(1); break;
|
||||||
|
case 'm': minmax++; break;
|
||||||
case 'o': output_file = optarg; break;
|
case 'o': output_file = optarg; break;
|
||||||
case 's': rescale = 1; break;
|
case 's': rescale = 1; break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'x': experiment++; break;
|
case 'x': experiment++; break;
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,9 +88,12 @@ 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
|
||||||
|
|
||||||
|
memset(vals, 0, 3*sizeof(float));
|
||||||
|
|
||||||
for (idx=optind; idx<argc; idx++) {
|
for (idx=optind; idx<argc; idx++) {
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "%5d %s\n", idx, argv[idx]);
|
fprintf(stderr, "---------------- %s\n", argv[idx]);
|
||||||
|
fflush(stderr);
|
||||||
#endif
|
#endif
|
||||||
foo = testfile(argv[idx]);
|
foo = testfile(argv[idx]);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
@@ -92,8 +101,15 @@ for (idx=optind; idx<argc; idx++) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* load the picture, create a clone of the first
|
||||||
|
*/
|
||||||
if ( ! src_loaded ) {
|
if ( ! src_loaded ) {
|
||||||
foo = fimg_create_from_dump(argv[idx], &accu);
|
foo = fimg_create_from_dump(argv[idx], &accu);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "create from dump -> %d\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
fimg_clone(&accu, &temp, 0);
|
fimg_clone(&accu, &temp, 0);
|
||||||
src_loaded = 1;
|
src_loaded = 1;
|
||||||
}
|
}
|
||||||
@@ -103,8 +119,20 @@ for (idx=optind; idx<argc; idx++) {
|
|||||||
fprintf(stderr, "load from dump -> %d\n", foo);
|
fprintf(stderr, "load from dump -> %d\n", foo);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fimg_add_2(&temp, &accu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (minmax) {
|
||||||
|
/*
|
||||||
|
* print the maximum values and compute the
|
||||||
|
* maximum of all the maximums
|
||||||
|
*/
|
||||||
|
foo = fimg_max_of_max(&temp, vals);
|
||||||
|
// fprintf(stderr, "%5d max of max %9.3f %9.3f %9.3f\n",
|
||||||
|
// idx, vals[0], vals[1], vals[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fimg_add_2(&temp, &accu);
|
||||||
|
|
||||||
compte++;
|
compte++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,11 +141,9 @@ if (rescale) {
|
|||||||
fimg_div_cste(&accu, (float)compte);
|
fimg_div_cste(&accu, (float)compte);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX */
|
|
||||||
if (experiment) {
|
|
||||||
|
|
||||||
}
|
fprintf(stderr, "max of max %9.3f %9.3f %9.3f\n",
|
||||||
/* XXX */
|
vals[0], vals[1], vals[2]);
|
||||||
|
|
||||||
|
|
||||||
if (to_gray) {
|
if (to_gray) {
|
||||||
@@ -155,6 +181,8 @@ if (verbosity) {
|
|||||||
vals[4], vals[5], vals[5]-vals[4]);
|
vals[4], vals[5], vals[5]-vals[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fimg_destroy(&accu); fimg_destroy(&temp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -32,27 +32,30 @@ if (foo) {
|
|||||||
|
|
||||||
fimg_destroy(&fimg);
|
fimg_destroy(&fimg);
|
||||||
|
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
static void help(int k)
|
static void help(int k)
|
||||||
{
|
{
|
||||||
puts("export to FITS format");
|
puts("export to FITS format");
|
||||||
puts("\t-p select colorplane : R, G, B");
|
puts("\t-p select colorplane : R, G, B");
|
||||||
|
puts("\t default is blue");
|
||||||
|
puts("\t-v increase verbosity");
|
||||||
fimg_print_version(k);
|
fimg_print_version(k);
|
||||||
}
|
}
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt, foo;
|
||||||
int plane = '?';
|
int plane = 'b';
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "p:hv")) != -1) {
|
while ((opt = getopt(argc, argv, "p:hv")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'p': plane = optarg[0]; break;
|
case 'p': plane = optarg[0]; break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'h': help(1); exit(1);
|
case 'h': help(1); exit(1);
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +64,11 @@ if (2 != argc-optind) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export_fimg_plane_as_fits(argv[optind], argv[optind+1], plane);
|
foo = export_fimg_plane_as_fits(argv[optind], argv[optind+1], plane);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "export_fimg_plane_as_fits --> %d\n", foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ return 0;
|
|||||||
void help(int k)
|
void help(int k)
|
||||||
{
|
{
|
||||||
|
|
||||||
puts("usage:\n\tfimg2png [options] foo.fimg bar.png");
|
puts("usage:\n\tfimg2png [options] from.fimg to.png");
|
||||||
puts("options:");
|
puts("options:");
|
||||||
puts("\t-g\tconvert to gray");
|
puts("\t-g\tconvert to gray");
|
||||||
puts("\t-v\tincrease verbosity");
|
puts("\t-v\tincrease verbosity");
|
||||||
@@ -80,6 +80,7 @@ while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
|||||||
case 'g': to_gray = 1; break;
|
case 'g': to_gray = 1; break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'h': help(1); exit(1);
|
case 'h': help(1); exit(1);
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +92,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 (foo) {
|
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);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
|||||||
case 'g': to_gray = 1; break;
|
case 'g': to_gray = 1; break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'h': help(1); exit(1);
|
case 'h': help(1); exit(1);
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,10 @@ int x, y;
|
|||||||
float rgb[3];
|
float rgb[3];
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %25s ( %p '%s' %d )\n", __func__,
|
fprintf(stderr, ">>> %s ( %p '%s' 0x%x )\n", __func__,
|
||||||
src, fname, flags);
|
src, fname, flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (0 != flags) {
|
|
||||||
fprintf(stderr, "bad flags in %s\n", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
fp = NULL; /* molly guard */
|
fp = NULL; /* molly guard */
|
||||||
if (strcmp("-", fname)) { /* real file */
|
if (strcmp("-", fname)) { /* real file */
|
||||||
fprintf(stderr, "real file '%s'\n", fname);
|
fprintf(stderr, "real file '%s'\n", fname);
|
||||||
@@ -38,6 +34,12 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fp = stdout; /* XXX */
|
fp = stdout; /* XXX */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* put a first line, so we can load those data with R
|
||||||
|
*/
|
||||||
|
if (flags & 1) { fputs("X Y R G B\n", fp); }
|
||||||
|
|
||||||
for (y=0; y<src->height; y+=steps) {
|
for (y=0; y<src->height; y+=steps) {
|
||||||
for (x=0; x<src->width; x+=steps) {
|
for (x=0; x<src->width; x+=steps) {
|
||||||
fimg_get_rgb(src, x, y, rgb);
|
fimg_get_rgb(src, x, y, rgb);
|
||||||
@@ -49,6 +51,9 @@ for (y=0; y<src->height; y+=steps) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
/*
|
||||||
|
* This function must be in the libfloatimg !
|
||||||
|
*/
|
||||||
static int normalize(FloatImg *pimg, float vmax)
|
static int normalize(FloatImg *pimg, float vmax)
|
||||||
{
|
{
|
||||||
float mmv[6], maxi, coef;
|
float mmv[6], maxi, coef;
|
||||||
@@ -85,14 +90,15 @@ return 0;
|
|||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int convertir_fimg_en_machinable(char *srcname, char *dstname,
|
int convertir_fimg_en_machinable(char *srcname, char *dstname,
|
||||||
int steps, float norm)
|
int steps, float norm, int header)
|
||||||
{
|
{
|
||||||
int foo, infos[3];
|
int foo, infos[3];
|
||||||
|
int flg;
|
||||||
FloatImg fimg;
|
FloatImg fimg;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %25s ( '%s' '%s' %d %f )\n", __func__,
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d %f %d )\n", __func__,
|
||||||
srcname, dstname, steps, norm);
|
srcname, dstname, steps, norm, header);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (steps < 1) {
|
if (steps < 1) {
|
||||||
@@ -100,12 +106,14 @@ if (steps < 1) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flg = 0;
|
||||||
|
if (header) flg |= 1;
|
||||||
|
|
||||||
foo = fimg_fileinfos(srcname, infos);
|
foo = fimg_fileinfos(srcname, infos);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo);
|
fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fprintf(stderr, "%s: image '%s' is %d x %d %s\n",
|
fprintf(stderr, "%s: image '%s' is %d x %d %s\n",
|
||||||
__func__,
|
__func__,
|
||||||
@@ -119,16 +127,12 @@ if (foo) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity) {
|
|
||||||
// fimg_describe(&fimg, srcname);
|
|
||||||
fprintf(stderr, "normalize to %f\n", norm);
|
|
||||||
}
|
|
||||||
if (norm > 0.0) {
|
if (norm > 0.0) {
|
||||||
// fprintf(stderr, "normalize %p\n", &fimg);
|
if (verbosity) fprintf(stderr, "normalize to %f\n", norm);
|
||||||
foo = normalize(&fimg, norm);
|
foo = normalize(&fimg, norm);
|
||||||
}
|
}
|
||||||
|
|
||||||
foo = export_as_machinable(&fimg, dstname, steps, 0);
|
foo = export_as_machinable(&fimg, dstname, steps, flg);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr,"%s: err %d on export\n", __func__, foo);
|
fprintf(stderr,"%s: err %d on export\n", __func__, foo);
|
||||||
}
|
}
|
||||||
@@ -141,9 +145,10 @@ void help(int k)
|
|||||||
{
|
{
|
||||||
puts("usage:\n\tfimg2text [options] foo.fimg > bar.csv");
|
puts("usage:\n\tfimg2text [options] foo.fimg > bar.csv");
|
||||||
puts("options:");
|
puts("options:");
|
||||||
puts("\t-v\t\tincrease verbosity");
|
puts("\t-n Value\tnormalize picture if Value > 0.0");
|
||||||
puts("\t-n 3.14\t\tnormalize picture");
|
|
||||||
puts("\t-s N\t\tsteps on x & y");
|
puts("\t-s N\t\tsteps on x & y");
|
||||||
|
puts("\t-T\t\tadd header with colon name");
|
||||||
|
puts("\t-v\t\tincrease verbosity");
|
||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
printf("*** compiled: %s at %s\n", __DATE__, __TIME__);
|
printf("*** compiled: %s at %s\n", __DATE__, __TIME__);
|
||||||
fimg_print_version(k);
|
fimg_print_version(k);
|
||||||
@@ -156,16 +161,19 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int foo, opt;
|
int foo, opt;
|
||||||
int steps = 1;
|
int steps = 1;
|
||||||
float norm_val = 222.0; /* < 0 : don't normalize */
|
int header = 0;
|
||||||
|
float norm_val = -1; /* < 0 : don't normalize */
|
||||||
// char separator = ' ';
|
// char separator = ' ';
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "f:hn:s:v")) != -1) {
|
while ((opt = getopt(argc, argv, "f:hn:s:Tv")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
// case 'f': separator = optarg[0]; break;
|
// case 'f': separator = optarg[0]; break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'h': help(1); exit(1);
|
case 'h': help(1); exit(1);
|
||||||
case 's': steps = atoi(optarg); break;
|
case 's': steps = atoi(optarg); break;
|
||||||
|
case 'T': header = 1; break;
|
||||||
case 'n': norm_val = atof(optarg); break;
|
case 'n': norm_val = atof(optarg); break;
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +182,8 @@ if (1 != argc-optind) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foo = convertir_fimg_en_machinable(argv[optind], "-", steps, norm_val);
|
foo = convertir_fimg_en_machinable(argv[optind], "-",
|
||||||
|
steps, norm_val, header);
|
||||||
if (foo) {
|
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 1;
|
return 1;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
|||||||
case 'g': to_gray = 1; break;
|
case 'g': to_gray = 1; break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'h': help(1); exit(1);
|
case 'h': help(1); exit(1);
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
148
tools/fimgextract.c
Normal file
148
tools/fimgextract.c
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* This thing is just a mess !
|
||||||
|
* ***************************
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
int verbosity; // nasty global var.
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau - Mon Apr 8 11:52:18 UTC 2024 */
|
||||||
|
int copy_metadata(FloatImg *src, FloatImg *dst)
|
||||||
|
{
|
||||||
|
FimgMetaData *mdsrc, *mddst;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mdsrc = &(src->mdatas); mddst = &(dst->mdatas);
|
||||||
|
if (verbosity) fprintf(stderr, "%s: %p --> %p\n", __func__, mdsrc, mddst);
|
||||||
|
|
||||||
|
mdsrc->reserved[1] = 0x55555555;
|
||||||
|
memcpy(mddst, mdsrc, sizeof(FimgMetaData));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
/* nouveau ~ 2 octobre 2022 */
|
||||||
|
int extractor(char *srcname, char *dstname, FimgArea51 *rect)
|
||||||
|
{
|
||||||
|
FloatImg src, dst;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %s %s %p )\n", __func__, srcname, dstname, rect);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (verbosity) {
|
||||||
|
print_rectangle((char *)__func__, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_create_from_dump(srcname, &src);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: load %s from dump --> %d\n", __func__,
|
||||||
|
srcname, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_create(&dst, rect->w, rect->h, 3);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: fimg create dst --> %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* REAL operation was here ! */
|
||||||
|
foo = fimg_extractor(&src, &dst, rect);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: fimg extractor --> %d\n", __func__, foo);
|
||||||
|
#ifdef MUST_ABORT
|
||||||
|
abort(); // kill me hardly !
|
||||||
|
#endif
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX
|
||||||
|
* may be we can also copy the metadate from src to dst ?
|
||||||
|
* with an option on the command line ?
|
||||||
|
*/
|
||||||
|
foo = copy_metadata(&src, &dst);
|
||||||
|
|
||||||
|
foo = fimg_dumpmd_to_file(&dst, dstname, NULL, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: dumping datas to '%s' give us a %d\n",
|
||||||
|
__func__, dstname, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
void help(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("-- Fimg Extractor -- lib v%d -- %s %s\n", FIMG_VERSION,
|
||||||
|
__DATE__, __TIME__);
|
||||||
|
|
||||||
|
puts("usage:\n\tfimgextract [options] source.fimg width,height,xpos,ypos");
|
||||||
|
puts("options:");
|
||||||
|
puts("\t-m\t\tcopy metadata bloc");
|
||||||
|
puts("\t-o out.fimg\tname the output file");
|
||||||
|
puts("\t-v\t\tmake me a blabla box");
|
||||||
|
puts("\t-x\t\tenable crashy feature");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo, idx;
|
||||||
|
int opt;
|
||||||
|
int experiment = 0;
|
||||||
|
FimgArea51 area;
|
||||||
|
char *output_file = "out.fimg";
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "ho:vx")) != -1) {
|
||||||
|
switch(opt) {
|
||||||
|
case 'h': help(); break;
|
||||||
|
case 'm': break;
|
||||||
|
case 'o': output_file = optarg; break;
|
||||||
|
case 'v': verbosity++; break;
|
||||||
|
case 'x': experiment++; break;
|
||||||
|
default: exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbosity) {
|
||||||
|
fprintf(stderr, "argc = %d optind = %d\n", argc, optind);
|
||||||
|
for (idx=optind; idx<argc; idx++) {
|
||||||
|
fprintf(stderr, " %5d %s\n", idx, argv[idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc==optind) {
|
||||||
|
fprintf(stderr, "what the fsck ?\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = parse_rectangle(argv[optind+1], &area, 0);
|
||||||
|
if (4 != foo) {
|
||||||
|
fprintf(stderr, "%s: parse_rectangle --> %d\n", argv[0], foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = extractor(argv[optind], output_file, &area);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: extractor --> %d\n", __func__, foo);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
85
tools/fimgfilters.c
Normal file
85
tools/fimgfilters.c
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
FIMGFILTERS
|
||||||
|
===========
|
||||||
|
new: Sun Oct 8 05:51:05 UTC 2023
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "../floatimg.h"
|
||||||
|
|
||||||
|
int verbosity;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int filtre_image(char *infname, char *outfname, int type)
|
||||||
|
{
|
||||||
|
FloatImg src, dst;
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
static FimgFilter3x3 filtre = {
|
||||||
|
{
|
||||||
|
2.0, 3.0, 2.0,
|
||||||
|
3.0, 4.0, 3.0,
|
||||||
|
2.0, 3.0, 2.0,
|
||||||
|
},
|
||||||
|
1.0/24.0, 0.0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, infname, outfname, type);
|
||||||
|
fimg_show_filter(NULL, &filtre);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (0 != type) {
|
||||||
|
fprintf(stderr, "%s: bad type %d\n", __func__, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((foo = fimg_create_from_dump(infname, &src))) {
|
||||||
|
fprintf(stderr, "read error on '%s' is %d\n", infname, foo);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
if ((foo = fimg_clone(&src, &dst, 0))) {
|
||||||
|
fprintf(stderr, "clone error on %p is %d\n", &src, foo);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_filter_3x3(&src, &dst, &filtre);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: filtre -> %d\n", __func__, foo);
|
||||||
|
exit(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = fimg_dump_to_file(&dst, outfname, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "dumping to file give us a %d\n", foo);
|
||||||
|
exit(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
|
||||||
|
if (3 != argc) {
|
||||||
|
fprintf(stderr, "usage: %s in.fimg out.fimg\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, " +++ %s +++\n", argv[0]);
|
||||||
|
|
||||||
|
foo = filtre_image(argv[1], argv[2], 0);
|
||||||
|
fprintf(stderr, " filtrage -> %d\n", foo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -28,7 +28,8 @@ enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0,
|
|||||||
Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm,
|
Fx_rot90, Fx_cmixa, Fx_desat, Fx_ctr2x2, Fx_norm,
|
||||||
Fx_classtrial, Fx_mirror, Fx_shift0, Fx_trimul,
|
Fx_classtrial, Fx_mirror, Fx_shift0, Fx_trimul,
|
||||||
Fx_xper, Fx_binarize, Fx_trinarize, Fx_hilight_R,
|
Fx_xper, Fx_binarize, Fx_trinarize, Fx_hilight_R,
|
||||||
Fx_absolute, Fx_clamp, Fx_fakol0 };
|
Fx_absolute, Fx_clamp, Fx_fakol0, Fx_fakol3,
|
||||||
|
Fx_morph0, Fx_morph4, Fx_morph8, Fx_thermocol };
|
||||||
|
|
||||||
Fx fx_list[] = {
|
Fx fx_list[] = {
|
||||||
{ "cos01", Fx_cos01, 0, 1 },
|
{ "cos01", Fx_cos01, 0, 1 },
|
||||||
@@ -53,6 +54,10 @@ Fx fx_list[] = {
|
|||||||
{ "abs", Fx_absolute, 0, 1 },
|
{ "abs", Fx_absolute, 0, 1 },
|
||||||
{ "clamp", Fx_clamp, 0, 1 },
|
{ "clamp", Fx_clamp, 0, 1 },
|
||||||
{ "fakol0", Fx_fakol0, 0, 1 },
|
{ "fakol0", Fx_fakol0, 0, 1 },
|
||||||
|
{ "morph0", Fx_morph0, 0, 1 },
|
||||||
|
{ "morph4", Fx_morph4, 0, 1 },
|
||||||
|
{ "morph8", Fx_morph8, 0, 1 },
|
||||||
|
{ "thermocol", Fx_thermocol, 0, 1 },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -261,6 +266,16 @@ switch (action) {
|
|||||||
foo = fimg_falsecolors_0(&src, &dest, 0, 1.0);
|
foo = fimg_falsecolors_0(&src, &dest, 0, 1.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Fx_morph0:
|
||||||
|
foo = fimg_filtre_morpho_0(&src, &dest, 0); break;
|
||||||
|
case Fx_morph4:
|
||||||
|
foo = fimg_filtre_morpho_0(&src, &dest, 4); break;
|
||||||
|
case Fx_morph8:
|
||||||
|
foo = fimg_filtre_morpho_0(&src, &dest, 8); break;
|
||||||
|
|
||||||
|
case Fx_thermocol:
|
||||||
|
foo = fimg_auto_thermique(&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);
|
||||||
@@ -300,6 +315,7 @@ while ((opt = getopt(argc, argv, "hk:lvx")) != -1) {
|
|||||||
case 'l': list_of_effects(); exit(0);
|
case 'l': list_of_effects(); exit(0);
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'x': break;
|
case 'x': break;
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
|||||||
case 'g': grayed = 1; break;
|
case 'g': grayed = 1; break;
|
||||||
case 'h': help(0); break;
|
case 'h': help(0); break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
int verbosity;
|
int verbosity;
|
||||||
|
|
||||||
enum comId { C_timestamp, C_daytime, C_count, C_fval, C_cpid, C_origin,
|
enum comId { C_timestamp, C_daytime, C_count, C_fval, C_cpid, C_origin,
|
||||||
C_idcam, C_all };
|
C_idcam, C_reserved, C_all, C_dayhour };
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
@@ -26,11 +26,13 @@ typedef struct {
|
|||||||
Cmd Cmd_list[] = {
|
Cmd Cmd_list[] = {
|
||||||
{ "timestamp", C_timestamp },
|
{ "timestamp", C_timestamp },
|
||||||
{ "daytime", C_daytime },
|
{ "daytime", C_daytime },
|
||||||
|
{ "dayhour", C_dayhour },
|
||||||
{ "cpid", C_cpid },
|
{ "cpid", C_cpid },
|
||||||
{ "count", C_count },
|
{ "count", C_count },
|
||||||
{ "fval", C_fval },
|
{ "fval", C_fval },
|
||||||
{ "origin", C_origin },
|
{ "origin", C_origin },
|
||||||
{ "idcam", C_idcam },
|
{ "idcam", C_idcam },
|
||||||
|
{ "reserved", C_reserved },
|
||||||
{ "all", C_all },
|
{ "all", C_all },
|
||||||
{ NULL, 0, }
|
{ NULL, 0, }
|
||||||
};
|
};
|
||||||
@@ -57,10 +59,35 @@ for (n=0, cmd=Cmd_list; cmd->name; cmd++, n++) {
|
|||||||
return -1; /* NOT FOUND */
|
return -1; /* NOT FOUND */
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
void list_commands(void)
|
||||||
|
{
|
||||||
|
Cmd *cmd;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
fputs("Commands:", stderr);
|
||||||
|
for (n=0, cmd=Cmd_list; cmd->name; cmd++) {
|
||||||
|
n += fprintf(stderr, " %s", cmd->name);
|
||||||
|
if (n > 40) {
|
||||||
|
fputs("\n ", stderr);
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fputs("\n", stderr);
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int show_reserved(FimgMetaData *pmd)
|
||||||
|
{
|
||||||
|
int foo;
|
||||||
|
for (foo=0; foo<8; foo++) printf("%08x ", pmd->reserved[foo]);
|
||||||
|
puts("");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
int get_print_metadata(char *fname, char *command)
|
int get_print_metadata(char *fname, char *command)
|
||||||
{
|
{
|
||||||
int foo, action;
|
int foo, action;
|
||||||
FimgMetaData metadata;
|
FimgMetaData metadata;
|
||||||
|
time_t tstamp;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, fname, command);
|
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, fname, command);
|
||||||
@@ -73,11 +100,15 @@ if (foo) return foo;
|
|||||||
action = lookup_cmd(command);
|
action = lookup_cmd(command);
|
||||||
// fprintf(stderr, " command '%s' -> %d\n", command, action);
|
// fprintf(stderr, " command '%s' -> %d\n", command, action);
|
||||||
|
|
||||||
|
tstamp = metadata.timestamp.tv_sec;
|
||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case C_timestamp:
|
case C_timestamp:
|
||||||
printf("timestamp %ld\n", metadata.timestamp.tv_sec); break;
|
printf("timestamp %ld\n", tstamp); break;
|
||||||
case C_daytime:
|
case C_daytime:
|
||||||
printf("%s\n", ctime(&metadata.timestamp.tv_sec)); break;
|
printf("%s\n", ctime(&tstamp)); break;
|
||||||
|
case C_dayhour:
|
||||||
|
printf("%s\n", ctime(&tstamp)); break;
|
||||||
case C_count:
|
case C_count:
|
||||||
printf("count %d\n", metadata.count); break;
|
printf("count %d\n", metadata.count); break;
|
||||||
case C_fval:
|
case C_fval:
|
||||||
@@ -88,6 +119,8 @@ switch(action) {
|
|||||||
printf("origin 0x%x\n", metadata.origin); break;
|
printf("origin 0x%x\n", metadata.origin); break;
|
||||||
case C_idcam:
|
case C_idcam:
|
||||||
printf("camid \"%s\"\n", metadata.idcam); break;
|
printf("camid \"%s\"\n", metadata.idcam); break;
|
||||||
|
case C_reserved:
|
||||||
|
show_reserved(&metadata); break;
|
||||||
case C_all:
|
case C_all:
|
||||||
fimg_show_metadata(&metadata, fname, 0); break;
|
fimg_show_metadata(&metadata, fname, 0); break;
|
||||||
default:
|
default:
|
||||||
@@ -101,6 +134,7 @@ void help(void)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "*** Fimg Metadata Reader (%s, %s)\n", __DATE__, __TIME__);
|
fprintf(stderr, "*** Fimg Metadata Reader (%s, %s)\n", __DATE__, __TIME__);
|
||||||
fimg_print_version(1);
|
fimg_print_version(1);
|
||||||
|
list_commands();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
@@ -113,6 +147,7 @@ while ((opt = getopt(argc, argv, "hv")) != -1) {
|
|||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'h': help(); break;
|
case 'h': help(); break;
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
|
default: exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user