Zzzzz....

This commit is contained in:
2020-02-29 21:59:12 +01:00
parent f9467dacee
commit 248061f46b
5 changed files with 249 additions and 20 deletions

View File

@@ -13,14 +13,68 @@ int verbosity;
float global_fvalue;
/* --------------------------------------------------------------------- */
int essai_filtrage(char *infile)
int essai_filtrage_3x3(char *infile)
{
FloatImg src, dst;
int foo, idx;
char buffer[100];
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
};
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
};
if (NULL != infile) {
fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s is creating the picz\n", __func__);
fimg_create(&src, 640, 480, FIMG_TYPE_RGB);
fimg_test_pattern(&src, 0, 255.0);
fimg_save_as_png(&src, "test.png", 0);
}
foo = fimg_clone(&src, &dst, 0);
fimg_filter_3x3(&src, &dst, &filter_b);
foo = fimg_clamp_negativ(&dst);
if (foo) {
fprintf(stderr, "clamped %d negativ pixels\n", foo);
}
foo = fimg_save_as_png(&dst, "f3x3.png", 0);
foo = fimg_save_as_pnm(&dst, "f3x3.pnm", 0);
fimg_destroy(&src); fimg_destroy(&dst);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_filtrage_2x2(char *infile)
{
FloatImg fimg;
int foo, idx;
char buffer[100];
if (NULL != infile) {
fprintf(stderr, "loading %s\n", infile);
fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &fimg);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
@@ -39,11 +93,13 @@ foo = fimg_save_as_pnm(&fimg, "source.pnm", 0);
* running multiple filters so you can
* watch the up-left shift :)
*/
for (idx=0; idx<10; idx++) {
for (idx=0; idx<5; idx++) {
foo = fimg_lissage_2x2(&fimg);
foo = fimg_killborders(&fimg);
sprintf(buffer, "filter%03d.png", idx);
foo = fimg_save_as_png(&fimg, buffer, 0);
if (verbosity) {
fprintf(stderr, "%s %d\n", buffer, foo);
}
}
fimg_destroy(&fimg);
@@ -238,11 +294,19 @@ fprintf(stderr, "argc %d optind %d\n", argc, optind);
filename = NULL;
if (1 == argc-optind) filename = argv[optind];
foo = essai_filtrage(filename);
/*
foo = essai_filtrage_2x2(filename);
if (foo) {
fprintf(stderr, "====> %d\n", foo);
fprintf(stderr, "Filtre 2x2 ====> %d\n", foo);
}
*/
foo = essai_filtrage_3x3(filename);
if (foo) {
fprintf(stderr, "Filtre 3x3 ====> %d\n", foo);
}
fprintf(stderr, "++++++++++++++ end of pid %d\n", getpid());
return 0;
}
/* --------------------------------------------------------------------- */