killrgb: nice try, but...

This commit is contained in:
tth 2021-10-05 00:35:56 +02:00
parent 19c8f6aad5
commit f08f860daa
7 changed files with 84 additions and 4 deletions

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

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul
*/ */
#define FIMG_VERSION 153 #define FIMG_VERSION 154
/* /*
* in memory descriptor * in memory descriptor
@ -133,6 +133,7 @@ int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
/* #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);
/* 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);

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
#--------------------------------------------------------------- #---------------------------------------------------------------

42
funcs/killrgb.c Normal file
View File

@ -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;
}
/* --------------------------------------------------------------------- */

View File

@ -23,7 +23,7 @@ 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 };
typedef struct { typedef struct {
char *name; char *name;
int Cmd; int Cmd;
@ -51,6 +51,7 @@ Command commands[] = {
{ "geometrie", Geometrie, }, { "geometrie", Geometrie, },
{ "filetype", FileType }, { "filetype", FileType },
{ "mirror", Mirror }, { "mirror", Mirror },
{ "killrgb", KillRGB },
{ NULL, 0 } { NULL, 0 }
} ; } ;
@ -216,6 +217,9 @@ 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;
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,37 @@
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 fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused); int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused);

View File

@ -5,6 +5,7 @@
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_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);