Compare commits

...

3 Commits

Author SHA1 Message Date
tth
a9e03371b8 Merge branch 'master' of ssh://tetalab.org:2213/tTh/FloatImg
another bug in the wall ?
2021-02-23 03:54:10 +01:00
tth
d867b905a8 tracking a math bug in filters3x3 2021-02-23 03:49:24 +01:00
tth
c6f10d642a + diagonal filter 2021-02-23 03:22:14 +01:00
7 changed files with 59 additions and 19 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

@ -9,7 +9,8 @@ FILTRES=$(./t -L | awk 'NR>1 { print $1 }' | sort)
rm /tmp/fstack*.png 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 for F in $FILTRES
do do
@ -53,6 +54,6 @@ ffmpeg -nostdin \
# ------------------------------------------------------------ # ------------------------------------------------------------
# MAIN # MAIN
essai_singlepass essai_filtres
# ------------------------------------------------------------ # ------------------------------------------------------------

View File

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

View File

@ -48,7 +48,7 @@ for (y=1; y < h-1; y++) {
M[7] * pr[of+w] + M[7] * pr[of+w] +
M[8] * pr[of+(w-1)] ; M[8] * pr[of+(w-1)] ;
dst->R[of] = dval; dst->R[of] = dval + filtr->offset;
dval = M[0] * pg[of-(w+1)] + dval = M[0] * pg[of-(w+1)] +
M[1] * pg[of-w] + M[1] * pg[of-w] +
@ -60,7 +60,7 @@ for (y=1; y < h-1; y++) {
M[7] * pg[of+w] + M[7] * pg[of+w] +
M[8] * pg[of+(w-1)] ; M[8] * pg[of+(w-1)] ;
dst->G[of] = dval; dst->G[of] = dval + filtr->offset;
dval = M[0] * pb[of-(w+1)] + dval = M[0] * pb[of-(w+1)] +
M[1] * pb[of-w] + M[1] * pb[of-w] +
@ -72,7 +72,7 @@ for (y=1; y < h-1; y++) {
M[7] * pb[of+w] + M[7] * pb[of+w] +
M[8] * pb[of+(w-1)] ; M[8] * pb[of+(w-1)] ;
dst->B[of] = dval; dst->B[of] = dval + filtr->offset;
} }
} }
@ -189,7 +189,6 @@ if (foo) {
return foo; return foo;
} }
/* XXX */
fimg_killborders(img); fimg_killborders(img);
return foo; return foo;

View File

@ -323,7 +323,7 @@ FimgFilter3x3 filter_a = {
{ 1.0, 1.0, 1.0, { 1.0, 1.0, 1.0,
1.0, -3.0, 1.0, 1.0, -3.0, 1.0,
1.0, 1.0, 1.0 }, 1.0, 1.0, 1.0 },
8.0, 0.0 9.0, 0.0
}; };
@ -336,6 +336,15 @@ FimgFilter3x3 filter_b = {
}; };
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) { if (NULL != infile) {
fprintf(stderr, "%s: loading %s\n", __func__, infile); fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src); foo = fimg_create_from_dump(infile, &src);
@ -351,6 +360,8 @@ else {
} }
// fimg_save_as_png(&src, "test.png", 0); // 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); foo = fimg_clone(&src, &dst, 0);
if (foo) { if (foo) {
@ -359,21 +370,27 @@ if (foo) {
} }
fimg_filter_3x3(&src, &dst, &filter_a); fimg_filter_3x3(&src, &dst, &filter_a);
foo = fimg_clamp_negativ(&dst); foo = fimg_clamp_negativ(&dst);
if (foo) { 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); // foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
fimg_filter_3x3(&src, &dst, &filter_b); fimg_filter_3x3(&src, &dst, &filter_b);
foo = fimg_clamp_negativ(&dst); foo = fimg_clamp_negativ(&dst);
if (foo) { 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_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_pnm(&dst, "f3x3a.pnm", 0); // foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
fimg_destroy(&src); fimg_destroy(&dst); fimg_destroy(&src); fimg_destroy(&dst);