more experiments

This commit is contained in:
Tonton Th 2021-01-03 15:21:38 +01:00
parent 87c681ac70
commit 1d6f0e8b4e
9 changed files with 114 additions and 14 deletions

View File

@ -203,6 +203,9 @@ switch (idFx) {
retval = octotree_classif(image, 0.500, 0);
break;
case CR_trinitron:
retval = trinitron(image, 0);
break;
/* here are the glitches */
case CR_bsombra: /* experiment ! */
@ -228,6 +231,10 @@ switch (idFx) {
retval = 0;
break;
case CR_nothing:
retval = do_something(image, 3);
break;
default :
fprintf(stderr, "%s : effect #%d invalid\n",
__func__, idFx);

View File

@ -19,9 +19,11 @@
18 updown 1 1.0
19 hipass 1 1.0
20 octotree 1 1.0
21 trinitron 3, 0.0
24 bsombra 1 1.0
25 vsglitch 1 1.0
26 rndblks 1 1.0
27 shiftln0 1 1.0
42 nothing 42 3.14159
99 message 1 1.0
-1 end 1 1.0

View File

@ -125,8 +125,9 @@ for (idx=0; idx<f_stacks[numid].count; idx++) {
if (foo) {
fprintf(stderr,
"crapulator give me error %d on effect %d\n",
foo, eff);
"crapulator give me error %d on effect %d (%s)\n",
foo, eff,
crap_name_from_number(eff));
return foo;
}
}

View File

@ -16,6 +16,28 @@
extern int verbosity;
/* -------------------------------------------------------------- */
/* nouveau du 32 decembre 2020, endless september */
int do_something(FloatImg *pimg, int notused)
{
int ypos, idx, pos, sline;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
#endif
ypos = rand() % pimg->width;
for (idx=0; idx < pimg->height; idx++) {
sline = idx * pimg->width;
pos = sline + ypos;
// fprintf(stderr, "%6d %6d\n", idx, sline);
pimg->R[pos] = pimg->G[pos];
pimg->B[pos] = pimg->G[pos];
}
return 0;
}
/* -------------------------------------------------------------- */
int kill_a_random_line(FloatImg *pvictime, float fval, int bits)
{

View File

@ -2,6 +2,8 @@
* glitches.h
*/
int do_something(FloatImg *pimg, int notused);
int kill_a_random_line(FloatImg *pvictime, float level, int bits);
int kill_a_few_lines(FloatImg *who, float fval, int number);
int random_blocks(FloatImg *picture, int percent);

View File

@ -9,6 +9,38 @@
extern int verbosity;
/* -------------------------------------------------------------- */
int stat_zone(FloatImg *pimg, int geom[4], float v3[3])
{
int x, y, xe, ye;
int off;
double accus[3], divisor;
xe = geom[0] + geom[2];
ye = geom[1] + geom[3];
#if DEBUG_LEVEL
fprintf(stdout, "geom: %5d %5d %5d %5d\n",
geom[0], geom[1], geom[2], geom[3]);
#endif
accus[0] = accus[1] = accus[2] = 0.0;
for (y=geom[1]; y<ye; y++) {
for (x=geom[0]; x<xe; x++) {
off = (y*pimg->width) + x;
accus[0] += (double) pimg->R[off];
accus[1] += (double) pimg->G[off];
accus[2] += (double) pimg->B[off];
}
}
divisor = (double)(geom[2] * geom[3]); /* array of zone */
v3[0] = (float)(accus[0] / divisor);
v3[1] = (float)(accus[1] / divisor);
v3[2] = (float)(accus[2] / divisor);
return 0;
}
/* -------------------------------------------------------------- */
/*
* premier essai...

View File

@ -4,6 +4,9 @@
/* -------------------------------------------------------------- */
int stat_zone(FloatImg *pimg, int geom[4], float v3[3]);
/* first experiments */
int get_float_metric_a(FloatImg *pimg, float *where);

View File

@ -12,6 +12,7 @@
#include "../floatimg.h"
#include "fonctions.h"
#include "metriques.h"
#include "sfx.h"
/* -------------------------------------------------------------- */
@ -20,12 +21,50 @@
extern int verbosity;
/* -------------------------------------------------------------- */
/* nouveau du 27 decembre 2020, un soir de grand froid... */
/* nouveau du premier dimanche de 2020 'nextgen' */
static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals)
{
int x, y, off;
for (y=pos[1]; y<pos[1]+pos[3]; y++) {
for (x=pos[0]; x<pos[0]+pos[2]; x++) {
off = (y*pimg->width) + x;
pimg->R[off] = fvals[0];
}
}
return 0;
}
int trinitron(FloatImg *pimg, int notused)
{
int x, y, coo[4], foo;
float vals[3];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, notused);
#endif
#define STP 16 /* stepd for x & y axex */
coo[2] = coo[3] = STP;
for (y=0; y<pimg->height; y+=STP) {
coo[1] = y;
for (x=0; x<pimg->width; x+=STP) {
coo[0] = x;
foo = stat_zone(pimg, coo, vals);
if (foo) abort();
/* next step : plot the datas */
pixel_trinitron(pimg, coo, vals);
}
}
#undef STP
return 0;
}
/* -------------------------------------------------------------- */
/* nouveau du 27 decembre 2020, un soir de grand froid... */
int octotree_classif(FloatImg *pimg, float kdist, int notused)
{
int foo;
float mm[6], means[4], delta[3];
float mm[6], delta[3];
float r, g, b, kr, kg, kb, dp, trig;
int idx, sz, n8, count;
typedef struct {
@ -38,16 +77,6 @@ fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__,
pimg, kdist, notused);
#endif
#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
foo = fimg_get_minmax_rgb(pimg, mm);
if (foo) {
fprintf(stderr, "oups %d in get minmax\n", foo);

View File

@ -3,6 +3,8 @@
* ---------------------------------------------------
*/
int trinitron(FloatImg *pimg, int notused);
int bouger_les_pixels(FloatImg *pimg, int kaboo);
int octotree_classif(FloatImg *pimg, float fk, int notused);