Browse Source

killrgb: nice try, but...

master
tth 10 months ago
parent
commit
f08f860daa
  1. 3
      Fonderie/t.c
  2. 3
      floatimg.h
  3. 2
      funcs/Makefile
  4. 42
      funcs/killrgb.c
  5. 6
      funcs/t.c
  6. 31
      funcs/tests.c
  7. 1
      funcs/tests.h

3
Fonderie/t.c

@ -170,7 +170,8 @@ fprintf(stderr, "EXPERIMENT\n"); @@ -170,7 +170,8 @@ fprintf(stderr, "EXPERIMENT\n");
foo = fimg_create_from_dump("01137.fimg", &image);
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;
}

3
floatimg.h

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 153
#define FIMG_VERSION 154
/*
* in memory descriptor
@ -133,6 +133,7 @@ int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused); @@ -133,6 +133,7 @@ int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
/* #coronamaison */
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k);
/* universal exporter XXX */
int fimg_export_picture(FloatImg *pic, char *fname, int flags);

2
funcs/Makefile

@ -13,7 +13,7 @@ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ @@ -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 \
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
displacement.o dithering.o plasmas.o incrustator.o \
recurse.o
killrgb.o recurse.o
#---------------------------------------------------------------

42
funcs/killrgb.c

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
/*
* 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, ig, ib;
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
src, dst, k);
fimg_clear(dst);
ir = ig = ib = 0;
for (line=0; line<src->height; line++) {
for (col=0; col<src->width; 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;
}
/* --------------------------------------------------------------------- */

6
funcs/t.c

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

31
funcs/tests.c

@ -17,6 +17,37 @@ @@ -17,6 +17,37 @@
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 fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused);

1
funcs/tests.h

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef);
int essai_miroir(char *inf, char *outf, int flags);
int essai_killrgb(char *inf, char *outf);
int essai_displacement(char *infile, char *outfile);
int essai_qsort_rgb(char *infile, char *outfile);

Loading…
Cancel
Save