2023-10-08 18:38:42 +11:00
|
|
|
/*
|
|
|
|
FIMGFILTERS
|
|
|
|
===========
|
|
|
|
new: Sun Oct 8 05:51:05 UTC 2023
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
int verbosity;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
2023-11-29 21:25:43 +11:00
|
|
|
int filtre_image(char *infname, char *outfname, int type)
|
2023-10-08 18:38:42 +11:00
|
|
|
{
|
|
|
|
FloatImg src, dst;
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
static FimgFilter3x3 filtre = {
|
|
|
|
{
|
|
|
|
2.0, 3.0, 2.0,
|
|
|
|
3.0, 4.0, 3.0,
|
|
|
|
2.0, 3.0, 2.0,
|
|
|
|
},
|
|
|
|
1.0/24.0, 0.0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-11-29 21:25:43 +11:00
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, infname, outfname, type);
|
2023-10-08 18:38:42 +11:00
|
|
|
fimg_show_filter(NULL, &filtre);
|
2023-11-29 21:25:43 +11:00
|
|
|
#endif
|
2023-10-08 18:38:42 +11:00
|
|
|
|
2024-03-25 01:24:09 +11:00
|
|
|
if (0 != type) {
|
|
|
|
fprintf(stderr, "%s: bad type %d\n", __func__, type);
|
|
|
|
}
|
|
|
|
|
2023-10-08 18:38:42 +11:00
|
|
|
if ((foo = fimg_create_from_dump(infname, &src))) {
|
|
|
|
fprintf(stderr, "read error on '%s' is %d\n", infname, foo);
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
if ((foo = fimg_clone(&src, &dst, 0))) {
|
|
|
|
fprintf(stderr, "clone error on %p is %d\n", &src, foo);
|
|
|
|
exit(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
foo = fimg_filter_3x3(&src, &dst, &filtre);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: filtre -> %d\n", __func__, foo);
|
|
|
|
exit(4);
|
|
|
|
}
|
|
|
|
|
|
|
|
foo = fimg_dump_to_file(&dst, outfname, 0);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "dumping to file give us a %d\n", foo);
|
2023-11-29 21:25:43 +11:00
|
|
|
exit(5);
|
2023-10-08 18:38:42 +11:00
|
|
|
}
|
|
|
|
|
2023-11-29 21:25:43 +11:00
|
|
|
return 0;
|
2023-10-08 18:38:42 +11:00
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
if (3 != argc) {
|
|
|
|
fprintf(stderr, "usage: %s in.fimg out.fimg\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, " +++ %s +++\n", argv[0]);
|
|
|
|
|
2023-11-29 21:25:43 +11:00
|
|
|
foo = filtre_image(argv[1], argv[2], 0);
|
2023-10-08 18:38:42 +11:00
|
|
|
fprintf(stderr, " filtrage -> %d\n", foo);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|