minor changes

This commit is contained in:
tTh 2024-04-01 00:07:34 +02:00
parent fe3bc9d64c
commit 02b4493659
6 changed files with 31 additions and 22 deletions

View File

@ -27,7 +27,7 @@ fimg2obj: fimg2obj.c $(DEPS)
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
# ---------------------------------------------------------
# CACHE ENGINE
# CACHE ENGINE (wip)
cachengn.o: cachengn.c cachengn.h Makefile
gcc $(COPT) -c $<

View File

@ -51,7 +51,6 @@ if (foo) {
return -1;
}
foo = fimg_export_picture(&grande, outname, 0);
if (foo) {
fprintf(stderr, "%s: error %d export '%s'\n", __func__,

View File

@ -36,7 +36,7 @@ int init_empty_cache(int iw, int ih, int szc, int wtfparam)
{
int idx;
fprintf(stderr, ">>> %s ( %d %d %d %d )\n", __func__,
fprintf(stderr, ">>> %s ( %d %d %d %d )\n", __func__,
iw, ih, szc, wtfparam);
/* MOLLYGUARD : don't init TWICE, please */
@ -89,7 +89,7 @@ for (idx=0; idx<nombre_slots; idx++) {
}
}
/* we not have this picture in ou cache, so we need a free
/* we not have this picture in our cache, so we need a free
slot for it */
freeslot = -1;
for (idx=0; idx<nombre_slots; idx++) {
@ -103,9 +103,10 @@ fprintf(stderr, "freeslot = %d\n", freeslot);
/* check if we can read this file */
foo = access(fname, R_OK); /* XXX */
if (foo) {
perror(__FILE__ ": give_me_thiz_picz");
perror("give_me_thiz_picz");
return NULL;
}
fprintf(stderr, "file '%s' is readble\n", fname);
/* try to load the requested file */
foo = fimg_create_from_dump(fname, &img);
@ -113,8 +114,7 @@ if (foo) {
fprintf(stderr, "oups on %s\n", fname);
return NULL;
}
/* OK we have all the pixels in core memorey */
/* OK, we have all the pixels in core memory */
return NULL;
}

View File

@ -62,14 +62,14 @@ if (NULL == counts) {
}
nbpix = img->width * img->height;
minp = 1e10, maxp = -1e10;
minp = 1e30, maxp = -1e30;
for (offset=0; offset<nbpix; offset++) {
pixel = img->R[offset];
if (pixel < minp) minp = pixel;
if (pixel > maxp) maxp = pixel;
}
fprintf(stderr, " values = %g < %g\n", minp, maxp);
// fprintf(stderr, " values = %g < %g\n", minp, maxp);
*pmax = maxp; /* copy value for the caller */
@ -111,9 +111,11 @@ fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
/*
* trying some preprocessor filters
*/
//foo = fimg_lissage_2x2(src);
foo = fimg_lissage_3x3(src);
if (foo) fprintf(stderr, " lissage -> %d\n", foo);
if (foo) fprintf(stderr, " lissage 1 -> %d\n", foo);
foo = fimg_lissage_3x3(src);
if (foo) fprintf(stderr, " lissage 2 -> %d\n", foo);
foo = fimg_killborders(src);
if (foo) fprintf(stderr, " killborder -> %d\n", foo);
@ -128,6 +130,7 @@ if (foo) {
fprintf(stderr, "create tmp pic --> %d\n", foo);
return foo;
}
/* calcul de la pente : a vérifier ! */
for (y=0; y<(src->height-1); y++) {
for (x=0; x<(src->width-1); x++) {
@ -147,11 +150,11 @@ for (y=0; y<(src->height-1); y++) {
foo = calcul_histo_gray(&tmp, "histogramme.data", 499, &maxp);
if (foo) fprintf(stderr, "<<< calcul histo -> %d\n", foo);
minp = 1e10;
seuil = 0.700 * maxp;
fprintf(stderr, " seuil = %f\n", seuil);
/* ésotérisme, quand tu nous tiens... */
for (offset=0; offset<(src->width*src->height); offset++) {
pente = tmp.R[offset];
if (pente > seuil) {
@ -162,12 +165,17 @@ for (offset=0; offset<(src->width*src->height); offset++) {
// fprintf(stderr, " minp = %f maxp = %f\n", minp, maxp);
/* recopie dans l'image destination avec translation hauteur */
fimg_clear(dst);
for (offset=0; offset<(src->width*src->height); offset++) {
pente = tmp.R[offset] - minp;
if (pente < 0.0) pente = 0.0;
dst->R[offset] = pente;
dst->G[offset] = pente;
dst->B[offset] = pente;
if (pente < 0.0) {
dst->R[offset] = -pente;
dst->G[offset] = -pente;
}
else {
dst->B[offset] = pente;
dst->G[offset] = pente;
}
}
foo = fimg_killborders(dst);

View File

@ -69,8 +69,7 @@ for (yd=0; yd<pdst->height; yd++) {
if ( xs<0 || xs>psrc->width ||
ys<0 || ys>psrc->height ) {
rgb[0] = maxv; /* fucking bug XXX */
rgb[1] = rgb[2] = 0.0;
rgb[0] = rgb[1] = rgb[2] = 0.0;
outside++;
}
else {
@ -79,7 +78,6 @@ for (yd=0; yd<pdst->height; yd++) {
}
fimg_put_rgb(pdst, xd, yd, rgb);
}
}
@ -89,7 +87,10 @@ for (yd=0; yd<pdst->height; yd++) {
return 0;
}
/* ------------------------------------------------------------------- */
/*
* High level operateur, taking care of opening/closing
* files and doing memory management
*/
int move_the_pixels(char *infile, char *statfile, char *outfile, int k)
{
int foo;
@ -145,9 +146,10 @@ srcfile = argv[1];
dstfile = argv[2];
verbosity = 0;
foo = move_the_pixels(srcfile, "cumul.fimg", dstfile, 3);
/* XXX the static picture file MUST be selectable by the yuser ! */
foo = move_the_pixels(srcfile, "reference.fimg", dstfile, 3);
// fprintf(stderr, "move pixels %s -> %s = %d\n", srcfile, dstfile, foo);
fprintf(stderr, "move pixels %s -> %s = %d\n", srcfile, dstfile, foo);
return 0;
}

0
experiment/remotegrab.c Normal file
View File