Ok, this writz is working

This commit is contained in:
tTh 2022-01-08 21:51:31 +01:00
parent ccd324749e
commit a8d1e18650
6 changed files with 125 additions and 10 deletions

5
.gitignore vendored
View File

@ -91,4 +91,7 @@ experiment/movepixels
experiment/tcache
contrib/fimg2povhf
contrib/*.tga
contrib/pov.stderr
contrib/*.png
contrib/*.gif

View File

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

View File

@ -1,4 +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 !

View File

@ -5,6 +5,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "tthimage.h"
@ -15,17 +16,33 @@ int verbosity;
/* ------------------------------------------------------------------ */
int This_is_the_real_conversion(FloatImg *fimg, Image_Desc *hf, int k)
{
FloatImg mixed;
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");
// 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;
}
@ -36,7 +53,6 @@ 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
@ -48,7 +64,7 @@ if (foo) {
}
wid = fimg.width; hei = fimg.height; // nice alias
fprintf(stderr, "picture size %dx%d\n", wid, hei);
fprintf(stderr, " source picture size %dx%d\n", wid, hei);
hf = Image_alloc(wid, hei, IMAGE_RGB);
fprintf(stderr, "hf alloc -> %p\n", hf);
@ -59,9 +75,18 @@ if (NULL == hf) {
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[])
{
@ -69,13 +94,22 @@ int foo;
verbosity = 1;
Image_print_version(3);
fimg_print_version(3);
// printf("%s: argc = %d\n", argv[0], argc);
if (3 != argc) {
help(0);
exit(0);
}
foo = Convertir_Fimg_to_Povhf("foo.fimg", "out.tga", 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;
}

30
contrib/raytrace.sh Executable file
View File

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

40
contrib/scene.pov Normal file
View File

@ -0,0 +1,40 @@
/* 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.5 }
translate <-0.5, 0, -0.5>
scale 2
translate y*0.01
}
camera {
location <-0.86, 3, -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 }