forked from tTh/FloatImg
79 lines
1.6 KiB
C
79 lines
1.6 KiB
C
/*
|
|
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;
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
int filtre_image(char *infname, char *outfname)
|
|
{
|
|
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
|
|
};
|
|
|
|
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, infname, outfname);
|
|
|
|
fimg_show_filter(NULL, &filtre);
|
|
|
|
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);
|
|
}
|
|
|
|
return -12;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
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]);
|
|
|
|
foo = filtre_image(argv[1], argv[2]);
|
|
fprintf(stderr, " filtrage -> %d\n", foo);
|
|
|
|
return 0;
|
|
}
|
|
/* --------------------------------------------------------------------- */
|
|
|