Compare commits

...

2 Commits

Author SHA1 Message Date
tTh
c004f22b16 cosmetic 2023-01-22 15:32:09 +01:00
tTh
d58decefcb demo_fmorph: 1ere version 2023-01-22 15:26:55 +01:00
8 changed files with 139 additions and 7 deletions

2
contrib/.gitignore vendored
View File

@ -5,5 +5,5 @@ demo_fmorph
*.tga
*.png
*.pnm
*.gif
*.fimg
pov.stderr

View File

@ -1,7 +1,18 @@
DBGL = '-DDEBUG_LEVEL=1 -g '
DBGL = -DDEBUG_LEVEL=1 -g
fimg2povhf: fimg2povhf.c Makefile
gcc -Wall $(DBGL) $< -limage -lfloatimg -lm -o $@
# --------------------------------------------------------
demo_fmorph: demo_fmorph.c Makefile
gcc -Wall $(DBGL) $< -lfloatimg -lpnglite -lm -o $@
in.fimg: Makefile
mkfimg -t tpat0 -v $@ 640 480
out.png: in.fimg demo_fmorph
./demo_fmorph $< $@
# --------------------------------------------------------

116
contrib/demo_fmorph.c Normal file
View File

@ -0,0 +1,116 @@
/*
* DEMONSTRATOR FOR FMORPHO
*/
#include <stdio.h>
#include <stdlib.h>
#include <floatimg.h>
int verbosity = 1;
#define DF_W 512
#define DF_H 128
/* ~~~ -------------------------------------------------------------- +++ */
int demo_fmorph(char *srcf, char *dsti, int mode)
{
FloatImg simg, // image source
timg, uimg, // intermediaires
dimg; // destination
FimgArea51 rect;
char line[200];
int foo, pass, hpos;
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__, srcf, dsti, mode);
/*
* chargement image source
*/
foo = fimg_create_from_dump(srcf, &simg);
fprintf(stderr, " load of %s --> %d\n", srcf, foo);
if (foo) {
return foo;
}
/*
* images temporaires
*/
foo = fimg_create(&timg, DF_W, DF_H, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create T img\n", foo);
return foo;
}
foo = fimg_create(&uimg, DF_W, DF_H, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create U img\n", foo);
return foo;
}
/*
* image de destination
*/
foo = fimg_create(&dimg, DF_W, DF_H*9, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create D img\n", foo);
return foo;
}
/*
* this is an iterator
*/
rect.x = 20; rect.y = 20;
rect.w = DF_W; rect.h = DF_H;
for (pass=0; pass<9; pass++) {
hpos = pass * DF_H;
fprintf(stderr, "pass %d, hpos %d\n", pass, hpos);
foo = fimg_extractor(&simg, &timg, &rect);
// sprintf(line, "S_%02d.png", pass);
// foo = fimg_save_as_png(&timg, line, 0);
foo = fimg_filtre_morpho_0(&timg, &uimg, pass);
if (foo) {
fprintf(stderr, "err %d filtre morpho, pass %d\n",
foo, pass);
exit(1);
}
sprintf(line, "D_%02d.png", pass);
foo = fimg_save_as_png(&uimg, line, 0);
foo = fimg_incrustator_0(&uimg, &dimg, 0, hpos, 0);
if (foo) {
fprintf(stderr, "err %d incrustator\n", foo);
exit(1);
}
}
foo = fimg_save_as_png(&dimg, dsti, 0);
/*
* do some cleanup
*/
fimg_destroy(&simg); fimg_destroy(&timg); fimg_destroy(&dimg);
return 0;
}
/* ~~~ -------------------------------------------------------------- +++ */
int main(int argc, char *argv[])
{
int foo;
fimg_print_version(1);
if (3 != argc) {
fprintf(stderr, "usage:\n\t%s src.fimg dst.png\n", argv[0]);
exit(1);
}
foo = demo_fmorph(argv[1], argv[2], 0);
fprintf(stderr, " got --> %d\n", foo);
return 0;
}
/* ~~~ -------------------------------------------------------------- +++ */

View File

@ -22,7 +22,6 @@ float minmax[6];
float rgb[3];
float dltr, dltg, dltb; /* delta des minmax */
float dispx, dispy;
int dstx, dsty;
int in, out;
@ -83,9 +82,7 @@ for (y=0; y<psrc->height; y++) {
fimg_put_rgb(pdst, dstx, dsty, rgb);
in++;
}
}
}
if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out);

View File

@ -171,7 +171,7 @@ unsigned char *bytes, *bptr;
double maximum, fk;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %-25s ( %p '%s' 0x%x )\n", __func__, src, outname, flags);
fprintf(stderr, ">>> %s ( %p '%s' 0x%x )\n", __func__, src, outname, flags);
#endif
if (flags) {

View File

@ -123,7 +123,6 @@ fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, in, out, rect);
if (verbosity > 1) {
fimg_describe(in, "extractor: source");
fimg_describe(out, "extractor: destination");
// print_rectangle(rect);
}
/*

View File

@ -47,6 +47,9 @@ return -1;
}
*/
/* ---------------------------------------------------------------- */
/*
* See also: fimg_extractor() in geometry.c
*/
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags)
{

View File

@ -22,6 +22,12 @@ int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused)
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused);
#endif
if (notused) {
fprintf(stderr, "%s parameter notused is %d, must be 0\n",
__func__, notused);
return -2;
}
fprintf(stderr, "!!!!!! %s is a wip !!!!!\n", __func__);
/*