Compare commits

..

No commits in common. "da44439be7ff1b9b4f2a9e1bc5aa43e08e3d6775" and "b8e5bbf3ccf95364f004e63c3e147914159dc32c" have entirely different histories.

3 changed files with 10 additions and 67 deletions

View File

@ -197,7 +197,7 @@ switch (idFx) {
retval = insitu_filtre3x3(image, 1);
break;
case 20:
retval = octotree_classif(image, 0.500, 0);
retval = octotree_classif(image, 0);
break;
@ -262,7 +262,6 @@ switch (num) {
case 18: return "updown";
case 20: return "octoclass";
case 25: return "vsglitch";
}
return "???";

View File

@ -7,7 +7,6 @@
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include "../floatimg.h"
@ -22,88 +21,33 @@ extern int verbosity;
/* -------------------------------------------------------------- */
/* nouveau du 27 decembre 2020, un soir de grand froid... */
int octotree_classif(FloatImg *pimg, float kdist, int notused)
int octotree_classif(FloatImg *pimg, int notused)
{
int foo;
float mm[6], means[4], delta[3];
float r, g, b, kr, kg, kb, dp, trig;
int idx, sz, n8, count;
typedef struct {
float x, y, z;
} ptc_t;
ptc_t ptc[8];
float mm[6], means[4];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__,
pimg, kdist, notused);
#endif
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
#if 0
foo = fimg_meanvalues(pimg, means);
if (foo) {
fprintf(stderr, "oups %d in meanvalues\n", foo);
return foo;
}
fprintf(stderr, "means: %11f %11f %11f\n",
means[0], means[1], means[2]);
#endif
fprintf(stderr, "means: %11f %11f %11f\n", means[0], means[1], means[2]);
foo = fimg_get_minmax_rgb(pimg, mm);
if (foo) {
fprintf(stderr, "oups %d in get minmax\n", foo);
return foo;
}
if (verbosity) fimg_print_minmax(mm, "input pic");
fimg_print_minmax(mm, __func__);
/*
* compute the 8 center points
*/
delta[0] = mm[1] - mm[0]; /* R */
delta[1] = mm[3] - mm[2]; /* G */
delta[2] = mm[5] - mm[4]; /* B */
// fprintf(stderr, "delta: %11.3f %11.3f %11.3f\n",
// delta[0], delta[1], delta[2]);
for (idx=0; idx<8; idx++) {
kr = 0.25 * ((idx & 0x4) ? 1 : 3);
kg = 0.25 * ((idx & 0x2) ? 1 : 3);
kb = 0.25 * ((idx & 0x1) ? 1 : 3);
// fprintf(stderr, "%6d %.2f %.2f %.2f\n", idx, kr, kg, kb);
ptc[idx].x = (delta[0] * kr) + mm[0];
ptc[idx].y = (delta[1] * kg) + mm[2];
ptc[idx].z = (delta[2] * kb) + mm[4];
// fprintf(stderr, "%6d %.3f %.3f %.3f\n", idx,
// ptc[idx].x, ptc[idx].y, ptc[idx].z);
}
* compute the height center points */
sz = pimg->width * pimg->height;
trig = kdist * ((mm[1] + mm[3] + mm[5])/6.0);
// fprintf(stderr, "trig value %f\n", trig);
count = 0;
#define X(a,b) ( ((a)-(b)) * ((a)-(b)) )
for (idx=0; idx<sz; idx++) {
r = pimg->R[idx]; g = pimg->G[idx]; b = pimg->B[idx];
for (n8=0; n8<8; n8++) {
dp = sqrt(X(r,ptc[n8].x) + X(g,ptc[n8].y) + X(b,ptc[n8].z) );
if (dp < trig) {
pimg->R[idx] = ptc[n8].x;
pimg->G[idx] = ptc[n8].y;
pimg->B[idx] = ptc[n8].z;
count++;
break;
}
else {
pimg->R[idx]=pimg->G[idx]=pimg->B[idx]=0.0;
}
}
}
fprintf(stderr, "%s: %d/%d pixels, ratio %f\n", __func__, count, sz,
(float)count/(float)sz);
return 0;
return -1;
}
/* -------------------------------------------------------------- */
/* nouveau du 19 decembre 2020, pour le grand ecran de da Scritch */

View File

@ -1,10 +1,10 @@
/*
* sfx.h - special effects for fonderie & interpolator
* ---------------------------------------------------
*/
int bouger_les_pixels(FloatImg *pimg, int kaboo);
int octotree_classif(FloatImg *pimg, float fk, int notused);
int octotree_classif(FloatImg *pimg, int notused);
int mirror_split(FloatImg *pimg, int kaboo);
int upside_down(FloatImg *pimg);