Compare commits
2
Commits
69d94f59d3
...
583151302a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
583151302a | ||
|
|
268a73ceb5 |
+1
-1
@@ -6,7 +6,7 @@ cp floatimg.h /usr/local/include
|
|||||||
cp tools/mkfimg tools/fimg2pnm tools/fimgops \
|
cp tools/mkfimg tools/fimg2pnm tools/fimgops \
|
||||||
tools/fimg2png tools/fimg2tiff tools/fimg2fits \
|
tools/fimg2png tools/fimg2tiff tools/fimg2fits \
|
||||||
tools/png2fimg tools/fimgstats tools/fimgfx \
|
tools/png2fimg tools/fimgstats tools/fimgfx \
|
||||||
tools/cumulfimgs \
|
tools/cumulfimgs tools/fimg2text \
|
||||||
/usr/local/bin
|
/usr/local/bin
|
||||||
|
|
||||||
cp v4l2/grabvidseq v4l2/video-infos \
|
cp v4l2/grabvidseq v4l2/video-infos \
|
||||||
|
|||||||
+2
-1
@@ -88,8 +88,9 @@ if (2 != argc-optind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray);
|
foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray);
|
||||||
if (foo)
|
if (foo) {
|
||||||
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-11
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* converting a floatimg to a machinable text file
|
* converting a floatimg to a machinable text file
|
||||||
|
* an ugly software from tTh - february 2021
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
int verbosity;
|
int verbosity;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
int export_as_machinable(FloatImg *src, char *fname, int flags)
|
int export_as_machinable(FloatImg *src, char *fname, int steps, int flags)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int x, y, idx;
|
int x, y, idx;
|
||||||
@@ -32,11 +33,12 @@ if (strcmp("-", fname)) { /* real file */
|
|||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
fp = stdout; /* XXX */
|
fp = stdout; /* XXX */
|
||||||
for (y=0; y<src->height; y++) {
|
for (y=0; y<src->height; y+=steps) {
|
||||||
for (x=0; x<src->width; x++) {
|
for (x=0; x<src->width; x+=steps) {
|
||||||
|
|
||||||
fprintf(fp, "%d %d %d ", x, y, idx);
|
fprintf(fp, "%d %d ", x, y);
|
||||||
fprintf(fp, " %f %f %f\n", src->R[idx], src->G[idx], src->B[idx]);
|
fprintf(fp, " %f %f %f\n",
|
||||||
|
src->R[idx], src->G[idx], src->B[idx]);
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -45,7 +47,37 @@ for (y=0; y<src->height; y++) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
int convertir_fimg_en_machinable(char *srcname, char *dstname, int grisaille)
|
static int normalize(FloatImg *pimg, float vmax)
|
||||||
|
{
|
||||||
|
float mmv[6], maxi, coef;
|
||||||
|
int foo, sz, idx;
|
||||||
|
|
||||||
|
// #if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %g )\n", __func__, pimg, vmax);
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
foo = fimg_get_minmax_rgb(pimg, mmv);
|
||||||
|
fimg_print_minmax(mmv, "norm it ?");
|
||||||
|
maxi = mmv[1];
|
||||||
|
if (mmv[3] > maxi) maxi = mmv[3];
|
||||||
|
if (mmv[5] > maxi) maxi = mmv[5];
|
||||||
|
fprintf(stderr, "maximum = %f\n", maxi);
|
||||||
|
coef = vmax / maxi;
|
||||||
|
fprintf(stderr, "coef = %f\n", coef);
|
||||||
|
|
||||||
|
sz = pimg->width * pimg->height;
|
||||||
|
|
||||||
|
for (idx=0; idx<sz; idx++) {
|
||||||
|
pimg->R[idx] *= coef;
|
||||||
|
pimg->G[idx] *= coef;
|
||||||
|
pimg->B[idx] *= coef;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
int convertir_fimg_en_machinable(char *srcname, char *dstname,
|
||||||
|
int steps, float norm)
|
||||||
{
|
{
|
||||||
int foo, infos[3];
|
int foo, infos[3];
|
||||||
FloatImg fimg;
|
FloatImg fimg;
|
||||||
@@ -77,8 +109,12 @@ if (foo) {
|
|||||||
if (verbosity) {
|
if (verbosity) {
|
||||||
fimg_describe(&fimg, srcname);
|
fimg_describe(&fimg, srcname);
|
||||||
}
|
}
|
||||||
|
if (norm > 0.0) {
|
||||||
|
fprintf(stderr, "normalize %p\n", &fimg);
|
||||||
|
foo = normalize(&fimg, norm);
|
||||||
|
}
|
||||||
|
|
||||||
foo = export_as_machinable(&fimg, dstname, 0);
|
foo = export_as_machinable(&fimg, dstname, steps, 0);
|
||||||
|
|
||||||
fimg_destroy(&fimg);
|
fimg_destroy(&fimg);
|
||||||
|
|
||||||
@@ -87,12 +123,12 @@ return 0;
|
|||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
void help(int k)
|
void help(int k)
|
||||||
{
|
{
|
||||||
|
|
||||||
puts("usage:\n\tfimg2text [options] foo.fimg > bar.csv");
|
puts("usage:\n\tfimg2text [options] foo.fimg > bar.csv");
|
||||||
puts("options:");
|
puts("options:");
|
||||||
puts("\t-v\tincrease verbosity");
|
puts("\t-v\tincrease verbosity");
|
||||||
|
puts("\t-n 3.14\tnormalize picture");
|
||||||
|
puts("\t-s N\nsteps on x & y");
|
||||||
if (verbosity) fimg_print_version(1);
|
if (verbosity) fimg_print_version(1);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
@@ -100,11 +136,15 @@ exit(0);
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int foo, opt;
|
int foo, opt;
|
||||||
|
int steps = 16;
|
||||||
|
float norm_val = 222.0; /* < 0 : don't normalize */
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ghv")) != -1) {
|
while ((opt = getopt(argc, argv, "hs:v")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'v': verbosity++; break;
|
case 'v': verbosity++; break;
|
||||||
case 'h': help(1); exit(1);
|
case 'h': help(1); exit(1);
|
||||||
|
case 's': steps = atoi(optarg); break;
|
||||||
|
case 'n': norm_val = atof(optarg); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +153,7 @@ if (1 != argc-optind) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foo = convertir_fimg_en_machinable(argv[optind], "-", 0);
|
foo = convertir_fimg_en_machinable(argv[optind], "-", steps, norm_val);
|
||||||
if (foo)
|
if (foo)
|
||||||
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user