Compare commits

...

7 Commits

Author SHA1 Message Date
tth
5a90dce59d doc + demo 2021-05-29 13:01:32 +02:00
tth
17955bd303 we can list all the garbage... 2021-05-29 09:33:38 +02:00
tth
865cc60ccf + stdint.h 2021-05-29 09:05:02 +02:00
tth
f77a63b08c bla 2021-05-27 17:57:35 +02:00
tth
389beea6cd + stdint.h / +debug code 2021-05-27 16:55:54 +02:00
tth
b2d2c45be1 planomuxer: step 1 2021-05-26 11:31:52 +02:00
tth
468b5feb74 + stdint.h 2021-05-25 12:01:56 +02:00
11 changed files with 184 additions and 12 deletions

1
.gitignore vendored
View File

@ -84,4 +84,5 @@ experiment/extracteur
experiment/*.fimg experiment/*.fimg
experiment/*.pnm experiment/*.pnm
experiment/*.o experiment/*.o
experiment/muxplanes

View File

@ -4,6 +4,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include "../floatimg.h" #include "../floatimg.h"
#include "metriques.h" #include "metriques.h"

View File

@ -6,10 +6,13 @@ COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm
DEPS = ../floatimg.h ../libfloatimg.a Makefile DEPS = ../floatimg.h ../libfloatimg.a Makefile
LIBS = -ltiff -lpnglite -lcfitsio LIBS = -ltiff -lpnglite -lcfitsio
all: assemblage extracteur all: assemblage extracteur muxplanes
assemblage: assemblage.c ${DEPS} assemblage: assemblage.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@ gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
extracteur: extracteur.c ${DEPS} extracteur: extracteur.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@ gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
muxplanes: muxplanes.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -4,11 +4,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h>
#include "../floatimg.h" #include "../floatimg.h"
// #include "incrustator.h"
int verbosity; int verbosity;
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */ /* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
@ -24,7 +23,7 @@ float rgb[3];
if (verbosity) { if (verbosity) {
fimg_describe(in, "source"); fimg_describe(in, "source");
fimg_describe(out, "destination"); fimg_describe(out, "destination");
print_rectangle(__func__, rect); print_rectangle((char *)__func__, rect);
} }
count = 0; count = 0;

97
experiment/muxplanes.c Normal file
View File

@ -0,0 +1,97 @@
/*
* another ugly experiment
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <strings.h>
#include "../floatimg.h"
int verbosity;
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int triplane_muxer(FloatImg *sr, FloatImg *sg, FloatImg *sb,
FloatImg *dst, int flages)
{
int foo;
int sz;
if (FIMG_TYPE_RGB != dst->type) {
fprintf(stderr, "%s: dst picz must be RGB, was %d\n",
__func__, dst->type);
return -99;
}
if ( fimg_images_not_compatible(sr, sg) ||
fimg_images_not_compatible(sr, sb) ||
fimg_images_not_compatible(sr, dst) ) {
fprintf(stderr, "%s: compatibility error\n", __func__);
return -2;
}
sz = sr->width * sr->height * sizeof(float);
memcpy(dst->R, sr->R, sz);
memcpy(dst->G, sg->G, sz);
memcpy(dst->B, sb->B, sz);
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int try_this_muxplane(char *fr, char *fg, char *fb, char *dst, int flags)
{
int foo;
FloatImg imr, img, imb, dest;
fprintf(stderr, "muxing: %s %s %s --> %s\n", fr, fg, fb, dst);
foo = fimg_create_from_dump(fr, &imr);
if (foo) {
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
return -1;
}
foo = fimg_create_from_dump(fg, &img);
if (foo) {
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
return -1;
}
foo = fimg_create_from_dump(fb, &imb);
if (foo) {
fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr);
return -1;
}
fimg_clone(&imr, &dest, 0);
foo = triplane_muxer(&imr, &img, &imb, &dest, 0);
if (foo) {
fprintf(stderr, "%s: err %d\n", __func__, foo);
return foo;
}
fimg_export_picture(&dest, dst, 0);
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int main(int argc, char *argv[])
{
int foo;
if (5 != argc) {
fprintf(stderr, "ERROR: %s need four fimg files arguments\n", argv[0]);
return 1;
}
foo = try_this_muxplane(argv[1], argv[2], argv[3], argv[4], 0);
if (foo) {
fprintf(stderr, "oups %d\n", foo);
exit(1);
}
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */

24
experiment/tripla.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
GRABOPT=" -vv -d /dev/video0 -n 400 -p 0.5 -u "
SPOOL=${HOME}/TMP
echo ; echo ; echo
for capture in red green blue
do
image=${SPOOL}/${capture}.fimg
echo grabbing $image
grabvidseq ${GRABOPT} -o $image
echo
done
./muxplanes "${SPOOL}/red.fimg" \
"${SPOOL}/green.fimg" \
"${SPOOL}/blue.fimg" \
yo.fimg
echo $0 "got a" $?
fimgstats -v yo.fimg

13
scripts/demo-mkfimg.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
echo "=== make a lot of float img ==="
MKFIMG="../tools/mkfimg"
SIZE=" 640x480 "
for type in $(${MKFIMG} -L)
do
picname="/tmp/${type}.fimg"
echo $picname
${MKFIMG} -v -t $type $picname $SIZE
done

View File

@ -1,17 +1,31 @@
# 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 `-h` pour avoir des
explications sur ce que vous pouvez faire. explications sur ce que vous pouvez faire, et l'option `-v` pour suivre
l'avancée des travaux.
## mkfimg ## mkfimg
Génération d'une image flottante avec des choses dedans.
Un [../scripts/demo-mkfimg.sh](script) permet de créer toutes
les images disponibles.
## fimgops ## fimgops
## fimgfx ## fimgfx
effects:
cos01 cos010 pow2 sqrt gray0 cmixa xper desat ctr2x2 mirror
shift0 trimul classtrial binarize trinarize hilightr
## fimgstats ## fimgstats
## fimg2pnm - fimg2png Compute some useless numbers...
## fimg2pnm - fimg2png - fimg2tiff
Exportation d'image flottante vers divers formats. Certains d'entre eux
ne sont gérés que de façon très rudimentaire.
## fimg2text ## fimg2text

View File

@ -49,8 +49,6 @@ Type *type;
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name); fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name);
#endif #endif
// #define TEST(str) ( ! strcmp(name, str) )
for (type = types; type->code; type++) { for (type = types; type->code; type++) {
if (!strcmp(name, type->name)) { if (!strcmp(name, type->name)) {
return type->code; return type->code;
@ -60,6 +58,16 @@ for (type = types; type->code; type++) {
return -1; return -1;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void list_types(void)
{
Type *type;
for (type = types; type->code; type++) {
puts(type->name);
}
exit(0);
}
/* --------------------------------------------------------------------- */
static void help(int lj) static void help(int lj)
{ {
int foo, cc; int foo, cc;
@ -67,6 +75,7 @@ int foo, cc;
puts("Usage:\tmkfimg [options] quux.fimg width height"); puts("Usage:\tmkfimg [options] quux.fimg width height");
puts("\t-k N.N\tgive a float parameter"); puts("\t-k N.N\tgive a float parameter");
puts("\t-L\tlist howto make a pic");
fputs("\t-t bla\thowto make the pic :\n\t\t| ", stdout); fputs("\t-t bla\thowto make the pic :\n\t\t| ", stdout);
for (foo=cc=0; types[foo].code; foo++) { for (foo=cc=0; types[foo].code; foo++) {
@ -95,12 +104,13 @@ char *tname = "wtf?";
FloatImg fimg; FloatImg fimg;
while ((opt = getopt(argc, argv, "hk:t:v")) != -1) { while ((opt = getopt(argc, argv, "hk:Lt:v")) != -1) {
switch(opt) { switch(opt) {
case 'h': help(0); break; case 'h': help(0); break;
case 'k': fvalue = atof(optarg); break; case 'k': fvalue = atof(optarg); break;
case 't': type = get_type_by_name(tname=optarg); case 't': type = get_type_by_name(tname=optarg);
break; break;
case 'L': list_types(); break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
} }
} }

View File

@ -1,6 +1,9 @@
/*
* UGLY CODE INSIDE
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include "../floatimg.h" #include "../floatimg.h"
#include "funcs.h" #include "funcs.h"
@ -85,6 +88,11 @@ int x_add_rgb2fimg(unsigned char *src, int w, int h, FloatImg *d)
int iter, size; int iter, size;
float *rp, *gp, *bp; float *rp, *gp, *bp;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %p )\n", __func__,
src, w, h, d);
#endif
size = w * h; size = w * h;
rp = d->R, gp = d->G, bp = d->B; rp = d->R, gp = d->G, bp = d->B;