FloatImg/funcs/t.c

780 lines
17 KiB
C
Raw Normal View History

2019-09-12 19:48:12 +02:00
/*
2020-11-09 14:27:28 +01:00
* tests des fonctions diverses
2019-09-12 19:48:12 +02:00
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pam.h>
2020-11-09 14:27:28 +01:00
#undef DEBUG_LEVEL
#define DEBUG_LEVEL 1
2020-07-24 10:38:13 +02:00
2019-09-12 19:48:12 +02:00
#include "../floatimg.h"
2020-01-22 22:14:06 +01:00
int verbosity;
2020-02-16 16:21:27 +01:00
float global_fvalue;
2020-10-26 16:45:36 +01:00
/* --------------------------------------------------------------------- */
/* 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;
}
2020-10-08 11:24:29 +02:00
/* --------------------------------------------------------------------- */
/*
* nouveau 7 octobre 2020 pendant sonoptic
2020-11-09 14:27:28 +01:00
*
* inspiration: Olivier Baudu
2020-10-08 11:24:29 +02:00
*/
int essai_qsort_rgb(char *infile, char *outfile)
2020-10-08 11:24:29 +02:00
{
FloatImg src, dst;
int foo;
if (NULL != infile) {
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;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
fimg_clone(&src, &dst, 1);
2020-10-09 01:26:07 +02:00
foo = fimg_qsort_rgb_b(&src, &dst, 0);
2020-10-08 11:24:29 +02:00
if (foo) {
fprintf(stderr, "%s: err %d in qsort_rgb\n", __func__, foo);
return foo;
}
foo = fimg_export_picture(&dst, outfile, 0);
2020-10-08 11:24:29 +02:00
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
2020-10-30 10:03:35 +01:00
fimg_destroy(&src); fimg_destroy(&dst);
2020-10-08 11:24:29 +02:00
return 0;
}
2020-10-07 11:32:23 +02:00
/* --------------------------------------------------------------------- */
/*
* nouveau 5 octobre 2020 pendant sonoptic
*/
2020-10-16 11:20:10 +02:00
int essai_contour_2x2(char *infile, char *outfile)
2020-10-07 11:32:23 +02:00
{
FloatImg src, dst;
int foo;
if (NULL != infile) {
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;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
fimg_clone(&src, &dst, 1);
2020-10-16 11:20:10 +02:00
foo = fimg_contour_2x2(&src, &dst, 0);
2020-10-07 11:32:23 +02:00
if (foo) {
fprintf(stderr, "%s: err %d in contour_2x2\n", __func__, foo);
return foo;
}
foo = fimg_export_picture(&dst, outfile, 0);
2020-10-07 11:32:23 +02:00
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
2020-10-30 10:03:35 +01:00
fimg_destroy(&src); fimg_destroy(&dst);
2020-10-07 11:32:23 +02:00
return 0;
}
2020-10-04 13:05:28 +02:00
/* --------------------------------------------------------------------- */
2020-10-06 16:30:42 +02:00
/*
* nouveau 5 octobre 2020 pendant sonoptic
*/
int essai_classif(char *infile, char *outfile)
2020-10-04 13:05:28 +02:00
{
FloatImg src, dst;
int foo;
if (NULL != infile) {
2020-10-06 16:30:42 +02:00
fprintf(stderr, "%s : loading %s\n", __func__, infile);
2020-10-04 13:05:28 +02:00
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: error loading '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
fimg_clone(&src, &dst, 1);
2020-10-06 16:30:42 +02:00
fprintf(stderr, "%s : fvalue is %f\n", __func__, global_fvalue);
2020-10-06 12:48:17 +02:00
foo = fimg_classif_trial(&src, &dst, global_fvalue, 0);
2020-10-04 13:05:28 +02:00
if (foo) {
fprintf(stderr, "%s: err %d in classif_trial\n", __func__, foo);
return foo;
}
foo = fimg_export_picture(&dst, outfile, 0);
2020-10-04 13:05:28 +02:00
if (foo) {
fprintf(stderr, "%s : err %d saving result\n", __func__, foo);
return foo;
}
2020-10-30 10:03:35 +01:00
fimg_destroy(&src); fimg_destroy(&dst);
2020-10-06 12:48:17 +02:00
return 0;
2020-10-04 13:05:28 +02:00
}
2020-08-22 02:16:13 +02:00
/* --------------------------------------------------------------------- */
/* nouveau 19 aout 2020, le matin avant la canicule */
int essai_ecriture_tiff(char *outname)
{
int foo;
FloatImg picz;
fimg_create(&picz, 800, 600, FIMG_TYPE_RGB);
fimg_test_pattern(&picz, 0, 22222);
foo = fimg_write_as_tiff(&picz, outname, 0);
if (foo) {
fprintf(stderr, "%s got a %d\n", __func__, foo);
return foo;
}
return -7;
}
2020-07-24 10:38:13 +02:00
/* --------------------------------------------------------------------- */
/* essai de fichiers FITS (astronomie) */
int essai_ecriture_fits(char *outname)
{
FloatImg src;
int foo;
fprintf(stderr, "%s is creating the picz\n", __func__);
fimg_create(&src, 512, 512, FIMG_TYPE_RGB);
fimg_test_pattern(&src, 0, 255.0);
foo = fimg_save_R_as_fits(&src, outname, 0);
fprintf(stderr, "saving '%s' to fits --> %d\n", outname, foo);
return -1;
}
2020-04-11 23:18:33 +02:00
/* --------------------------------------------------------------------- */
/*
* egalisation dynamique approximative
* #coronamaison Thu 09 Apr 2020 03:37:10 PM CEST
*/
int essai_equalize(char *infile)
{
FloatImg src;
int foo;
if (NULL != infile) {
fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
2020-08-13 07:25:55 +02:00
foo = fimg_equalize_compute(&src, NULL, 666.666);
2020-04-11 23:18:33 +02:00
fprintf(stderr, "equalize compute --> %d\n", foo);
fimg_destroy(&src);
return -1;
}
/* --------------------------------------------------------------------- */
int essai_rotate(char *infile)
{
FloatImg src, dst;
int foo;
if (NULL != infile) {
fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s : NOT INPUT FILE, FUBAR\n", __func__);
abort();
}
fimg_save_as_png(&src, "test.png", 0);
foo = fimg_rotate_90(&src, &dst, 0);
fprintf(stderr, "rotate 90 -> %d\n", foo);
2020-10-16 11:20:10 +02:00
foo = fimg_export_picture(&dst, "rotated90.png", 0);
foo = fimg_export_picture(&dst, "rotated90.pnm", 0);
fimg_destroy(&src);
return -1;
}
/* --------------------------------------------------------------------- */
2020-02-29 21:59:12 +01:00
int essai_filtrage_3x3(char *infile)
{
FloatImg src, dst;
int foo; /// , idx;
// char buffer[100];
2020-02-29 21:59:12 +01:00
FimgFilter3x3 filter_a = {
{ 1.0, 1.0, 1.0,
1.0, -3.0, 1.0,
1.0, 1.0, 1.0 },
8.0, 0.0
};
FimgFilter3x3 filter_b = {
{ -2.0, -1.0, 0.0,
-1.0, 3.0, 1.0,
0.0, 1.0, 2.0 },
8.0, 0.0
};
if (NULL != infile) {
fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s is creating the picz\n", __func__);
fimg_create(&src, 640, 480, FIMG_TYPE_RGB);
fimg_test_pattern(&src, 0, 255.0);
}
2020-04-11 23:18:33 +02:00
// fimg_save_as_png(&src, "test.png", 0);
2020-03-17 09:29:20 +01:00
2020-02-29 21:59:12 +01:00
foo = fimg_clone(&src, &dst, 0);
if (foo) {
fprintf(stderr, "%s: err clone %p\n", __func__, &src);
return -44;
}
2020-04-11 23:18:33 +02:00
2020-03-02 01:19:57 +01:00
fimg_filter_3x3(&src, &dst, &filter_a);
2020-04-11 23:18:33 +02:00
2020-03-02 01:19:57 +01:00
foo = fimg_clamp_negativ(&dst);
2020-04-11 23:18:33 +02:00
2020-03-02 01:19:57 +01:00
if (foo) {
fprintf(stderr, "clamped %d negative pixels\n", foo);
}
2020-04-11 23:18:33 +02:00
// foo = fimg_save_as_png(&dst, "f3x3a.png", 0);
2020-03-02 01:19:57 +01:00
// foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
2020-02-29 21:59:12 +01:00
fimg_filter_3x3(&src, &dst, &filter_b);
foo = fimg_clamp_negativ(&dst);
if (foo) {
2020-03-02 01:19:57 +01:00
fprintf(stderr, "clamped %d negative pixels\n", foo);
2020-02-29 21:59:12 +01:00
}
2020-04-11 23:18:33 +02:00
// foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
2020-03-02 01:19:57 +01:00
// foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
2020-02-29 21:59:12 +01:00
fimg_destroy(&src); fimg_destroy(&dst);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_filtrage_2x2(char *infile)
{
FloatImg fimg;
int foo, idx;
char buffer[100];
if (NULL != infile) {
2020-02-29 21:59:12 +01:00
fprintf(stderr, "%s: loading %s\n", __func__, infile);
foo = fimg_create_from_dump(infile, &fimg);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
}
else {
fprintf(stderr, "%s is creating the picz\n", __func__);
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
fimg_draw_something(&fimg);
}
foo = fimg_save_as_pnm(&fimg, "source.pnm", 0);
2020-02-27 13:16:00 +01:00
/*
* running multiple filters so you can
* watch the up-left shift :)
*/
2020-02-29 21:59:12 +01:00
for (idx=0; idx<5; idx++) {
foo = fimg_lissage_2x2(&fimg);
2020-02-27 13:16:00 +01:00
sprintf(buffer, "filter%03d.png", idx);
foo = fimg_save_as_png(&fimg, buffer, 0);
2020-02-29 21:59:12 +01:00
if (verbosity) {
fprintf(stderr, "%s %d\n", buffer, foo);
}
}
fimg_destroy(&fimg);
return 0;
}
2020-02-13 20:44:22 +01:00
/* --------------------------------------------------------------------- */
int essai_geometrie(char *infile)
{
FloatImg fimg, result;
int foo;
if (NULL != infile) {
fprintf(stderr, "loading %s\n", infile);
2020-02-27 13:16:00 +01:00
foo = fimg_create_from_dump(infile, &fimg);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
2020-02-13 20:44:22 +01:00
}
else {
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
fimg_draw_something(&fimg);
}
foo = fimg_save_as_pnm(&fimg, "source.pnm", 0);
memset(&result, 0, sizeof(FloatImg));
foo = fimg_halfsize_0(&fimg, &result, 0);
fprintf(stderr, "retour halfsize -> %d\n", foo);
if (foo) {
return -2;
}
2020-02-16 16:21:27 +01:00
if (verbosity) fimg_describe(&result, "result after halfsize");
2020-02-13 20:44:22 +01:00
foo = fimg_save_as_pnm(&result, "something.pnm", 0);
2020-02-07 18:01:28 +01:00
2020-02-13 20:44:22 +01:00
return 0;
}
2020-02-07 18:01:28 +01:00
/* --------------------------------------------------------------------- */
int essai_sfx0(char *infile)
{
FloatImg fimg;
int foo;
2020-02-07 20:09:03 +01:00
if (NULL != infile) {
fprintf(stderr, "loading %s\n", infile);
2020-02-27 13:16:00 +01:00
foo = fimg_create_from_dump(infile, &fimg);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, infile);
return foo;
}
2020-02-07 20:09:03 +01:00
}
else {
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
fimg_draw_something(&fimg);
}
2020-02-07 18:01:28 +01:00
foo = fimg_save_as_pnm(&fimg, "something.pnm", 0);
2020-02-16 16:21:27 +01:00
if (foo) {
fprintf(stderr, "%s: err save %d\n", __func__, foo);
return -6;
}
2020-02-07 18:01:28 +01:00
foo = fimg_killcolors_a(&fimg, 0.0);
2020-02-07 20:09:03 +01:00
foo = fimg_save_as_pnm(&fimg, "colorskilled-a.pnm", 0);
2020-02-16 16:21:27 +01:00
if (foo) {
fprintf(stderr, "%s: err save %d\n", __func__, foo);
return -6;
}
2020-02-07 20:09:03 +01:00
foo = fimg_killcolors_b(&fimg, 0.0);
foo = fimg_save_as_pnm(&fimg, "colorskilled-b.pnm", 0);
2020-02-16 16:21:27 +01:00
if (foo) {
fprintf(stderr, "%s: err save %d\n", __func__, foo);
return -6;
}
2020-02-07 18:01:28 +01:00
return 0;
}
2019-09-12 19:48:12 +02:00
/* --------------------------------------------------------------------- */
2019-10-30 15:49:53 +01:00
int essai_parse_double(void)
2019-09-12 19:48:12 +02:00
{
int foo;
2019-09-16 12:28:47 +02:00
double dval;
char *str;
str = "12.34"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
2019-09-12 19:48:12 +02:00
2019-09-16 12:28:47 +02:00
str = "12e4"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
2019-09-12 19:48:12 +02:00
2019-09-16 12:28:47 +02:00
str = "5s"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
2019-09-13 14:34:56 +02:00
2019-09-16 12:28:47 +02:00
str = "PORN"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
2019-09-12 19:48:12 +02:00
return 0;
}
/* --------------------------------------------------------------------- */
2019-10-30 15:49:53 +01:00
int essai_detect_type(void)
{
int foo;
char *fname;
foo = format_from_extension(fname="foo.fimg");
printf("%-10s %d\n\n", fname, foo);
2020-02-07 18:01:28 +01:00
foo = format_from_extension(fname="foo.pnm");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.png");
2019-10-30 15:49:53 +01:00
printf("%-10s %d\n\n", fname, foo);
2020-10-12 15:55:06 +02:00
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);
2019-10-30 15:49:53 +01:00
foo = format_from_extension(fname="foo.xyzzy");
printf("%-10s %d\n\n", fname, foo);
2020-01-03 15:39:11 +01:00
return 0;
}
/* --------------------------------------------------------------------- */
2020-07-02 16:55:45 +02:00
int essai_mire(char *outname, int notused)
{
FloatImg fimg;
int re;
fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB);
re = fimg_test_pattern(&fimg, 9, 1.0);
2020-07-24 10:38:13 +02:00
if (re) {
fprintf(stderr, "fimg_test_pattern -> %d\n", re);
}
2020-10-16 11:20:10 +02:00
fimg_export_picture(&fimg, "mire.pnm", 0);
2020-07-02 16:55:45 +02:00
return -1;
}
/* --------------------------------------------------------------------- */
2020-01-03 15:39:11 +01:00
int essai_rampes(void)
{
FloatImg fimg;
int foo;
fimg_create(&fimg, 640, 480, FIMG_TYPE_RGB);
foo = fimg_hdeg_a(&fimg, (double)3.141592654);
fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "hdeg.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
foo = fimg_vdeg_a(&fimg, (double)3.141592654);
fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "vdeg.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
2020-11-09 14:27:28 +01:00
return 0;
}
/* --------------------------------------------------------------------- */
int essai_lecture_png(char *fname, char *outfile, int notused)
{
FloatImg fimg;
int foo;
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
memset(&fimg, 0, sizeof(FloatImg));
foo = fimg_create_from_png(fname, &fimg);
if (foo) {
fprintf(stderr, "%s: createfrom -> %d\n", __func__, foo);
return foo;
}
fimg_describe(&fimg, "created from png");
foo = fimg_export_picture(&fimg, outfile, 0);
if (foo) {
fprintf(stderr, "%s : err %d saving result to %s\n", __func__,
foo, outfile);
return foo;
}
2019-12-13 18:18:07 +01:00
return 0;
}
/* --------------------------------------------------------------------- */
2020-08-22 02:16:13 +02:00
int essai_ecriture_png(char *fname)
2019-12-13 18:18:07 +01:00
{
FloatImg fimg;
int foo;
2020-07-24 10:38:13 +02:00
fimg_create(&fimg, 800, 600, FIMG_TYPE_RGB);
2019-12-31 12:02:37 +01:00
fimg_draw_something(&fimg);
2020-08-22 02:16:13 +02:00
if (verbosity) {
foo = fimg_save_as_pnm(&fimg, "quux.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
}
2019-12-13 18:18:07 +01:00
foo = fimg_save_as_png(&fimg, fname, 0);
2019-12-31 12:02:37 +01:00
fprintf(stderr, "save as png -> %d\n", foo);
2019-12-13 18:18:07 +01:00
2019-10-30 15:49:53 +01:00
return 0;
}
/* --------------------------------------------------------------------- */
2020-09-03 01:37:53 +02:00
2020-09-08 22:55:17 +02:00
int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */
int fimg_essai_hsv(char *fname); /* hsv.c */
2020-09-03 01:37:53 +02:00
int essai_histogramme(char *fname, int k)
{
FloatImg fimg;
int foo;
2020-09-07 13:13:03 +02:00
2020-09-03 01:37:53 +02:00
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, k);
foo = fimg_create_from_dump(fname, &fimg);
if (foo) {
fprintf(stderr, "%s: err load '%s'\n", __func__, fname);
return foo;
}
foo = fimg_essai_histo(&fimg, "out.png", k);
if (foo) {
2020-09-07 13:13:03 +02:00
fprintf(stderr, "essai_histo -> error %d\n", foo);
2020-09-03 01:37:53 +02:00
return foo;
}
2020-09-07 13:13:03 +02:00
fimg_destroy(&fimg);
2020-09-03 01:37:53 +02:00
fprintf(stderr, "\\o/ end of %s\n", __func__);
2020-09-07 13:13:03 +02:00
return 0;
2020-09-03 01:37:53 +02:00
}
/* --------------------------------------------------------------------- */
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
2020-10-26 16:45:36 +01:00
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
2020-11-09 14:27:28 +01:00
Displace, ReadPNG };
2020-04-11 23:18:33 +02:00
typedef struct {
char *name;
int Cmd;
} Command;
Command commands[] = {
{ "equalize", Equalize },
{ "rotate", Rotate },
{ "sfx0", Sfx0 },
{ "f3x3", F3x3 },
2020-07-02 16:55:45 +02:00
{ "mire", MIRE },
2020-07-24 10:38:13 +02:00
{ "wfits", Wfits },
{ "wpng", Wpng },
2020-08-22 02:16:13 +02:00
{ "wtiff", Wtiff },
2020-09-03 01:37:53 +02:00
{ "histo", Histo },
2020-09-08 22:55:17 +02:00
{ "hsv", Hsv },
2020-10-04 13:05:28 +02:00
{ "classif", Classif },
2020-10-07 11:32:23 +02:00
{ "ctr2x2", Ctr2x2 },
2020-10-08 11:24:29 +02:00
{ "qsortrgb", Qsortrgb },
2020-10-26 16:45:36 +01:00
{ "displace", Displace },
2020-11-09 14:27:28 +01:00
{ "readpng", ReadPNG },
2020-04-11 23:18:33 +02:00
{ NULL, 0 }
} ;
/* --------------------------------------------------------------------- */
int lookup_cmd(char *cmdtxt)
{
Command *pcmd;
pcmd = commands;
while (pcmd->name) {
if (!strcmp(pcmd->name, cmdtxt)) return pcmd->Cmd;
pcmd++;
}
return -1;
}
/* --------------------------------------------------------------------- */
void help(int k)
{
Command *pcmd;
2020-10-16 11:20:10 +02:00
fprintf(stderr, "usage:\n\t./t [options] command filename\n");
fprintf(stderr, "options:\n");
fprintf(stderr, "\t-o outfile\n");
2020-04-11 23:18:33 +02:00
fprintf(stderr, "commands:\n");
pcmd = commands;
while (pcmd->name) {
fprintf(stderr, "\t%-15s %d\n", pcmd->name, pcmd->Cmd);
pcmd++;
}
fprintf(stderr, "\ncompiled on "__DATE__" at "__TIME__"\n");
exit(0);
}
/* --------------------------------------------------------------------- */
2019-10-30 15:49:53 +01:00
int main(int argc, char *argv[])
{
2020-02-16 16:21:27 +01:00
int foo, opt;
2020-10-16 11:20:10 +02:00
char *filename, *command, *outfile;
2019-10-30 15:49:53 +01:00
2020-09-03 02:00:32 +02:00
fprintf(stderr, "++++++++ test des fonctions pid=%d\n", getpid());
2020-10-26 16:45:36 +01:00
fprintf(stderr, "++++++++ compiled "__DATE__" at " __TIME__ "\n");
2019-12-13 18:18:07 +01:00
2020-10-16 11:20:10 +02:00
global_fvalue = 1.0;
outfile = "out.pnm";
2020-10-26 16:45:36 +01:00
command = "none";
2020-02-16 16:21:27 +01:00
while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) {
2020-02-16 16:21:27 +01:00
switch(opt) {
2020-04-11 23:18:33 +02:00
case 'h': help(0); break;
2020-02-16 16:21:27 +01:00
case 'k': global_fvalue = atof(optarg); break;
2020-10-16 11:20:10 +02:00
case 'o': outfile = optarg; break;
2020-02-16 16:21:27 +01:00
case 'v': verbosity++; break;
}
}
2020-04-11 23:18:33 +02:00
// fprintf(stderr, "argc %d optind %d\n", argc, optind);
filename = NULL;
2020-04-11 23:18:33 +02:00
if (2 != argc-optind) {
fprintf(stderr, "%s: bad command line\n", argv[0]);
help(1);
}
command = argv[optind];
filename = argv[optind+1];
if (verbosity) {
2020-10-06 16:30:42 +02:00
fprintf(stderr, "%s : running command '%s' on '%s'\n",
argv[0], command, filename);
2020-10-06 12:48:17 +02:00
fprintf(stderr, "global fvalue : %f\n", global_fvalue);
2020-04-11 23:18:33 +02:00
}
opt = lookup_cmd(command);
2020-07-24 10:38:13 +02:00
// fprintf(stderr, "lookup '%s' --> %d\n", command, opt);
2020-04-11 23:18:33 +02:00
switch(opt) {
case Equalize:
foo = essai_equalize(filename); break;
case Sfx0:
foo = essai_sfx0(filename); break;
case F3x3:
foo = essai_filtrage_3x3(filename); break;
2020-07-02 16:55:45 +02:00
case MIRE:
foo = essai_mire(filename, 0);
break;
2020-07-24 10:38:13 +02:00
case Wfits:
foo = essai_ecriture_fits(filename);
break;
case Wpng:
2020-08-22 02:16:13 +02:00
foo = essai_ecriture_png(filename);
break;
case Wtiff:
foo = essai_ecriture_tiff(filename);
2020-07-24 10:38:13 +02:00
break;
2020-09-03 01:37:53 +02:00
case Histo:
2020-09-07 13:13:03 +02:00
foo = essai_histogramme(filename, 98765);
2020-09-03 01:37:53 +02:00
break;
2020-09-08 22:55:17 +02:00
case Hsv:
foo = fimg_essai_hsv(filename);
break;
2020-10-04 13:05:28 +02:00
case Classif:
foo = essai_classif(filename, outfile);
2020-10-04 13:05:28 +02:00
break;
2020-10-07 11:32:23 +02:00
case Ctr2x2:
foo = essai_contour_2x2(filename, outfile);
2020-10-07 11:32:23 +02:00
break;
2020-10-08 11:24:29 +02:00
case Qsortrgb:
foo = essai_qsort_rgb(filename, outfile);
2020-10-08 11:24:29 +02:00
break;
2020-10-26 16:45:36 +01:00
case Displace:
foo = essai_displacement(filename, outfile);
break;
2020-11-09 14:27:28 +01:00
case ReadPNG:
foo = essai_lecture_png(filename, outfile, 0);
break;
2020-04-11 23:18:33 +02:00
default:
fprintf(stderr, "%s : bad command\n", command);
exit(1);
2020-02-29 21:59:12 +01:00
}
2020-02-16 16:21:27 +01:00
if (foo) {
fprintf(stderr, "Essai ====> %d\n", foo);
2020-02-16 16:21:27 +01:00
}
2019-10-30 15:49:53 +01:00
2020-10-12 15:55:06 +02:00
fprintf(stderr, "+++++ end of %s pid %d\n", command, getpid());
2019-10-30 15:49:53 +01:00
return 0;
}
/* --------------------------------------------------------------------- */