add 'fimg_lissage_3x3' function

This commit is contained in:
tTh 2023-07-05 10:59:06 +02:00
parent 54b061232d
commit 99bbd20b47
2 changed files with 40 additions and 2 deletions

View File

@ -20,7 +20,7 @@
* https://git.tetalab.org/tTh/FloatImg
*/
#define FIMG_VERSION (223)
#define FIMG_VERSION (224)
#define RELEASE_NAME ("noname")
/* XXX add a test for stdint.h / uint32_t XXX */
@ -153,6 +153,7 @@ typedef struct {
*/
int fimg_killborders(FloatImg *img);
int fimg_lissage_2x2(FloatImg *img);
int fimg_lissage_3x3(FloatImg *img);
int fimg_show_filter(char *title, FimgFilter3x3 *filtr);
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);

View File

@ -200,7 +200,6 @@ for (idx=0; idx<h; idx++) {
}
o = w * (h - 1);
for (idx=0; idx<w; idx++) {
#if FAST
img->R[idx] = 0.0;
@ -233,4 +232,42 @@ fimg_killborders(img);
return foo;
}
/* -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- */
int fimg_lissage_3x3(FloatImg *img)
{
int foo;
FloatImg tmp;
fprintf(stderr, ">>> %s ( %p )\n", __func__, img);
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_destroy(&tmp);
if (foo) {
fprintf(stderr, "%s: destroy -> %d\n", __func__, foo);
abort();
}
fimg_killborders(img);
return 0;
}
/* -------------------------------------------------------------------- */