Compare commits

...

3 Commits

Author SHA1 Message Date
tth
5845ab7962 is _clear_rectangle working ? 2021-10-19 03:56:56 +02:00
tth
0e79b3e8fa hop hop hop le système de cache 2021-10-17 20:23:35 +02:00
tth
1b5186f4b3 NEW RELEASE for other systems 2021-10-17 18:32:53 +02:00
12 changed files with 168 additions and 14 deletions

2
.gitignore vendored
View File

@ -86,4 +86,6 @@ experiment/*.pnm
experiment/*.o experiment/*.o
experiment/muxplanes experiment/muxplanes
experiment/movepixels experiment/movepixels
experiment/tcache

View File

@ -92,6 +92,7 @@ FimgFilter3x3 lowpass = {
}; };
FimgFilter3x3 hipass = { FimgFilter3x3 hipass = {
/* there was a bug with this filter */
{ {
-1.0, -1.0, -1.0, -1.0, -1.0, -1.0,
-1.0, 9.0, -1.0, -1.0, 9.0, -1.0,
@ -101,6 +102,7 @@ FimgFilter3x3 hipass = {
}; };
FimgFilter3x3 diagonal = { FimgFilter3x3 diagonal = {
/* there was a bug with this filter */
{ {
4.0, 1.0, 0.0, 4.0, 1.0, 0.0,
1.0, 0.0, -1.0, 1.0, 0.0, -1.0,
@ -354,8 +356,9 @@ switch (idFx) {
retval = des_bords_sombres_a(image, 160); retval = des_bords_sombres_a(image, 160);
break; break;
case CR_bsombrb: /* experiment ! */ case CR_bsombrb: /* experiment ! */
retval = des_bords_sombres_b(image, 160); retval = des_bords_sombres_b(image, 100);
break; break;
case CR_vsglitch: case CR_vsglitch:
/* please make this function more tweakable */ /* please make this function more tweakable */
retval = vertical_singlitch(image, 290+rand()%45, retval = vertical_singlitch(image, 290+rand()%45,

View File

@ -54,9 +54,11 @@ static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals)
{ {
int x, y, pline, off; int x, y, pline, off;
fimg_clear_rectangle(pimg, pos);
for (y=pos[1]; y<pos[1]+pos[3]; y++) { 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 ? */ /* wtf i'm doing here ? */
pimg->R[off] = fvals[0]; pimg->R[off] = fvals[0];
@ -320,21 +322,39 @@ return 0;
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* nouveau Mon 10 May 2021 08:46:02 PM CEST /* nouveau Mon 10 May 2021 08:46:02 PM CEST
* chez Eric 1KA */ * chez Eric 1KA */
int des_bords_sombres_b(FloatImg *pimg, int offset) int des_bords_sombres_b(FloatImg *pimg, int nbre)
{ {
int idx, x, foo;
float coef, *fptr;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, offset); fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pimg, offset);
#endif #endif
if (offset<0 || offset>=pimg->width) { for (idx=0; idx<nbre; idx++) {
fprintf(stderr, "%s: offset %d is bad\n", __func__, offset);
return -66; coef = (float)idx / (float)nbre;
fptr = pimg->R + (idx*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->G + (idx*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->B + (idx*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
foo = (pimg->height-idx) - 1;
fptr = pimg->R + (foo*pimg->width);
// fprintf(stderr, "%5d %9.3f %p\n", foo, coef, fptr);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->G + (foo*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
fptr = pimg->B + (foo*pimg->width);
for (x=0; x<pimg->width; x++) *fptr++ *= coef;
} }
fprintf(stderr, "ERROR: %s not implemented\n", __func__); // fprintf(stderr, "WARNING: %s badly implemented\n", __func__);
return -1; return 0;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* /*

View File

@ -5,10 +5,12 @@
COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm
DEPS = ../floatimg.h ../libfloatimg.a Makefile DEPS = ../floatimg.h ../libfloatimg.a Makefile
LIBS = -ltiff -lpnglite -lcfitsio LIBS = ../libfloatimg.a -ltiff -lpnglite -lcfitsio
all: assemblage extracteur muxplanes movepixels all: assemblage extracteur muxplanes movepixels
# ---------------------------------------------------------
assemblage: assemblage.c ${DEPS} assemblage: assemblage.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
@ -16,7 +18,20 @@ extracteur: extracteur.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
muxplanes: muxplanes.c ${DEPS} muxplanes: muxplanes.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ gcc $(COPT) $< ${LIBS} -o $@
movepixels: movepixels.c ${DEPS} movepixels: movepixels.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
# ---------------------------------------------------------
# CACHE ENGINE
cachengn.o: cachengn.c cachengn.h Makefile
gcc $(COPT) -c $<
tcache.o: tcache.c cachengn.h Makefile
gcc $(COPT) -c $<
tcache: tcache.o cachengn.o Makefile
gcc $(COPT) tcache.o cachengn.o $(LIBS) -o $@

18
experiment/cachengn.c Normal file
View File

@ -0,0 +1,18 @@
/*
* the chache engine - code
*/
#include <stdio.h>
#include "cachengn.h"
/* ------------------------------------------------------------ */
void cachengn_print_version(int k)
{
printf("this is the version ZERO !!!\n");
}
/* ------------------------------------------------------------ */

5
experiment/cachengn.h Normal file
View File

@ -0,0 +1,5 @@
/*
* the chache engine - header
*/
void cachengn_print_version(int k);

18
experiment/tcache.c Normal file
View File

@ -0,0 +1,18 @@
/*
* tests du systeme de cache
*/
#include <stdio.h>
#include "cachengn.h"
/* ------------------------------------------------------------ */
int main(int argc, char *argv[])
{
fprintf(stderr, "Test of the cache engin - %s %s\n", __DATE__, __TIME__);
return 0;
}
/* ------------------------------------------------------------ */

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul
*/ */
#define FIMG_VERSION 157 #define FIMG_VERSION 160
/* /*
* in memory descriptor * in memory descriptor
@ -108,6 +108,7 @@ typedef struct {
int fimg_killborders(FloatImg *img); int fimg_killborders(FloatImg *img);
int fimg_lissage_2x2(FloatImg *img); int fimg_lissage_2x2(FloatImg *img);
int fimg_show_filter(char *title, FimgFilter3x3 *filtr);
int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr); int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
@ -248,6 +249,7 @@ int parse_rectangle(char *str, FimgArea51 *r, int notused);
int format_from_extension(char *fname); int format_from_extension(char *fname);
char * extension_from_format(int fmt); char * extension_from_format(int fmt);
int fimg_clear_rectangle(FloatImg *pimg, int rect[4]);

View File

@ -7,7 +7,7 @@ COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
DEPS = ../floatimg.h Makefile DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o \ fimg-libpnm.o rampes.o rectangle.o \
sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \ sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \
geometry.o rotate.o fimg-openexr.o \ geometry.o rotate.o fimg-openexr.o \
equalize.o fimg-fits.o saturation.o histogram.o \ equalize.o fimg-fits.o saturation.o histogram.o \
@ -37,6 +37,9 @@ tests.o: tests.c tests.h $(DEPS)
# ### # ###
rectangle.o: rectangle.c $(DEPS)
gcc $(COPT) -c $<
decomprgb.o: decomprgb.c $(DEPS) decomprgb.o: decomprgb.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

38
funcs/rectangle.c Normal file
View File

@ -0,0 +1,38 @@
/*
* R E C T A N G L E
* This is an eternal WIP, sorry...
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
/* --------------------------------------------------------------------- */
int fimg_clear_rectangle(FloatImg *pi, int coo[4])
{
int line, off;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", __func__, pi, coo);
#endif
/* please add boudary checks */
for (line=0; line<coo[3]; line++) {
off = (line+coo[1])*pi->width + coo[0];
// fprintf(stderr, "line %3d off %8d\n", line, off);
/* Kaboum ! */
memset(pi->R + off, 0, coo[2]*sizeof(float));
memset(pi->G + off, 0, coo[2]*sizeof(float));
memset(pi->B + off, 0, coo[2]*sizeof(float));
}
return -1;
}
/* --------------------------------------------------------------------- */

View File

@ -24,7 +24,7 @@ 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, KillRGB, Geometrie, FileType, Mirror, KillRGB,
Pixelize,SplitLevel,DecompRgbz }; Pixelize,SplitLevel,DecompRgbz, Rectangle };
typedef struct { typedef struct {
char *name; char *name;
int Cmd; int Cmd;
@ -56,6 +56,7 @@ Command commands[] = {
{ "pixelize", Pixelize }, { "pixelize", Pixelize },
{ "spltlvl", SplitLevel }, { "spltlvl", SplitLevel },
{ "decomprgbz", DecompRgbz }, { "decomprgbz", DecompRgbz },
{ "rectangle", Rectangle },
{ NULL, 0 } { NULL, 0 }
} ; } ;
@ -233,6 +234,10 @@ switch(opt) {
case DecompRgbz: case DecompRgbz:
foo = essai_decomprgb(filename, outfile); foo = essai_decomprgb(filename, outfile);
break; break;
case Rectangle:
essai_rectangle(outfile, 0);
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,31 @@
extern int verbosity; extern int verbosity;
/* --------------------------------------------------------------------- */
int essai_rectangle(char *outf, int k)
{
FloatImg img;
int foo;
int rect[4];
foo = fimg_create(&img, 320, 240, FIMG_TYPE_RGB);
fimg_drand48(&img, 1.0);
rect[0] = 100; rect[1] = 100;
rect[2] = 32; rect[3] = 16;
foo = fimg_clear_rectangle(&img, rect);
foo = fimg_export_picture(&img, outf, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
fimg_destroy(&img);
return 0;
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int essai_killrgb(char *inf, char *outf) int essai_killrgb(char *inf, char *outf)
{ {