Compare commits

..

No commits in common. "ce02cf96bc8b597de2aca29fee2473a113a0bb55" and "8b8cf74128dd88a7b9de72839040e0f1f60959e8" have entirely different histories.

6 changed files with 7 additions and 157 deletions

View File

@ -3,7 +3,7 @@
* ugly code from tTh * ugly code from tTh
*/ */
#define FIMG_VERSION 111 #define FIMG_VERSION 109
/* /*
* in memory descriptor * in memory descriptor
@ -145,8 +145,6 @@ int fimg_desaturate(FloatImg *src, FloatImg *dst, int k);
/* module funcs/geometry.c */ /* module funcs/geometry.c */
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused); int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused);
int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
/* module funcs/rampes.c */ /* module funcs/rampes.c */
int fimg_hdeg_a(FloatImg *img, double dcoef); int fimg_hdeg_a(FloatImg *img, double dcoef);
int fimg_vdeg_a(FloatImg *img, double dcoef); int fimg_vdeg_a(FloatImg *img, double dcoef);
@ -184,8 +182,6 @@ int fimg_save_as_png(FloatImg *src, char *outname, int flags);
int fimg_test_pattern(FloatImg *fimg, int type, double dval); int fimg_test_pattern(FloatImg *fimg, int type, double dval);
int fimg_draw_something(FloatImg *fimg); int fimg_draw_something(FloatImg *fimg);
/* file is 'funcs/utils.c' */
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 format_from_extension(char *fname); int format_from_extension(char *fname);

View File

@ -5,8 +5,7 @@ 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 sfx0.o geometry.o rotate.o \ fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.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
#--------------------------------------------------------------- #---------------------------------------------------------------
@ -20,9 +19,6 @@ t: t.c $(DEPS) ../libfloatimg.a
../libfloatimg.a: $(OBJS) ../libfloatimg.a: $(OBJS)
$(AR) r $@ $? $(AR) r $@ $?
displacement.o: displacement.c
gcc $(COPT) -c $<
fimg-png.o: fimg-png.c $(DEPS) fimg-png.o: fimg-png.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

View File

@ -1,93 +0,0 @@
/*
* displacement.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
extern int verbosity;
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* nouveau 24 octobre 2020, pendant le masque-flamme coronavidique */
int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags)
{
int x, y, foo;
float minmax[6];
float rgb[3];
float dltr, dltg, dltb; /* delta des minmax */
float dispx, dispy;
int dstx, dsty;
int in, out;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p 0x%04x )\n", __func__, psrc, pdst, flags);
#endif
if (FIMG_TYPE_RGB != psrc->type) {
fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type);
return -7;
}
if (fimg_images_not_compatible(psrc, pdst)) {
fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type);
return -8;
}
foo = fimg_get_minmax_rgb(psrc, minmax);
if (verbosity) {
fimg_print_minmax(minmax, (char *)__func__);
}
dltr = minmax[1] - minmax[0];
dltg = minmax[3] - minmax[2];
dltb = minmax[5] - minmax[4];
in = out = 0;
for (y=0; y<psrc->height; y++) {
for (x=0; x<psrc->width; x++) {
fimg_get_rgb(psrc, x, y, rgb);
dispx = (float)x + (rgb[1]/dltg * 20.0);
dispy = (float)y + (rgb[2]/dltb * 10.0);
dstx = (int)roundf(dispx - 10.0);
dsty = (int)roundf(dispy - 10.0);
if ( (dstx < 0) || (dsty < 0) ||
(dstx >= psrc->width) ||
(dsty >= psrc->height) )
{
/* OUT OF DESTINATION PICTURE */
out++;
}
else {
if (flags & 1) {
/* going monochrome */
rgb[1] = rgb[2] = rgb[0];
}
fimg_put_rgb(pdst, dstx, dsty, rgb);
// fprintf(stderr, "%5d %5d %f\n", dstx, dsty, rgb[1]);
in++;
}
}
if (verbosity > 2) {
fprintf(stderr, "%4d / %4d\n", y, psrc->height);
}
}
if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out);
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -14,37 +14,6 @@ int verbosity;
float global_fvalue; float global_fvalue;
/* --------------------------------------------------------------------- */
/* nouveau 24 octobre 2020, pendant le masque-flamme coronavidique */
int essai_displacement(char *infile, char *outfile)
{
int foo;
FloatImg src, dst;
fprintf(stderr, "%s : loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
return foo;
}
fimg_clone(&src, &dst, 1);
foo = fimg_displacement_0(&src, &dst, 0);
if (foo) {
fprintf(stderr, "%s: err %d in disp map 0\n", __func__, foo);
return foo;
}
foo = fimg_export_picture(&dst, outfile, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
return 0;
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* /*
* nouveau 7 octobre 2020 pendant sonoptic * nouveau 7 octobre 2020 pendant sonoptic
@ -588,8 +557,7 @@ return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
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 };
typedef struct { typedef struct {
char *name; char *name;
int Cmd; int Cmd;
@ -609,7 +577,6 @@ Command commands[] = {
{ "classif", Classif }, { "classif", Classif },
{ "ctr2x2", Ctr2x2 }, { "ctr2x2", Ctr2x2 },
{ "qsortrgb", Qsortrgb }, { "qsortrgb", Qsortrgb },
{ "displace", Displace },
{ NULL, 0 } { NULL, 0 }
} ; } ;
@ -653,11 +620,10 @@ int foo, opt;
char *filename, *command, *outfile; char *filename, *command, *outfile;
fprintf(stderr, "++++++++ test des fonctions pid=%d\n", getpid()); fprintf(stderr, "++++++++ test des fonctions pid=%d\n", getpid());
fprintf(stderr, "++++++++ compiled "__DATE__" at " __TIME__ "\n");
global_fvalue = 1.0; global_fvalue = 1.0;
outfile = "out.pnm"; outfile = "out.pnm";
command = "none";
while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) { while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) {
switch(opt) { switch(opt) {
@ -724,9 +690,6 @@ switch(opt) {
case Qsortrgb: case Qsortrgb:
foo = essai_qsort_rgb(filename, outfile); foo = essai_qsort_rgb(filename, outfile);
break; break;
case Displace:
foo = essai_displacement(filename, outfile);
break;
default: default:
fprintf(stderr, "%s : bad command\n", command); fprintf(stderr, "%s : bad command\n", command);
exit(1); exit(1);

View File

@ -7,16 +7,6 @@
extern int verbosity; /* must be declared around main() */ extern int verbosity; /* must be declared around main() */
/* --------------------------------------------------------------------- */
void fimg_print_minmax(float minmax[6], char *titre)
{
fprintf(stderr, "\t\tminmax %s\n", titre);
fprintf(stderr, "red\t\t%10f %10f\n", minmax[0], minmax[1]);
fprintf(stderr, "green\t\t%10f %10f\n", minmax[2], minmax[3]);
fprintf(stderr, "blue\t\t%10f %10f\n", minmax[4], minmax[5]);
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int parse_WxH(char *str, int *pw, int *ph) int parse_WxH(char *str, int *pw, int *ph)
{ {

View File

@ -6,7 +6,7 @@ out=out.fimg
maxi=49 maxi=49
W="640" W="640"
H="480" H="480"
grabopt=" -s 640x480 -vv -p 0 -n 500 -c cos01 " grabopt=" -s 640x480 -vv -p 0 -n 400 -c pow2 "
mkdir /tmp/V mkdir /tmp/V
@ -20,11 +20,9 @@ do
grabvidseq -$grabopt -o $src grabvidseq -$grabopt -o $src
fval=$(echo "$foo / $maxi" | bc -l) fval=$(echo "$foo / $maxi" | bc -l)
./t -vv -k 0.333 -o $out displace $src ./t -vv -k 0.333 -o $out classif $src
# fimgstats $out
echo $foo ' => ' $fval echo $foo ' => ' $fval
dst=$(printf "/tmp/V/%03d.png" $foo) dst=$(printf "/tmp/V/%03d.png" $foo)
echo $dst echo $dst
montage $src $out -tile 1x2 -geometry $G $dst montage $src $out -tile 1x2 -geometry $G $dst