Compare commits

...

10 Commits

Author SHA1 Message Date
tth
6c92cca12c this is a big mess 2021-10-15 23:21:02 +02:00
tth
bc864a6acb + bla 2021-10-11 20:13:26 +02:00
tth
39f48a56b0 minor fix 2021-10-11 13:40:30 +02:00
tth
094b61ba39 fix a nasty bug in a Makefile 2021-10-11 09:23:17 +02:00
tth
9bde22f560 first version of pixelize_h 2021-10-10 23:38:10 +02:00
tth
f3dc73782a a small bla 2021-10-10 22:35:19 +02:00
tth
b93ec2e603 useless commit 2021-10-10 12:20:52 +02:00
tth
9124ab6434 adding killrgb experiments 2021-10-10 09:46:27 +02:00
tth
23908cb746 explicit error message 2021-10-10 09:25:59 +02:00
tth
f08f860daa killrgb: nice try, but... 2021-10-05 00:35:56 +02:00
20 changed files with 655 additions and 13 deletions

View File

@ -10,6 +10,7 @@ OBJS = fifo.o sfx.o crapulator.o glitches.o metriques.o \
filterstack.o single.o filterstack.o single.o
DEPS = ../floatimg.h \ DEPS = ../floatimg.h \
../libfloatimg.a \
fifo.h crapulator.h metriques.h glitches.h sfx.h \ fifo.h crapulator.h metriques.h glitches.h sfx.h \
filterstack.h crapdef.h crapstr.h single.h filterstack.h crapdef.h crapstr.h single.h

View File

@ -102,9 +102,9 @@ FimgFilter3x3 hipass = {
FimgFilter3x3 diagonal = { FimgFilter3x3 diagonal = {
{ {
2.0, 1.0, 0.0, 4.0, 1.0, 0.0,
1.0, 0.0, -1.0, 1.0, 0.0, -1.0,
0.0, -1.0, -2.0, 0.0, -1.0, -4.0,
}, },
1.0, 0.0 1.0, 0.0
}; };
@ -152,6 +152,81 @@ fimg_destroy(&img);
return retval; return retval;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
int run_killrgb_0(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
// fprintf(stderr, "----> %s\n", __func__);
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_killrgb_v(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
// fprintf(stderr, "%s ---->\n", __func__);
return ret;
}
/* -------------------------------------------------------------- */
static int run_pixelize_0(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_pixelize_h_0(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
static int run_pixelize_random(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_pixelize_h_rnd(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
static int run_decomprgbz_color(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_decomp_rgbz_color(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
static int run_decomprgbz_gray(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = fimg_decomp_rgbz_gray(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
/* /*
* This is the main filter engine used both for input and * This is the main filter engine used both for input and
* output processing. It can be called by the filterstack * output processing. It can be called by the filterstack
@ -319,6 +394,29 @@ switch (idFx) {
retval = do_something(image, 3); retval = do_something(image, 3);
break; break;
case CR_killrgb0:
retval = run_killrgb_0(image, 0);
break;
case CR_pixelizh:
retval = run_pixelize_0(image, 8);
break;
case CR_pixelrand:
retval = run_pixelize_random(image, -1);
break;
case CR_splitlevel:
retval = fimg_split_level(image, image, 0);
break;
case CR_decrgbzc:
retval = run_decomprgbz_color(image, -1);
break;
case CR_decrgbzg:
retval = run_decomprgbz_gray(image, -1);
break;
case CR_hilightr: case CR_hilightr:
retval = fimg_highlight_color(image, image, 'R', 1.717); retval = fimg_highlight_color(image, image, 'R', 1.717);
break; break;
@ -358,7 +456,7 @@ void list_crapulors(char *texte)
int idx; int idx;
#define OUT stdout #define OUT stdout
fprintf(OUT, "______________. %s\n", texte); if (NULL!=texte) fprintf(OUT, "______________. %s\n", texte);
for (idx=0; CrapL[idx].id!=-1; idx++) { for (idx=0; CrapL[idx].id!=-1; idx++) {
fprintf(OUT, " %-12s | %4d | %5d | %8.3f\n", fprintf(OUT, " %-12s | %4d | %5d | %8.3f\n",
CrapL[idx].name, CrapL[idx].name,

View File

@ -33,6 +33,13 @@
32 vsglitch 1 1.0 32 vsglitch 1 1.0
33 crumphard 1 1.0 33 crumphard 1 1.0
42 nothing 42 3.1415926 42 nothing 42 3.1415926
43 killrgb0 1 9
45 hilightr 1 1.717 45 hilightr 1 1.717
46 pixelizh 1 1.111
47 pixelizv 1 1.111
48 pixelrand 1 1
49 splitlevel 1 1
50 decrgbzc 1 99
51 decrgbzg 1 99
99 message 1 1.0 99 message 1 1.0
-1 end 1 1.0 -1 end 1 1.0

View File

@ -47,6 +47,9 @@ return -1;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* nouveau du premier dimanche de 2020 'nextgen' */ /* nouveau du premier dimanche de 2020 'nextgen' */
/* CE TRUC NE MARCHE PAS COMME PRÉVU */
static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals) static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals)
{ {
int x, y, pline, off; int x, y, pline, off;
@ -55,6 +58,7 @@ for (y=pos[1]; y<pos[1]+pos[3]; y++) {
pline = y*pimg->width; pline = y*pimg->width;
for (x=pos[0]+2; x<pos[0]+pos[2]-2; x++) { for (x=pos[0]+2; x<pos[0]+pos[2]-2; x++) {
off = pline + x; off = pline + x;
/* wtf i'm doing here ? */
pimg->R[off] = fvals[0]; pimg->R[off] = fvals[0];
pimg->G[off] = fvals[1]; pimg->G[off] = fvals[1];
pimg->B[off] = fvals[2]; pimg->B[off] = fvals[2];
@ -62,6 +66,10 @@ for (y=pos[1]; y<pos[1]+pos[3]; y++) {
} }
return 0; return 0;
} }
/*
* need more explanation, need more work
*/
int trinitron(FloatImg *pimg, int notused) int trinitron(FloatImg *pimg, int notused)
{ {
int x, y, coo[4], foo; int x, y, coo[4], foo;
@ -324,6 +332,8 @@ if (offset<0 || offset>=pimg->width) {
return -66; return -66;
} }
fprintf(stderr, "ERROR: %s not implemented\n", __func__);
return -1; return -1;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */

View File

@ -170,7 +170,8 @@ fprintf(stderr, "EXPERIMENT\n");
foo = fimg_create_from_dump("01137.fimg", &image); foo = fimg_create_from_dump("01137.fimg", &image);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d on create\n", __func__, foo); fprintf(stderr, "%s: err %d on create_from_dump\n",
__func__, foo);
return -1; return -1;
} }

View File

@ -66,6 +66,8 @@ for (foo=0; foo<argc; foo++) {
} }
#endif #endif
fprintf(stderr, "*** Extracteur %s %s\n", __DATE__, __TIME__);
while ((opt = getopt(argc, argv, "hv")) != -1) { while ((opt = getopt(argc, argv, "hv")) != -1) {
switch(opt) { switch(opt) {
case 'h': help(0), exit(0); break; case 'h': help(0), exit(0); break;

View File

@ -46,7 +46,7 @@ int try_this_muxplane(char *fr, char *fg, char *fb, char *dst, int flags)
int foo; int foo;
FloatImg imr, img, imb, dest; FloatImg imr, img, imb, dest;
fprintf(stderr, "muxing: %s %s %s --> %s\n", fr, fg, fb, dst); fprintf(stderr, "muxing: %s %s %s -> %s\n", fr, fg, fb, dst);
foo = fimg_create_from_dump(fr, &imr); foo = fimg_create_from_dump(fr, &imr);
if (foo) { if (foo) {
@ -82,7 +82,8 @@ int main(int argc, char *argv[])
int foo; int foo;
if (5 != argc) { if (5 != argc) {
fprintf(stderr, "ERROR: %s need four fimg files arguments\n", argv[0]); fprintf(stderr, "ERROR: %s need four fimg files arguments\n",
argv[0]);
return 1; return 1;
} }

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul
*/ */
#define FIMG_VERSION 153 #define FIMG_VERSION 157
/* /*
* in memory descriptor * in memory descriptor
@ -28,6 +28,9 @@ typedef struct {
char magic[8]; char magic[8];
int32_t w, h, t; int32_t w, h, t;
} FimgFileHead; } FimgFileHead;
/*
* we MUST look at packing and endianess problems NOW */
#define MAGIC_AREA51 0xA5EA0051 #define MAGIC_AREA51 0xA5EA0051
typedef struct { typedef struct {
@ -128,11 +131,15 @@ int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused);
/* module sfx4.c */ /* module sfx4.c */
int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused); int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
int fimg_split_level(FloatImg *src, FloatImg *dst, int notused);
/* funcs/rotate.c module */ /* funcs/rotate.c module */
/* #coronamaison */ /* #coronamaison */
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused); int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k);
int fimg_decomp_rgbz_color(FloatImg *psrc, FloatImg *pdst, int k);
int fimg_decomp_rgbz_gray(FloatImg *psrc, FloatImg *pdst, int k);
/* universal exporter XXX */ /* universal exporter XXX */
int fimg_export_picture(FloatImg *pic, char *fname, int flags); int fimg_export_picture(FloatImg *pic, char *fname, int flags);
@ -159,6 +166,11 @@ int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
/* --> funcs/plasmas.c */ /* --> funcs/plasmas.c */
int fimg_prototype_plasma(FloatImg *img, double time, int type); int fimg_prototype_plasma(FloatImg *img, double time, int type);
/* --> funcs/pixelize.c
voir fimg_pixelize_h_rnd() */
int fimg_pixelize_h_0(FloatImg *psrc, FloatImg *pdst, int k);
int fimg_pixelize_h_rnd(FloatImg *psrc, FloatImg *pdst, int largeur);
/* * * * experimental ! */ /* * * * experimental ! */
int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused); int fimg_classif_trial(FloatImg *src, FloatImg*dst, float fval, int notused);
int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused); int fimg_qsort_rgb_a(FloatImg *psrc, FloatImg *pdst, int notused);
@ -230,6 +242,7 @@ int fimg_multirandom(FloatImg *fimg, long nbpass);
void fimg_print_minmax(float minmax[6], char *titre); void fimg_print_minmax(float minmax[6], char *titre);
int parse_WxH(char *str, int *pw, int *ph); int parse_WxH(char *str, int *pw, int *ph);
int parse_double(char *str, double *dptr); int parse_double(char *str, double *dptr);
int irand2(int offset, int modulo);
int print_rectangle(char *str, FimgArea51 *rect); int print_rectangle(char *str, FimgArea51 *rect);
int parse_rectangle(char *str, FimgArea51 *r, int notused); int parse_rectangle(char *str, FimgArea51 *r, int notused);
int format_from_extension(char *fname); int format_from_extension(char *fname);

View File

@ -13,7 +13,7 @@ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
equalize.o fimg-fits.o saturation.o histogram.o \ equalize.o fimg-fits.o saturation.o histogram.o \
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \ hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
displacement.o dithering.o plasmas.o incrustator.o \ displacement.o dithering.o plasmas.o incrustator.o \
recurse.o killrgb.o recurse.o pixelize.o decomprgb.o
#--------------------------------------------------------------- #---------------------------------------------------------------
@ -37,6 +37,15 @@ tests.o: tests.c tests.h $(DEPS)
# ### # ###
decomprgb.o: decomprgb.c $(DEPS)
gcc $(COPT) -c $<
pixelize.o: pixelize.c $(DEPS)
gcc $(COPT) -c $<
killrgb.o: killrgb.c $(DEPS)
gcc $(COPT) -c $<
recurse.o: recurse.c $(DEPS) recurse.o: recurse.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

View File

@ -4,8 +4,8 @@ Plein de fonctions qu'il serait bon de documenter :)
## PNG ## PNG
__Attention__ : la bibliothèque `pnglite`actuellement utiilsée pour lire les __Attention__ : la bibliothèque `pnglite`actuellement utilisée pour lire
fichiers PNG n'accepte que **certains** types de fichiers. les fichiers PNG n'accepte que **certains** types de fichiers.
Et en particulier, elle brotche sur ceux produits par ImageMagick ! Et en particulier, elle brotche sur ceux produits par ImageMagick !
## Contours ## Contours
@ -21,6 +21,10 @@ une image en fonction de l'extension du nom de fichier.
Effets spéciaux divers. Effets spéciaux divers.
La fonction `fimg_pixelize_h_rnd` est issue d'une idée qui m'est venue
dans la roulotte de TerreBlanque. Elle a besoin de recherches sur la
dynamique temporelle, et d'une FSM à trois états.
## Dithering ## Dithering
Work in progress... Work in progress...

149
funcs/decomprgb.c Normal file
View File

@ -0,0 +1,149 @@
/*
* DECOMPOSITION RGB
*/
#include <stdio.h>
#include <stdint.h>
#include "../floatimg.h"
extern int verbosity;
/* == ---------------------------------------------------- == */
/* some dirty macros */
#define pixidx(fi,x,y) (((y)*fi->width)+(x))
#define getRpix(fi,x,y) (fi->R[ pixidx(fi,(x),(y)) ])
#define getGpix(fi,x,y) (fi->G[ pixidx(fi,(x),(y)) ])
#define getBpix(fi,x,y) (fi->B[ pixidx(fi,(x),(y)) ])
/* A lot of strange and usefull parenthesis */
/* == ---------------------------------------------------- == */
static float compute_z_value(float r, float g, float b)
{
double dval;
return 42.0;
}
/* == ---------------------------------------------------- == */
int fimg_decomp_rgbz_color(FloatImg *psrc, FloatImg *pdst, int k)
{
int x, y, x2, y2;
int w2, h2, idx;
float cumul, vgray;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
psrc, pdst, k);
#endif
fimg_clear(pdst);
w2 = psrc->width/2; h2 = psrc->height/2;
for (y=0; y<h2; y++)
{
y2 = y * 2;
for (x=0; x<w2; x++) {
x2 = x * 2;
cumul = getRpix(psrc, x2, y2) +
getRpix(psrc, x2, y2+1) +
getRpix(psrc, x2+1, y2) +
getRpix(psrc, x2+1, y2+1);
cumul /= 4, vgray = cumul;
pdst->R[pixidx(pdst,x,y)] = cumul;
cumul = getGpix(psrc, x2, y2) +
getGpix(psrc, x2, y2+1) +
getGpix(psrc, x2+1, y2) +
getGpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
pdst->G[pixidx(pdst,x+w2,y)] = cumul;
cumul = getBpix(psrc, x2, y2) +
getBpix(psrc, x2, y2+1) +
getBpix(psrc, x2+1, y2) +
getBpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
pdst->B[pixidx(pdst,x,y+h2)] = cumul;
idx = pixidx(pdst,x+w2,y+h2);
pdst->R[idx] = pdst->G[idx] = \
pdst->B[idx] = vgray / 3.0;
}
}
return 0;
}
/* == ---------------------------------------------------- == */
/* PUTAIN LE COPIER/COLLÉ DE BATARD !!! */
int fimg_decomp_rgbz_gray(FloatImg *psrc, FloatImg *pdst, int k)
{
int x, y, x2, y2;
int w2, h2, idx;
float cumul, vgray;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
psrc, pdst, k);
#endif
fimg_clear(pdst);
w2 = psrc->width/2; h2 = psrc->height/2;
for (y=0; y<h2; y++)
{
y2 = y * 2;
for (x=0; x<w2; x++) {
x2 = x * 2;
cumul = getRpix(psrc, x2, y2) +
getRpix(psrc, x2, y2+1) +
getRpix(psrc, x2+1, y2) +
getRpix(psrc, x2+1, y2+1);
cumul /= 4, vgray = cumul;
idx = pixidx(pdst,x,y);
pdst->R[idx] = pdst->G[idx] = pdst->B[idx] = cumul;
cumul = getGpix(psrc, x2, y2) +
getGpix(psrc, x2, y2+1) +
getGpix(psrc, x2+1, y2) +
getGpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
idx = pixidx(pdst,x+w2,y);
pdst->R[idx] = pdst->G[idx] = pdst->B[idx] = cumul;
cumul = getBpix(psrc, x2, y2) +
getBpix(psrc, x2, y2+1) +
getBpix(psrc, x2+1, y2) +
getBpix(psrc, x2+1, y2+1);
cumul /= 4, vgray += cumul;
idx = pixidx(pdst,x,y+h2);
pdst->R[idx] = pdst->G[idx] = pdst->B[idx] = cumul;
idx = pixidx(pdst,x+w2,y+h2);
pdst->R[idx] = pdst->G[idx] = \
pdst->B[idx] = vgray / 3.0;
}
}
return 0;
}
/* == ---------------------------------------------------- == */

View File

@ -44,6 +44,7 @@ if (verbosity) {
tiff = TIFFOpen(fname, "w"); tiff = TIFFOpen(fname, "w");
if (NULL==tiff) { if (NULL==tiff) {
fprintf(stderr, "erreur TIFFOpen\n");
return -6; return -6;
} }

45
funcs/killrgb.c Normal file
View File

@ -0,0 +1,45 @@
/*
* KILL RGB !
*
* nouveau TerreBlanque 4 octobre 2021
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "../floatimg.h"
#include "tests.h"
/* --------------------------------------------------------------------- */
int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k)
{
int foo, line, col;
int ir;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
src, dst, k);
#endif
fimg_clear(dst);
ir = 0;
for (line=0; line<src->height; line++) {
// fprintf(stderr, "%s line %d\n", __func__, line);
for (col=0; col<(src->width-3); col+=3) {
dst->R[ir ] = src->R[ir]; ir++;
dst->G[ir+1] = src->G[ir]; ir++;
dst->B[ir+2] = src->B[ir]; ir++;
}
}
return 0;
}
/* --------------------------------------------------------------------- */

102
funcs/pixelize.c Normal file
View File

@ -0,0 +1,102 @@
/*
* P I X E L I Z E
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------- */
/* nouveau 10 octobre 2021 dans la roulotte de Terreblanque */
#define LARGEUR 16
int fimg_pixelize_h_0(FloatImg *psrc, FloatImg *pdst, int largeur)
{
int line, col, loop, idx;
float cr, cg, cb; /* cumuls */
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, largeur);
#endif
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: err compatibility\n", __func__);
return -8;
}
switch(largeur) {
case 8: case 16: case 32:
break;
default:
fprintf(stderr, "pixeliz bad width %d\n", largeur);
return -77;
}
for (line=0; line<psrc->height; line++) {
for (col=0; col<psrc->width; col+=largeur) {
cr = cg = cb = 0.0;
idx = line * psrc->width + col;
for (loop=0; loop<largeur; loop++) {
cr += psrc->R[idx+loop];
cg += psrc->G[idx+loop];
cb += psrc->B[idx+loop];
}
for (loop=0; loop<largeur; loop++) {
pdst->R[idx+loop] = cr / (float)largeur;
pdst->G[idx+loop] = cg / (float)largeur;
pdst->B[idx+loop] = cb / (float)largeur;
}
}
}
return 0;
}
/* -------------------------------------------------------------- */
/*
* un essai dans la roulotte :)
* 11 oct 2021 : premier jet, essai concluant, mais nécessite
* du travail sur les rand() pour être plus 'noisy'
*
*/
int fimg_pixelize_h_rnd(FloatImg *psrc, FloatImg *pdst, int largeur)
{
static int count = 0;
static int flag = 0;
int foo;
if (0==count) {
if (flag) {
count = irand2(5, 10);
flag = ! flag;
}
else {
count = irand2(20, 40);
flag = ! flag;
}
if (verbosity) {
fprintf(stderr, "%s c=%d f=%c\n", __func__,
count, flag?'T':'F');
}
}
if (verbosity) {
fprintf(stderr, "%s: count=%d flag=%d\n", __func__, count, flag);
}
foo = fimg_pixelize_h_0(psrc, pdst, flag ? 8 : 32);
if (foo) {
fprintf(stderr, "PANIC in %s\n", __func__);
abort();
}
count--; /* nice trick bro */
return 0;
}
/* -------------------------------------------------------------- */

View File

@ -23,6 +23,11 @@ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused);
fprintf(stderr, "!!!!!! %s is a wip !!!!!\n", __func__); fprintf(stderr, "!!!!!! %s is a wip !!!!!\n", __func__);
/*
* bon, maintenant, il faut plonger dans du code du
* siecle dernier et l'adapter a ce nouveau contexte
*/
return -1; return -1;
} }
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@ -40,5 +40,36 @@ for (y=0; y<src->height; y++) {
return 0; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/*
* see also:
sfx3.c:fimg_crump_hard()
*/
int fimg_split_level(FloatImg *src, FloatImg *dst, int notused)
{
float means[4];
float in[3], out[3];
int foo, idx, surface;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__, src, dst, notused);
#endif
foo = fimg_meanvalues(src, means);
if (foo) {
return -66;
}
surface = src->width*src->height;
for(idx=0; idx<surface; idx++) {
if (src->R[idx]<means[0]) dst->R[idx]=src->R[idx]*2.0;
else dst->R[idx]=(src->R[idx]-means[0])*2.0;
if (src->G[idx]<means[1]) dst->G[idx]=src->G[idx]*2.0;
else dst->G[idx]=(src->G[idx]-means[1])*2.0;
if (src->B[idx]<means[2]) dst->B[idx]=src->B[idx]*2.0;
else dst->B[idx]=(src->B[idx]-means[2])*2.0;
}
return 0;
}
/* -------------------------------------------------------------- */
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */

View File

@ -23,7 +23,8 @@ float global_fvalue;
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Histo, Hsv, Classif, Ctr2x2, Qsortrgb, Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
Displace, ReadPNG, Plasmas, Hilight, OpenEXR, Displace, ReadPNG, Plasmas, Hilight, OpenEXR,
Geometrie, FileType, Mirror }; Geometrie, FileType, Mirror, KillRGB,
Pixelize,SplitLevel,DecompRgbz };
typedef struct { typedef struct {
char *name; char *name;
int Cmd; int Cmd;
@ -51,6 +52,10 @@ Command commands[] = {
{ "geometrie", Geometrie, }, { "geometrie", Geometrie, },
{ "filetype", FileType }, { "filetype", FileType },
{ "mirror", Mirror }, { "mirror", Mirror },
{ "killrgb", KillRGB },
{ "pixelize", Pixelize },
{ "spltlvl", SplitLevel },
{ "decomprgbz", DecompRgbz },
{ NULL, 0 } { NULL, 0 }
} ; } ;
@ -216,6 +221,18 @@ switch(opt) {
case Mirror: case Mirror:
foo = essai_miroir(filename, outfile, 0); foo = essai_miroir(filename, outfile, 0);
break; break;
case KillRGB:
foo = essai_killrgb(filename, outfile);
break;
case Pixelize:
foo = essai_pixelize(filename, outfile);
break;
case SplitLevel:
foo = essai_split_level(filename, outfile, 0);
break;
case DecompRgbz:
foo = essai_decomprgb(filename, outfile);
break;
default: default:
fprintf(stderr, "'%s' is a bad command\n", command); fprintf(stderr, "'%s' is a bad command\n", command);
exit(1); exit(1);

View File

@ -17,6 +17,71 @@
extern int verbosity; extern int verbosity;
/* --------------------------------------------------------------------- */
int essai_killrgb(char *inf, char *outf)
{
int foo;
FloatImg src, dst;
fprintf(stderr, ">>> %s ( %s %s )\n", __func__, inf, outf);
foo = fimg_create_from_dump(inf, &src);
if (0 != foo) {
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
foo, inf);
return foo;
}
fimg_clone(&src, &dst, 1);
foo = fimg_killrgb_v(&src, &dst, 0);
if (foo) {
fprintf(stderr, "%s:%s(): fail %d line %d\n",
__FILE__, __func__, foo, __LINE__);
return foo;
}
foo = fimg_export_picture(&dst, outf, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
int essai_decomprgb(char *inf, char *outf)
{
int foo;
FloatImg src, dst;
fprintf(stderr, ">>> %s ( %s %s )\n", __func__, inf, outf);
foo = fimg_create_from_dump(inf, &src);
if (0 != foo) {
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
foo, inf);
return foo;
}
fimg_clone(&src, &dst, 1);
foo = fimg_decomp_rgbz_gray(&src, &dst, 0);
if (foo) {
fprintf(stderr, "%s:%s(): fail %d line %d\n",
__FILE__, __func__, foo, __LINE__);
return foo;
}
foo = fimg_export_picture(&dst, outf, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
fimg_destroy(&src); fimg_destroy(&dst);
return 0;
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused); int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused);
@ -73,7 +138,7 @@ fimg_clone(&src, &dst, 0);
/* run the crappy code */ /* run the crappy code */
foo = fimg_mirror(&src, &dst, 0); foo = fimg_mirror(&src, &dst, 0);
if (foo) { if (foo) {
fprintf(stderr, "err %d in fimg_mirrot\n", foo); fprintf(stderr, "err %d in fimg_mirror\n", foo);
return -6; return -6;
} }
@ -83,6 +148,36 @@ if (foo) {
return foo; return foo;
} }
return 0;
}
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
int essai_split_level(char *inf, char *outf, int flags)
{
int foo;
FloatImg src, dst;
fprintf(stderr, ">>> %s ( '%s' '%s' 0x%X )\n", __func__,
inf, outf, flags);
foo = fimg_create_from_dump(inf, &src);
if (0 != foo) {
fprintf(stderr, "%s: err %d loading image '%s'\n", __func__,
foo, inf);
return foo;
}
fimg_clone(&src, &dst, 0);
foo = fimg_split_level(&src, &dst, 0);
if (foo) {
fprintf(stderr, "err %d in split_level\n", foo);
return -6;
}
foo = fimg_export_picture(&dst, outf, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -828,4 +923,43 @@ fprintf(stderr, "\\o/ end of %s\n", __func__);
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/*
* dans la roulotte de terreblanque
*/
int essai_pixelize(char *infile, char *outfile)
{
FloatImg src, dst;
int foo;
fprintf(stderr, ">>> %s ( '%s' '%s' )\n", __func__, infile, outfile);
memset(&src, 0, sizeof(FloatImg));
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
memset(&dst, 0, sizeof(FloatImg));
foo = fimg_clone(&src, &dst, 0);
if (foo) return -888;
foo = fimg_pixelize_h_0(&src, &dst, 8);
if (foo) {
fprintf(stderr, "in %s, pixelize give us a %d\n", __func__, foo);
return foo;
}
foo = fimg_export_picture(&dst, outfile, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result to %s\n", __func__,
foo, outfile);
return foo;
}
fimg_destroy(&src);
fimg_destroy(&dst);
return 0;
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

View File

@ -5,6 +5,9 @@
int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef); int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef);
int essai_miroir(char *inf, char *outf, int flags); int essai_miroir(char *inf, char *outf, int flags);
int essai_killrgb(char *inf, char *outf);
int essai_decomprgb(char *inf, char *outf);
int essai_split_level(char *inf, char *outf, int flags);
int essai_displacement(char *infile, char *outfile); int essai_displacement(char *infile, char *outfile);
int essai_qsort_rgb(char *infile, char *outfile); int essai_qsort_rgb(char *infile, char *outfile);
@ -30,3 +33,5 @@ int essai_lecture_png(char *fname, char *outfile, int notused);
int essai_highlights(char *inf, char *outf, int ikoef, float fkoef); int essai_highlights(char *inf, char *outf, int ikoef, float fkoef);
int essai_openexr(char *inf, char *outf, int flags); int essai_openexr(char *inf, char *outf, int flags);
int essai_pixelize(char *infile, char *outfile);

View File

@ -3,6 +3,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
@ -53,6 +54,12 @@ if (1 == foo) {
return -1; return -1;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* new Mon 11 Oct 2021 08:28:27 PM CEST */
int irand2(int offset, int modulo)
{
return offset + (rand() % modulo);
}
/* --------------------------------------------------------------------- */
int file_type_from_name(char *name) int file_type_from_name(char *name)
{ {