Compare commits

...

3 Commits

Author SHA1 Message Date
tth
9fda48ab30 adding mollyguard 2020-10-14 10:32:29 +02:00
tth
947152532d more extension tets 2020-10-12 15:55:06 +02:00
tth
8206a1ac0a add "reverse flag" to fimg_contour_2x2 2020-10-10 12:34:29 +02:00
5 changed files with 62 additions and 10 deletions

View File

@ -98,7 +98,7 @@ int fimg_lissage_2x2(FloatImg *img);
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr); int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int notused); int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse);
/* 'sfx0' module */ /* 'sfx0' module */
int fimg_killcolors_a(FloatImg *fimg, float fval); int fimg_killcolors_a(FloatImg *fimg, float fval);

View File

@ -21,9 +21,19 @@ float range, dist, rgb[3], dr, dg, db;
int x, y, on, off; int x, y, on, off;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__, psrc, pdst, fval, notused); fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__,
psrc, pdst, fval, notused);
#endif #endif
if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7;
}
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
return -8;
}
/* calculer les amplitudes RGB de l'image source */ /* calculer les amplitudes RGB de l'image source */
fimg_get_minmax_rgb(psrc, minmax); fimg_get_minmax_rgb(psrc, minmax);
delta[0] = minmax[1] - minmax[0]; delta[0] = minmax[1] - minmax[0];

View File

@ -14,10 +14,11 @@ int verbosity;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* nouveau 4 octobre 2020, juste avant sonoptic de la pluie craignos */ /* nouveau 4 octobre 2020, juste avant sonoptic de la pluie craignos */
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int notused) int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse)
{ {
float avg[4]; float avg[4];
int foo, x, y, q; int foo, x, y, q;
float v1, v2;
int tbl[] = /* deep magic inside */ int tbl[] = /* deep magic inside */
{ {
@ -28,9 +29,26 @@ int tbl[] = /* deep magic inside */
}; };
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, reverse);
#endif #endif
if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7;
}
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
return -8;
}
if (reverse) {
v1 = 0.0; v2 = 1.0;
}
else {
v1 = 1.0; v2 = 0.0;
}
foo = fimg_meanvalues(psrc, avg); foo = fimg_meanvalues(psrc, avg);
if (verbosity) { if (verbosity) {
fprintf(stderr, "mean values : %f %f %f\n", avg[0], avg[1], avg[2]); fprintf(stderr, "mean values : %f %f %f\n", avg[0], avg[1], avg[2]);
@ -48,19 +66,19 @@ for (y=0; y<psrc->height-1; y++) {
( RP(x+1, y) << 2 ) | ( RP(x+1, y) << 2 ) |
( RP(x, y+1) << 1 ) | ( RP(x, y+1) << 1 ) |
( RP(x+1, y+1) ) ); ( RP(x+1, y+1) ) );
pdst->R[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ; pdst->R[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
q = ( ( GP(x, y) << 3 ) | q = ( ( GP(x, y) << 3 ) |
( GP(x+1, y) << 2 ) | ( GP(x+1, y) << 2 ) |
( GP(x, y+1) << 1 ) | ( GP(x, y+1) << 1 ) |
( GP(x+1, y+1) ) ); ( GP(x+1, y+1) ) );
pdst->G[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ; pdst->G[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
q = ( ( BP(x, y) << 3 ) | q = ( ( BP(x, y) << 3 ) |
( BP(x+1, y) << 2 ) | ( BP(x+1, y) << 2 ) |
( BP(x, y+1) << 1 ) | ( BP(x, y+1) << 1 ) |
( BP(x+1, y+1) ) ); ( BP(x+1, y+1) ) );
pdst->B[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ; pdst->B[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
} }

View File

@ -27,6 +27,15 @@ int foo, szimg;
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
#endif #endif
if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7;
}
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
return -8;
}
foo = fimg_copy_data(psrc, pdst); foo = fimg_copy_data(psrc, pdst);
szimg = pdst->width * pdst->height; szimg = pdst->width * pdst->height;
@ -44,7 +53,7 @@ typedef struct {
float r, g, b; float r, g, b;
} pix; } pix;
static compare_b(const void *p1, const void *p2) static int compare_b(const void *p1, const void *p2)
{ {
pix *s1, *s2; pix *s1, *s2;
s1 = (pix *)p1; s1 = (pix *)p1;
@ -62,6 +71,15 @@ float rgb[3];
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
#endif #endif
if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7;
}
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
return -8;
}
szimg = pdst->width * pdst->height; szimg = pdst->width * pdst->height;
fprintf(stderr, "%s : %d pixels\n", __func__, szimg); fprintf(stderr, "%s : %d pixels\n", __func__, szimg);

View File

@ -78,7 +78,7 @@ else {
fimg_clone(&src, &dst, 1); fimg_clone(&src, &dst, 1);
foo = fimg_contour_2x2(&src, &dst, 0); foo = fimg_contour_2x2(&src, &dst, 1);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d in contour_2x2\n", __func__, foo); fprintf(stderr, "%s: err %d in contour_2x2\n", __func__, foo);
return foo; return foo;
@ -456,6 +456,12 @@ printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.png"); foo = format_from_extension(fname="foo.png");
printf("%-10s %d\n\n", fname, foo); printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.tiff");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.fits");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.xyzzy"); foo = format_from_extension(fname="foo.xyzzy");
printf("%-10s %d\n\n", fname, foo); printf("%-10s %d\n\n", fname, foo);
@ -688,7 +694,7 @@ if (foo) {
fprintf(stderr, "Essai ====> %d\n", foo); fprintf(stderr, "Essai ====> %d\n", foo);
} }
fprintf(stderr, "++++++++++++++ end of pid %d\n", getpid()); fprintf(stderr, "+++++ end of %s pid %d\n", command, getpid());
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */