Browse Source

je crois que je suis en train de foutre la grouille...

master
tonton th 2 years ago
parent
commit
dc4f2f8089
  1. 1
      .gitignore
  2. 28
      Fonderie/crapulator.c
  3. 1
      Fonderie/crapulors.liste
  4. 5
      Fonderie/essai.sh
  5. 4
      Fonderie/fonctions.c
  6. 35
      Fonderie/fonderie.c
  7. 2
      floatimg.h
  8. 9
      funcs/filtrage.c
  9. 33
      funcs/tests.c
  10. 29
      tools/png2fimg.c
  11. 5
      v4l2/grabvidseq.c

1
.gitignore vendored

@ -67,6 +67,7 @@ Fonderie/*.o @@ -67,6 +67,7 @@ Fonderie/*.o
Fonderie/*.png
Fonderie/*.pnm
Fonderie/*.gif
Fonderie/*.fimg
Fonderie/fonderie
Fonderie/interpolator
Fonderie/t

28
Fonderie/crapulator.c

@ -14,6 +14,8 @@ @@ -14,6 +14,8 @@
#include "glitches.h"
#include "sfx.h"
extern int verbosity;
/* -------------------------------------------------------------- */
static int trier_les_pixels(FloatImg *pimg)
{
@ -76,7 +78,7 @@ return 0; @@ -76,7 +78,7 @@ return 0;
static int insitu_filtre3x3(FloatImg *pimg, int typef)
{
FloatImg img;
int retval;
int foo, retval;
FimgFilter3x3 *pfiltre;
FimgFilter3x3 lowpass = {
@ -97,9 +99,19 @@ FimgFilter3x3 hipass = { @@ -97,9 +99,19 @@ FimgFilter3x3 hipass = {
1.0, 0.0
};
FimgFilter3x3 diagonal = {
{
2.0, 1.0, 0.0,
1.0, 0.0, -1.0,
0.0, -1.0, -2.0,
},
1.0, 4.0
};
switch (typef) {
case 0: pfiltre = &lowpass; break;
case 1: pfiltre = &hipass; break;
case 2: pfiltre = &diagonal; break;
default:
fprintf(stderr, "%s: bad filter number %d\n",
__func__, typef);
@ -114,7 +126,14 @@ if (retval) { @@ -114,7 +126,14 @@ if (retval) {
fprintf(stderr, "%s error %d on filter\n", __func__, retval);
exit(1);
}
fimg_killborders(&img); /* XXX WTF OMG */
/** may be, we can check for negative values ? */
if (verbosity > 1) {
foo = fimg_count_negativ(&img);
fprintf(stderr, "%s -> %d / %d negative pixels\n", __func__,
foo, img.width*img.height);
}
fimg_killborders(&img);
fimg_copy_data(&img, pimg);
fimg_destroy(&img);
@ -194,7 +213,7 @@ switch (idFx) { @@ -194,7 +213,7 @@ switch (idFx) {
break;
case CR_liss2x2:
retval = fimg_lissage_2x2(image);
(void)fimg_killborders(image);
// (void)fimg_killborders(image);
break;
case CR_liss3x3:
/* smooth filter */
@ -220,6 +239,9 @@ switch (idFx) { @@ -220,6 +239,9 @@ switch (idFx) {
/* hipass filter */
retval = insitu_filtre3x3(image, 1);
break;
case CR_diagonal:
retval = insitu_filtre3x3(image, 2);
break;
case CR_octotree:
retval = octotree_classif(image, 0.500, 0);
break;

1
Fonderie/crapulors.liste

@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
27 shiftln0 1 1.0
28 qsortrgb 2 1.0
30 multidots 100 1.333
31 diagonal 1 1.0
42 nothing 42 3.1415926
99 message 1 1.0
-1 end 1 1.0

5
Fonderie/essai.sh

@ -9,7 +9,8 @@ FILTRES=$(./t -L | awk 'NR>1 { print $1 }' | sort) @@ -9,7 +9,8 @@ FILTRES=$(./t -L | awk 'NR>1 { print $1 }' | sort)
rm /tmp/fstack*.png
SRC=$(ls -rt1 $HOME/Essais/FondageDePlomb/capture/* | tail -1)
# SRC=$(ls -rt1 $HOME/Essais/FondageDePlomb/capture/* | tail -1)
SRC=mire.fimg
for F in $FILTRES
do
@ -53,6 +54,6 @@ ffmpeg -nostdin \ @@ -53,6 +54,6 @@ ffmpeg -nostdin \
# ------------------------------------------------------------
# MAIN
essai_singlepass
essai_filtres
# ------------------------------------------------------------

4
Fonderie/fonctions.c

@ -120,10 +120,6 @@ int insert_picture(FloatImg *src) @@ -120,10 +120,6 @@ int insert_picture(FloatImg *src)
FloatImg *dst;
int nbre;
/*
* this is the where we can insert the 'input filter'
*/
dst = &g_fifo.slots[g_fifo.next];
nbre = dst->width * dst->height * sizeof(float);

35
Fonderie/fonderie.c

@ -43,20 +43,49 @@ int insert_blank(FloatImg *image, int nbre, int pproc, @@ -43,20 +43,49 @@ int insert_blank(FloatImg *image, int nbre, int pproc,
float fval, char *outd)
{
int idx, foo;
int preloaded = 0;
FloatImg blank;
char *fname;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %f '%s' )\n", __func__,
image, nbre, pproc, fval, outd);
#endif
if (NULL != (fname=getenv("BLANK_FIMG"))) {
fprintf(stderr,"%s: try to load %s\n", __func__, fname);
fimg_clone(image, &blank, 1);
foo = fimg_load_from_dump(fname, &blank);
if (foo) {
fprintf(stderr, "epic fail %d on %s\n", foo, fname);
exit(1);
}
if (verbosity) fimg_describe(&blank, "Blank pic");
preloaded = 1;
}
fimg_clear(image);
for (idx=0; idx<nbre; idx++) {
fimg_vdeg_a(image, fval);
// brotche_rand48_b(image, drand48()*0.10, 1e5);
if (preloaded) {
fimg_copy_data(&blank, image);
}
else {
fimg_hdeg_a(image, fval);
}
if ((foo=traite_une_image(image, pproc, 1, outd))) {
fprintf(stderr, "%s : err %d from 'traite_une_image'\n",
__func__, foo);
break;
}
printf("\t%c\r", "ABCDEF"[idx%6]); fflush(stdout);
printf("\t%c\r", "ABCDEFGH"[idx%8]); fflush(stdout);
}
puts("");
if (preloaded) {
fimg_destroy(&blank);
}
return 0;
}
/* -------------------------------------------------------------- */

2
floatimg.h

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
* ugly code from tTh
*/
#define FIMG_VERSION 118
#define FIMG_VERSION 119
/*
* in memory descriptor

9
funcs/filtrage.c

@ -15,7 +15,7 @@ float *M; /* alias of filter matrix */ @@ -15,7 +15,7 @@ float *M; /* alias of filter matrix */
double dval;
#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
if (src->type != FIMG_TYPE_RGB) {
@ -48,7 +48,7 @@ for (y=1; y < h-1; y++) { @@ -48,7 +48,7 @@ for (y=1; y < h-1; y++) {
M[7] * pr[of+w] +
M[8] * pr[of+(w-1)] ;
dst->R[of] = dval;
dst->R[of] = dval + filtr->offset;
dval = M[0] * pg[of-(w+1)] +
M[1] * pg[of-w] +
@ -60,7 +60,7 @@ for (y=1; y < h-1; y++) { @@ -60,7 +60,7 @@ for (y=1; y < h-1; y++) {
M[7] * pg[of+w] +
M[8] * pg[of+(w-1)] ;
dst->G[of] = dval;
dst->G[of] = dval + filtr->offset;
dval = M[0] * pb[of-(w+1)] +
M[1] * pb[of-w] +
@ -72,7 +72,7 @@ for (y=1; y < h-1; y++) { @@ -72,7 +72,7 @@ for (y=1; y < h-1; y++) {
M[7] * pb[of+w] +
M[8] * pb[of+(w-1)] ;
dst->B[of] = dval;
dst->B[of] = dval + filtr->offset;
}
}
@ -189,7 +189,6 @@ if (foo) { @@ -189,7 +189,6 @@ if (foo) {
return foo;
}
/* XXX */
fimg_killborders(img);
return foo;

33
funcs/tests.c

@ -323,7 +323,7 @@ FimgFilter3x3 filter_a = { @@ -323,7 +323,7 @@ FimgFilter3x3 filter_a = {
{ 1.0, 1.0, 1.0,
1.0, -3.0, 1.0,
1.0, 1.0, 1.0 },
8.0, 0.0
9.0, 0.0
};
@ -332,10 +332,19 @@ FimgFilter3x3 filter_b = { @@ -332,10 +332,19 @@ FimgFilter3x3 filter_b = {
{ -2.0, -1.0, 0.0,
-1.0, 3.0, 1.0,
0.0, 1.0, 2.0 },
8.0, 0.0
8.0, 0.0
};
FimgFilter3x3 filter_c = {
{
2.0, 1.0, 0.0,
1.0, 0.0, -1.0,
0.0, -1.0, -2.0,
},
1.0, 8.0
};
if (NULL != infile) {
fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
@ -351,6 +360,8 @@ else { @@ -351,6 +360,8 @@ else {
}
// fimg_save_as_png(&src, "test.png", 0);
foo = fimg_count_negativ(&src);
fprintf(stderr, "%s: source have %d negs\n", __func__, foo);
foo = fimg_clone(&src, &dst, 0);
if (foo) {
@ -359,21 +370,27 @@ if (foo) { @@ -359,21 +370,27 @@ if (foo) {
}
fimg_filter_3x3(&src, &dst, &filter_a);
foo = fimg_clamp_negativ(&dst);
if (foo) {
fprintf(stderr, "clamped %d negative pixels\n", foo);
fprintf(stderr, "A clamped %d negative pixels\n", foo);
}
// foo = fimg_save_as_png(&dst, "f3x3a.png", 0);
foo = fimg_save_as_png(&dst, "f3x3a.png", 0);
// foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
fimg_filter_3x3(&src, &dst, &filter_b);
foo = fimg_clamp_negativ(&dst);
if (foo) {
fprintf(stderr, "clamped %d negative pixels\n", foo);
fprintf(stderr, "B clamped %d negative pixels\n", foo);
}
foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
// foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
fimg_filter_3x3(&src, &dst, &filter_c);
foo = fimg_clamp_negativ(&dst);
if (foo) {
fprintf(stderr, "C clamped %d negative pixels\n", foo);
}
// foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
// foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
fimg_destroy(&src); fimg_destroy(&dst);

29
tools/png2fimg.c

@ -16,33 +16,42 @@ @@ -16,33 +16,42 @@
int verbosity = 0;
/* --------------------------------------------------------------------- */
void help(int k)
{
if (verbosity) fimg_print_version(k);
exit(0);
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
FloatImg fimg;
int foo;
int foo, opt;
/*
* pas de traitement des options ?
*/
while ((opt = getopt(argc, argv, "hv")) != -1) {
switch(opt) {
case 'v': verbosity++; break;
case 'h': help(1); exit(1);
}
}
if (3 != argc) {
fimg_print_version(1);
fprintf(stderr, "usage:\n\t%s foo.png bar.fimg\n", argv[0]);
if (2 != argc-optind) {
fprintf(stderr, "error: %s need two filenames\n", argv[0]);
exit(1);
}
memset(&fimg, 0, sizeof(FloatImg));
foo = fimg_create_from_png(argv[1], &fimg);
foo = fimg_create_from_png(argv[optind], &fimg);
if (foo) {
fprintf(stderr, "%s : err %d, abort.\n", argv[0], foo);
exit(1);
}
if (verbosity) fimg_describe(&fimg, argv[2]);
if (verbosity) fimg_describe(&fimg, argv[optind+1]);
foo = fimg_dump_to_file(&fimg, argv[2], 0);
foo = fimg_dump_to_file(&fimg, argv[optind+1], 0);
if (foo) {
fprintf(stderr, "save as '%s' -> err %d\n", argv[2], foo);
exit(1);

5
v4l2/grabvidseq.c

@ -168,6 +168,11 @@ if (verbosity > 1) { @@ -168,6 +168,11 @@ if (verbosity > 1) {
if (upscaling) fprintf(stderr, "upscaling is on\n");
}
if (upscaling && (nbre_capt%4)) {
fprintf(stderr, "WARN upscaling: %d bad nbre_capt\n",
nbre_capt);
}
fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
if (fd < 0) {
perror(dev_name);

Loading…
Cancel
Save