tryint to repair a broken git

This commit is contained in:
tth 2022-01-21 14:48:45 +01:00
commit fcd8b09029
12 changed files with 224 additions and 265 deletions

8
.gitignore vendored
View File

@ -9,6 +9,8 @@ lib/*.gif
*.a *.a
gmon.out gmon.out
*.swp
*.pnm *.pnm
*.fimg *.fimg
essai essai
@ -88,4 +90,8 @@ experiment/muxplanes
experiment/movepixels experiment/movepixels
experiment/tcache experiment/tcache
contrib/fimg2povhf
contrib/*.tga
contrib/pov.stderr
contrib/*.png
contrib/*.gif

View File

@ -38,6 +38,10 @@ apt install libv4l2-dev
apt install libcfitsio-dev apt install libcfitsio-dev
apt install libnetpbm-dev apt install libnetpbm-dev
``` ```
Il est probable que j'en oublient. Ensuite, j'ai dans l'idée de construire
um met-packet à la sauce Debian pour installer facilement tout ce
qui sert à faire fonctionner ce kluge. Ensuite, j'irais voir du
coté de pkg-config.
Certains outils externes sont aussi utiles : Certains outils externes sont aussi utiles :

7
contrib/Makefile Normal file
View File

@ -0,0 +1,7 @@
DBGL = '-DDEBUG_LEVEL=1 -g '
fimg2povhf: fimg2povhf.c Makefile
gcc -Wall $(DBGL) $< -limage -lfloatimg -lm -o $@

12
contrib/README.md Normal file
View File

@ -0,0 +1,12 @@
# Contributions
## fimg2povhf
Need some external garbage, sorry.
Try to compile this really old code:
http://la.buvette.org/devel/libimage/libimage.html
Use the code, frtk !

116
contrib/fimg2povhf.c Normal file
View File

@ -0,0 +1,116 @@
/*
* convertir une image flottante en champ d'altitude
*
* nouveau 64 ernest renan - 20220108
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "tthimage.h"
#include "floatimg.h"
int verbosity;
/* ------------------------------------------------------------------ */
int This_is_the_real_conversion(FloatImg *fimg, Image_Desc *hf, int k)
{
int foo;
float minmax[6];
int x, y, h;
float rgb[6], cumul;
float maxi;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, fimg, hf, k);
#endif
foo = fimg_get_minmax_rgb(fimg, minmax);
// fimg_print_minmax(minmax, "source");
maxi = 0.0;
for (y=0; y<fimg->height; y++) {
for (x=0; x<fimg->width; x++) {
foo = fimg_get_rgb(fimg, x, y, rgb);
/* non-magic nuabmer spotted */
cumul = 1.732 * (rgb[1] + rgb[3] + rgb[5]);
if (cumul > maxi) maxi = cumul;
h = (int)cumul;
foo = Image_hf15_plot(hf, x, y, h);
}
}
fprintf(stderr, "--- the critical maximum is %f\n", maxi);
return FULL_NUCKED;
}
/* ------------------------------------------------------------------ */
int Convertir_Fimg_to_Povhf(char *fimgname, char *hfname, int k)
{
FloatImg fimg;
Image_Desc *hf;
int wid, hei;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %s %s %d )\n", __func__, fimgname, hfname, k);
#endif
foo = fimg_create_from_dump(fimgname, &fimg);
fprintf(stderr, "load of %s --> %d\n", fimgname, foo);
if (foo) {
return foo;
}
wid = fimg.width; hei = fimg.height; // nice alias
fprintf(stderr, " source picture size %dx%d\n", wid, hei);
hf = Image_alloc(wid, hei, IMAGE_RGB);
fprintf(stderr, "hf alloc -> %p\n", hf);
if (NULL == hf) {
return NULL_POINTER;
}
foo = This_is_the_real_conversion(&fimg, hf, k);
fprintf(stderr, "real conversion -> %d\n", foo);
foo = Image_TGA_save(hfname, hf, 0);
fprintf(stderr, "export as tga -> %d\n", foo);
return FULL_NUCKED;
}
/* ------------------------------------------------------------------ */
void help(int nu)
{
printf("usage :\n");
printf("\t$ fimg2povhf src.fimg dst.tga\n");
}
/* ------------------------------------------------------------------ */
int main(int argc, char *argv[])
{
int foo;
verbosity = 1;
// printf("%s: argc = %d\n", argv[0], argc);
if (3 != argc) {
help(0);
exit(0);
}
if (verbosity > 1) {
Image_print_version(3);
fimg_print_version(3);
}
foo = Convertir_Fimg_to_Povhf(argv[1], argv[2], 0);
fprintf(stderr, "retour conversion was %d\n", foo);
fprintf(stderr, "end\n\n");
return 0;
}
/* ------------------------------------------------------------------ */

31
contrib/raytrace.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
src="/dev/shm/foo.fimg"
dst="hf.tga"
TMPDIR=${HOME}/TMP
POVOPT="-w512 -h342 +q9 -a "
rm $TMPDIR/hf???.png
for idx in $(seq 0 60)
do
echo "========================== " $idx
grabvidseq -v \
-d /dev/video0 -s 640x480 \
-n 60 -p 1.0 \
-o ${src}
./fimg2povhf $src $dst
out=$(printf "%s/hf%03d.png" $TMPDIR $idx)
echo "raytracing " ${POVOPT} $out
povray -iscene.pov ${POVOPT} -o${out} 2> pov.stderr
# tail -15 pov.stderr
done
convert -delay 10 -colors 240 $TMPDIR/hf???.png foo.gif

41
contrib/scene.pov Normal file
View File

@ -0,0 +1,41 @@
/* scene demo conversion floatimg -> height field */
#version 3.7;
global_settings {
ambient_light rgb <0.07, 0.07, 0.07>
assumed_gamma 1.0
}
#include "colors.inc"
height_field {
tga "hf.tga"
smooth
pigment { color Orange*0.7 }
translate <-0.5, 0, -0.5>
// scale 2
translate y*0.002
}
camera {
location <-0.86, 4, -6.20>
look_at <0, 0, 0>
angle 14
}
plane {
<0, 1, 0>, 0
pigment {
hexagon
pigment { color Gray20 },
pigment { color Gray10 },
pigment { color Gray30 }
}
scale 0.27
}
light_source { <-9, 2, 3> color White }

View File

@ -5,7 +5,7 @@
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 = ../libfloatimg.a -ltiff -lpnglite -lcfitsio LIBS = ../libfloatimg.a -ltiff -lpnglite -lcfitsio -lm
all: assemblage extracteur muxplanes movepixels all: assemblage extracteur muxplanes movepixels

View File

@ -74,6 +74,9 @@ if (foo) {
fimg_export_picture(&dest, dst, 0); fimg_export_picture(&dest, dst, 0);
fimg_destroy(&imr); fimg_destroy(&img);
fimg_destroy(&imr); fimg_destroy(&dest);
return 0; return 0;
} }
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */ /* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */

View File

@ -1,262 +0,0 @@
/*
* floatimg.h
* ugly code from tTh
* http://la.buvette.org/photos/cumul
*/
#define FIMG_VERSION 165
/*
* in memory descriptor
*/
#define MAGIC_FIMG 0x00F11F00
typedef struct {
uint32_t magic;
int width;
int height;
int type;
float fval;
int count;
float *R, *G, *B, *A;
int reserved;
} FloatImg;
/*
* fimg file header
*/
typedef struct {
char magic[8];
int32_t w, h, t;
} FimgFileHead;
/*
* we MUST look at packing and endianess problems NOW */
#define MAGIC_AREA51 0xA5EA0051
typedef struct {
uint32_t magic;
int w, h;
int x, y;
int flags;
} FimgArea51;
#define FIMG_TYPE_GRAY 1
#define FIMG_TYPE_RGB 3
#define FIMG_TYPE_RGBA 4
#define FIMG_TYPE_RGBZ 99
#define FILE_TYPE_FIMG 1
#define FILE_TYPE_PNM 2
#define FILE_TYPE_PNG 3
#define FILE_TYPE_TGA 4
#define FILE_TYPE_TIFF 5
#define FILE_TYPE_FITS 6
#define FILE_TYPE_BMP 7
#define FILE_TYPE_EXR 8
#define FILE_TYPE_DICOM 9
/* lib/contrast.c */
#define CONTRAST_NONE 0
#define CONTRAST_SQRT 1
#define CONTRAST_POW2 2
#define CONTRAST_COS01 3
#define CONTRAST_COS010 4
#define CONTRAST_XPER 5 /* use with caution */
/*
* core module
*/
int fimg_create(FloatImg *fimg, int w, int h, int t);
int fimg_destroy(FloatImg *fimg);
int fimg_clone(FloatImg *fimg, FloatImg *newpic, int flags);
int fimg_copy_data(FloatImg *from, FloatImg *to);
int fimg_type_is_valid(int type);
int fimg_print_version(int k);
void fimg_print_sizeof(void);
void fimg_printhead(FloatImg *h);
void fimg_printdims(char *txt, FloatImg *pi);
int fimg_describe(FloatImg *head, char *txt);
char *fimg_str_type(int type);
int fimg_plot_rgb (FloatImg *head, int x, int y,
float r, float g, float b);
int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb);
int fimg_put_rgb(FloatImg *head, int x, int y, float *rgb);
int fimg_clear(FloatImg *fimg);
int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b);
int fimg_rgb_constant(FloatImg *head, float r, float g, float b);
/* --> lib/fimg-compare.c */
int fimg_images_not_compatible(FloatImg *a, FloatImg *b);
int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef);
/* 'operats' module */
int fimg_add_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_add_2(FloatImg *a, FloatImg *b); /* B+=A */
int fimg_sub_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
/* funcs/filtrage.c */
typedef struct {
float matrix[9];
float mult;
float offset;
} FimgFilter3x3;
int fimg_killborders(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_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse);
/* module sfx0.c */
int fimg_killcolors_a(FloatImg *fimg, float fval);
int fimg_killcolors_b(FloatImg *fimg, float fval);
int fimg_colors_mixer_a(FloatImg *fimg, float fval);
/* module sfx1.c */
int fimg_highlight_color(FloatImg *src, FloatImg *dst,
char color, float fval);
/* module sfx2.c */
int fimg_binarize(FloatImg *pimg, int notused);
int fimg_trinarize(FloatImg *pimg, int notused);
/* module sfx3.c */
int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused);
/* module sfx4.c */
int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused);
int fimg_split_level(FloatImg *src, FloatImg *dst, int notused);
/* funcs/rotate.c module */
/* #coronamaison */
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);
int fimg_save_plane_as_dicom(FloatImg *src, char *outname,
char plane, int flags);
/* universal exporter XXX */
int fimg_export_picture(FloatImg *pic, char *fname, int flags);
/* PNM files module */
int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
int fimg_load_from_pnm(char *fname, FloatImg *head, int notused);
double fimg_timer_set(int whot);
double fimg_timer_get(int whot);
/* --> lib/contrast.c */
int fimg_id_contraste(char *name);
int fimg_square_root(FloatImg *s, FloatImg *d, double maxval);
int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
int fimg_mix_rgb_gray(FloatImg *img, float mix);
/* funcs/saturation.c */
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
/* --> funcs/plasmas.c */
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 ! */
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_b(FloatImg *psrc, FloatImg *pdst, int notused);
/* module funcs/??????.c */
int fimg_equalize_compute(FloatImg *src, void *vptr, float vmax);
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
int fimg_desaturate(FloatImg *src, FloatImg *dst, int notused);
/* module funcs/geometry.c */
/* warning, this module is a mess */
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused);
int fimg_halfsize_1(FloatImg *src, FloatImg *dst, int notused);
int fimg_extractor(FloatImg *in, FloatImg *out, FimgArea51 *rect);
int fimg_mirror(FloatImg *src, FloatImg *dst, int notused);
int fimg_incrustator_0(FloatImg *psrc, FloatImg *pdst,
int xpos, int ypos, int flags);
int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
/* module funcs/rampes.c */
int fimg_hdeg_a(FloatImg *img, double dcoef);
int fimg_vdeg_a(FloatImg *img, double dcoef);
/* FIMG files module */
int fimg_fileinfos(char *fname, int *datas);
int fimg_dump_to_file(FloatImg *head, char *fname, int notused);
int fimg_load_from_dump(char *fname, FloatImg *where);
int fimg_create_from_dump(char *fname, FloatImg *head);
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);
int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);
int fimg_save_B_as_fits(FloatImg *src, char *outname, int flags);
int fimg_save_plane_as_fits(FloatImg *src, char *oname, char plane, int flags);
int fimg_write_as_tiff(FloatImg *src, char *fname, int flags);
int fimg_save_as_exr(FloatImg *src, char *outname, int flags);
/* mathematics operations */
float fimg_get_maxvalue(FloatImg *head);
int fimg_get_minmax_rgb(FloatImg *head, float mmvals[6]);
int fimg_meanvalues(FloatImg *head, float means[4]);
int fimg_to_gray(FloatImg *head);
int fimg_add_cste(FloatImg *fi, float value);
int fimg_mul_cste(FloatImg *fi, float value);
int fimg_ajust_from_grab(FloatImg *fi, double maxima, int notused);
int fimg_absolute(FloatImg *fimg);
void fimg_drand48(FloatImg *fi, float kmul);
long fimg_count_negativ(FloatImg *fi);
long fimg_clamp_negativ(FloatImg *fi);
/* various funcs modules */
int fimg_load_from_png(char *filename, FloatImg *fimg);
int fimg_create_from_png(char *filename, FloatImg *fimg);
int fimg_save_as_png(FloatImg *src, char *outname, int flags);
int fimg_save_as_bmp(FloatImg *src, char *outname, int flags);
int fimg_test_pattern(FloatImg *fimg, int type, double dval);
int fimg_draw_something(FloatImg *fimg);
int fimg_mircol_1(FloatImg *dst, float mval);
int fimg_multirandom(FloatImg *fimg, long nbpass);
/* file is 'funcs/utils.c' */
void fimg_print_minmax(float minmax[6], char *titre);
float *charplane2int(char plane, FloatImg *img);
int parse_WxH(char *str, int *pw, int *ph);
int parse_double(char *str, double *dptr);
int irand2(int offset, int modulo);
int print_rectangle(char *str, FimgArea51 *rect);
int parse_rectangle(char *str, FimgArea51 *r, int notused);
int format_from_extension(char *fname);
char * extension_from_format(int fmt);
int fimg_clear_rectangle(FloatImg *pimg, int rect[4]);

View File

@ -63,7 +63,7 @@ if (fimg_images_not_compatible(src, dst)) {
return -98; return -98;
} }
if (verbosity) { if (verbosity > 1) {
fimg_show_filter("essai", filtr); fimg_show_filter("essai", filtr);
} }

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <fcntl.h> /* low-level i/o */ #include <fcntl.h> /* low-level i/o */
#include <unistd.h> #include <unistd.h>