blam again ??
This commit is contained in:
@@ -5,7 +5,8 @@ DEPS = ../floatimg.h Makefile
|
||||
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 \
|
||||
equalize.o fimg-fits.o saturation.o histogram.o \
|
||||
hsv.o classif.o contour2x2.o qsortrgb.o
|
||||
hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \
|
||||
displacement.o dithering.o
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
||||
@@ -19,6 +20,9 @@ t: t.c $(DEPS) ../libfloatimg.a
|
||||
../libfloatimg.a: $(OBJS)
|
||||
$(AR) r $@ $?
|
||||
|
||||
displacement.o: displacement.c
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
fimg-png.o: fimg-png.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
@@ -52,6 +56,10 @@ histogram.o: histogram.c $(DEPS)
|
||||
equalize.o: equalize.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
dithering.o: dithering.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
|
||||
sfx0.o: sfx0.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
@@ -67,6 +75,9 @@ classif.o: classif.c $(DEPS)
|
||||
qsortrgb.o: qsortrgb.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
exporter.o: exporter.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
|
||||
hsv.o: hsv.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
20
funcs/README.md
Normal file
20
funcs/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Fonctions
|
||||
|
||||
Plein de fonctions qu'il serait bon de documenter :)
|
||||
|
||||
## Contours
|
||||
|
||||
Détecter des contours est une activité respectable.
|
||||
|
||||
## Exporter
|
||||
|
||||
Une méta-fonction qui va sauvegarder (dans la mesure de ses conséquences)
|
||||
une image en fonction de l'extension du nom de fichier.
|
||||
|
||||
## Sfx
|
||||
|
||||
Effets spéciaux divers.
|
||||
|
||||
## Dithering
|
||||
|
||||
Work in progress...
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
int verbosity;
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* nouveau 2 octobre 2020, juste avant sonoptic de la pluie craignos */
|
||||
@@ -21,9 +21,19 @@ float range, dist, rgb[3], dr, dg, db;
|
||||
int x, y, on, off;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__, psrc, pdst, fval, notused);
|
||||
fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__,
|
||||
psrc, pdst, fval, notused);
|
||||
#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;
|
||||
}
|
||||
|
||||
/* calculer les amplitudes RGB de l'image source */
|
||||
fimg_get_minmax_rgb(psrc, minmax);
|
||||
delta[0] = minmax[1] - minmax[0];
|
||||
@@ -37,7 +47,7 @@ range = delta[0]; if (delta[1]<range) range=delta[1];
|
||||
/* convertir le diametre en rayon (magic inside) */
|
||||
range *= fval;
|
||||
|
||||
if (verbosity ) fprintf(stderr, "deltas : %f %f %f / %f\n",
|
||||
if (verbosity > 1) fprintf(stderr, "deltas : %f %f %f / %f\n",
|
||||
delta[0], delta[1], delta[2], range);
|
||||
|
||||
|
||||
@@ -45,7 +55,7 @@ if (verbosity ) fprintf(stderr, "deltas : %f %f %f / %f\n",
|
||||
baryc[0] = (minmax[1] + minmax[0]) / 2;
|
||||
baryc[1] = (minmax[3] + minmax[2]) / 2;
|
||||
baryc[2] = (minmax[5] + minmax[4]) / 2;
|
||||
if (verbosity) fprintf(stderr, "barycs : %f %f %f\n",
|
||||
if (verbosity > 1) fprintf(stderr, "barycs : %f %f %f\n",
|
||||
baryc[0], baryc[1], baryc[2]);
|
||||
|
||||
on = off = 0;
|
||||
@@ -83,7 +93,7 @@ for (y=0; y<psrc->height; y++) {
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "on %d off %d\n", on, off);
|
||||
if (verbosity > 1) fprintf(stderr, "on %d off %d\n", on, off);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
int verbosity;
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* nouveau 4 octobre 2020, juste avant sonoptic de la pluie craignos */
|
||||
|
||||
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int notused)
|
||||
int fimg_contour_2x2(FloatImg *psrc, FloatImg *pdst, int reverse)
|
||||
{
|
||||
float avg[4];
|
||||
int foo, x, y, q;
|
||||
float v1, v2;
|
||||
|
||||
int tbl[] = /* deep magic inside */
|
||||
{
|
||||
@@ -28,11 +29,27 @@ int tbl[] = /* deep magic inside */
|
||||
};
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, reverse);
|
||||
#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;
|
||||
}
|
||||
|
||||
if (reverse) {
|
||||
v1 = 0.0; v2 = 1.0;
|
||||
}
|
||||
else {
|
||||
v1 = 1.0; v2 = 0.0;
|
||||
}
|
||||
|
||||
foo = fimg_meanvalues(psrc, avg);
|
||||
if (verbosity) {
|
||||
if (verbosity > 1) {
|
||||
fprintf(stderr, "mean values : %f %f %f\n", avg[0], avg[1], avg[2]);
|
||||
}
|
||||
|
||||
@@ -48,24 +65,27 @@ for (y=0; y<psrc->height-1; y++) {
|
||||
( RP(x+1, y) << 2 ) |
|
||||
( RP(x, y+1) << 1 ) |
|
||||
( RP(x+1, y+1) ) );
|
||||
pdst->R[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ;
|
||||
pdst->R[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
|
||||
|
||||
q = ( ( GP(x, y) << 3 ) |
|
||||
( GP(x+1, y) << 2 ) |
|
||||
( GP(x, y+1) << 1 ) |
|
||||
( GP(x+1, y+1) ) );
|
||||
pdst->G[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ;
|
||||
pdst->G[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
|
||||
|
||||
q = ( ( BP(x, y) << 3 ) |
|
||||
( BP(x+1, y) << 2 ) |
|
||||
( BP(x, y+1) << 1 ) |
|
||||
( BP(x+1, y+1) ) );
|
||||
pdst->B[(y*psrc->width)+x] = tbl[q] ? 1.0 : 0.0 ;
|
||||
pdst->B[(y*psrc->width)+x] = tbl[q] ? v1 : v2 ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* kill potential NaN values in last row or last column */
|
||||
fimg_killborders(pdst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
89
funcs/displacement.c
Normal file
89
funcs/displacement.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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);
|
||||
in++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (verbosity) fprintf(stderr, "%s -> in %d out %d\n", __func__, in, out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
||||
31
funcs/dithering.c
Normal file
31
funcs/dithering.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* FloatImg : some dithering experiments
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_dither_0(FloatImg *psrc, FloatImg *pdst, int flags)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (y=0; y<psrc->height; y++) {
|
||||
|
||||
for (x=0; x<psrc->width; x++)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
75
funcs/exporter.c
Normal file
75
funcs/exporter.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* exporter.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* multi-magic 'save file' function.
|
||||
*/
|
||||
int fimg_export_picture(FloatImg *pic, char *fname, int flags)
|
||||
{
|
||||
int filetype;
|
||||
int foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p '%s' 0x%X )\n", __func__,
|
||||
pic, fname, flags);
|
||||
#endif
|
||||
|
||||
filetype = format_from_extension(fname);
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "file %s : type %d\n", fname, filetype);
|
||||
}
|
||||
|
||||
switch(filetype) {
|
||||
|
||||
case FILE_TYPE_FIMG:
|
||||
foo = fimg_dump_to_file(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_PNM:
|
||||
foo = fimg_save_as_pnm(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_PNG:
|
||||
foo = fimg_save_as_png(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_TGA:
|
||||
fprintf(stderr, "%s: FILE_TYPE_TGA not implemented\n",
|
||||
__func__);
|
||||
foo = -666;
|
||||
break;
|
||||
|
||||
case FILE_TYPE_TIFF:
|
||||
foo = fimg_write_as_tiff(pic, fname, 0);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_FITS:
|
||||
foo = fimg_save_R_as_fits(pic, fname, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
foo = -1789;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: exporting '%s' -> %d\n", __func__,
|
||||
fname, foo);
|
||||
/* que faire maintenant ? */
|
||||
}
|
||||
|
||||
return foo;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
@@ -168,7 +168,8 @@ for (idx=0; idx<w; idx++) {
|
||||
fimg_plot_rgb(img, idx, h-1, 0.0, 0.0, 0.0);
|
||||
#endif
|
||||
}
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* -------------------------------------------------------------------- */
|
||||
int fimg_lissage_2x2(FloatImg *img)
|
||||
|
||||
@@ -27,6 +27,15 @@ int foo, szimg;
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
|
||||
#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_copy_data(psrc, pdst);
|
||||
|
||||
szimg = pdst->width * pdst->height;
|
||||
@@ -44,7 +53,7 @@ typedef struct {
|
||||
float r, g, b;
|
||||
} pix;
|
||||
|
||||
static compare_b(const void *p1, const void *p2)
|
||||
static int compare_b(const void *p1, const void *p2)
|
||||
{
|
||||
pix *s1, *s2;
|
||||
s1 = (pix *)p1;
|
||||
@@ -62,6 +71,15 @@ float rgb[3];
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused);
|
||||
#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;
|
||||
}
|
||||
|
||||
szimg = pdst->width * pdst->height;
|
||||
fprintf(stderr, "%s : %d pixels\n", __func__, szimg);
|
||||
|
||||
|
||||
93
funcs/t.c
93
funcs/t.c
@@ -14,12 +14,43 @@ int verbosity;
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
int essai_qsort_rgb(char *infile)
|
||||
int essai_qsort_rgb(char *infile, char *outfile)
|
||||
{
|
||||
FloatImg src, dst;
|
||||
int foo;
|
||||
@@ -45,12 +76,14 @@ if (foo) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = fimg_dump_to_file(&dst, "out.fimg", 0);
|
||||
foo = fimg_export_picture(&dst, outfile, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
fimg_destroy(&src); fimg_destroy(&dst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -58,7 +91,8 @@ return 0;
|
||||
/*
|
||||
* nouveau 5 octobre 2020 pendant sonoptic
|
||||
*/
|
||||
int essai_contour_2x2(char *infile)
|
||||
|
||||
int essai_contour_2x2(char *infile, char *outfile)
|
||||
{
|
||||
FloatImg src, dst;
|
||||
int foo;
|
||||
@@ -84,19 +118,21 @@ if (foo) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = fimg_save_as_pnm(&dst, "out.pnm", 0);
|
||||
foo = fimg_export_picture(&dst, outfile, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
fimg_destroy(&src); fimg_destroy(&dst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* nouveau 5 octobre 2020 pendant sonoptic
|
||||
*/
|
||||
int essai_classif(char *infile)
|
||||
int essai_classif(char *infile, char *outfile)
|
||||
{
|
||||
FloatImg src, dst;
|
||||
int foo;
|
||||
@@ -124,12 +160,14 @@ if (foo) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = fimg_save_as_pnm(&dst, "out.pnm", 0);
|
||||
foo = fimg_export_picture(&dst, outfile, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
fimg_destroy(&src); fimg_destroy(&dst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
@@ -222,8 +260,8 @@ fimg_save_as_png(&src, "test.png", 0);
|
||||
foo = fimg_rotate_90(&src, &dst, 0);
|
||||
fprintf(stderr, "rotate 90 -> %d\n", foo);
|
||||
|
||||
foo = fimg_save_as_png(&dst, "rotated90.png", 0);
|
||||
foo = fimg_save_as_pnm(&dst, "rotated90.pnm", 0);
|
||||
foo = fimg_export_picture(&dst, "rotated90.png", 0);
|
||||
foo = fimg_export_picture(&dst, "rotated90.pnm", 0);
|
||||
|
||||
fimg_destroy(&src);
|
||||
|
||||
@@ -456,6 +494,12 @@ printf("%-10s %d\n\n", fname, foo);
|
||||
foo = format_from_extension(fname="foo.png");
|
||||
printf("%-10s %d\n\n", fname, foo);
|
||||
|
||||
foo = format_from_extension(fname="foo.tiff");
|
||||
printf("%-10s %d\n\n", fname, foo);
|
||||
|
||||
foo = format_from_extension(fname="foo.fits");
|
||||
printf("%-10s %d\n\n", fname, foo);
|
||||
|
||||
foo = format_from_extension(fname="foo.xyzzy");
|
||||
printf("%-10s %d\n\n", fname, foo);
|
||||
|
||||
@@ -473,7 +517,7 @@ re = fimg_test_pattern(&fimg, 9, 1.0);
|
||||
if (re) {
|
||||
fprintf(stderr, "fimg_test_pattern -> %d\n", re);
|
||||
}
|
||||
fimg_save_as_pnm(&fimg, "mire.pnm", 0);
|
||||
fimg_export_picture(&fimg, "mire.pnm", 0);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -519,7 +563,6 @@ return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
||||
int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */
|
||||
int fimg_essai_hsv(char *fname); /* hsv.c */
|
||||
|
||||
@@ -551,7 +594,8 @@ return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
|
||||
Histo, Hsv, Classif, Ctr2x2, Qsortrgb };
|
||||
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
|
||||
Displace };
|
||||
typedef struct {
|
||||
char *name;
|
||||
int Cmd;
|
||||
@@ -571,6 +615,7 @@ Command commands[] = {
|
||||
{ "classif", Classif },
|
||||
{ "ctr2x2", Ctr2x2 },
|
||||
{ "qsortrgb", Qsortrgb },
|
||||
{ "displace", Displace },
|
||||
{ NULL, 0 }
|
||||
} ;
|
||||
|
||||
@@ -592,7 +637,10 @@ void help(int k)
|
||||
{
|
||||
Command *pcmd;
|
||||
|
||||
fprintf(stderr, "usage:\n\t./t command filename\n");
|
||||
fprintf(stderr, "usage:\n\t./t [options] command filename\n");
|
||||
|
||||
fprintf(stderr, "options:\n");
|
||||
fprintf(stderr, "\t-o outfile\n");
|
||||
|
||||
fprintf(stderr, "commands:\n");
|
||||
pcmd = commands;
|
||||
@@ -608,16 +656,20 @@ exit(0);
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
char *filename, *command;
|
||||
char *filename, *command, *outfile;
|
||||
|
||||
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";
|
||||
command = "none";
|
||||
|
||||
while ((opt = getopt(argc, argv, "hk:v")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) {
|
||||
switch(opt) {
|
||||
case 'h': help(0); break;
|
||||
case 'k': global_fvalue = atof(optarg); break;
|
||||
case 'o': outfile = optarg; break;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
}
|
||||
@@ -670,13 +722,16 @@ switch(opt) {
|
||||
foo = fimg_essai_hsv(filename);
|
||||
break;
|
||||
case Classif:
|
||||
foo = essai_classif(filename);
|
||||
foo = essai_classif(filename, outfile);
|
||||
break;
|
||||
case Ctr2x2:
|
||||
foo = essai_contour_2x2(filename);
|
||||
foo = essai_contour_2x2(filename, outfile);
|
||||
break;
|
||||
case Qsortrgb:
|
||||
foo = essai_qsort_rgb(filename);
|
||||
foo = essai_qsort_rgb(filename, outfile);
|
||||
break;
|
||||
case Displace:
|
||||
foo = essai_displacement(filename, outfile);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s : bad command\n", command);
|
||||
@@ -688,7 +743,7 @@ if (foo) {
|
||||
fprintf(stderr, "Essai ====> %d\n", foo);
|
||||
}
|
||||
|
||||
fprintf(stderr, "++++++++++++++ end of pid %d\n", getpid());
|
||||
fprintf(stderr, "+++++ end of %s pid %d\n", command, getpid());
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
@@ -7,6 +7,16 @@
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -3,10 +3,17 @@
|
||||
src=/dev/shm/foo.fimg
|
||||
out=out.fimg
|
||||
|
||||
<<<<<<< HEAD
|
||||
maxi=99
|
||||
W="640"
|
||||
H="480"
|
||||
grabopt=" -s 640x480 -v -p 0 -n 150 -c cos01 -d /dev/video2 "
|
||||
=======
|
||||
maxi=249
|
||||
W="320"
|
||||
H="240"
|
||||
grabopt=" -s ${W}x${H}w -vv -p 0 -n 60 -c none "
|
||||
>>>>>>> 423ab7f0eca3e74777b24f795fadf075c0066138
|
||||
|
||||
mkdir /tmp/V
|
||||
|
||||
@@ -20,13 +27,15 @@ do
|
||||
grabvidseq -$grabopt -o $src
|
||||
|
||||
fval=$(echo "$foo / $maxi" | bc -l)
|
||||
./t -k $fval qsortrgb $src
|
||||
echo $foo ' = ' $fval
|
||||
./t -vv -k 0.333 -o $out classif $src
|
||||
|
||||
# fimgstats $out
|
||||
|
||||
echo $foo ' => ' $fval
|
||||
dst=$(printf "/tmp/V/%03d.png" $foo)
|
||||
|
||||
montage $src $out -geometry $G $dst
|
||||
echo $dst
|
||||
montage $src $out -tile 1x2 -geometry $G $dst
|
||||
|
||||
done
|
||||
|
||||
convert -delay 20 /tmp/V/*.png foo.gif
|
||||
convert -delay 10 /tmp/V/*.png foo.gif
|
||||
|
||||
Reference in New Issue
Block a user