Bibliothèque de traitements d'images en virgule flottante. http://la.buvette.org/photos/cumul/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
3.9 KiB

/*
* tests des fonctions diverses - main file
see also: tests.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pam.h>
#undef DEBUG_LEVEL
#define DEBUG_LEVEL 1
#include "../floatimg.h"
#include "tests.h"
3 years ago
int verbosity;
float global_fvalue;
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Histo, Hsv, Classif, Ctr2x2, Qsortrgb,
Displace, ReadPNG };
typedef struct {
char *name;
int Cmd;
} Command;
Command commands[] = {
{ "equalize", Equalize },
{ "rotate", Rotate },
{ "sfx0", Sfx0 },
{ "f3x3", F3x3 },
2 years ago
{ "mire", MIRE },
{ "wfits", Wfits },
{ "wpng", Wpng },
{ "wtiff", Wtiff },
{ "histo", Histo },
{ "hsv", Hsv },
{ "classif", Classif },
{ "ctr2x2", Ctr2x2 },
{ "qsortrgb", Qsortrgb },
{ "displace", Displace },
{ "readpng", ReadPNG },
{ 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;
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;
while (pcmd->name) {
fprintf(stderr, "\t%-15s %d\n", pcmd->name, pcmd->Cmd);
pcmd++;
}
fprintf(stderr, "\ncompiled on "__DATE__" at "__TIME__"\n");
exit(0);
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo, opt;
char *filename, *command, *outfile;
fprintf(stderr, "++++++++ test des fonctions pid=%d\n", getpid());
fprintf(stderr, "++++++++ compiled "__DATE__" at " __TIME__ "\n");
global_fvalue = 1.0;
outfile = "out.pnm";
command = "none";
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;
}
}
// fprintf(stderr, "argc %d optind %d\n", argc, optind);
filename = NULL;
if (2 != argc-optind) {
fprintf(stderr, "%s: bad command line\n", argv[0]);
help(1);
}
command = argv[optind];
filename = argv[optind+1];
if (verbosity) {
2 years ago
fprintf(stderr, "%s : running command '%s' on '%s'\n",
argv[0], command, filename);
fprintf(stderr, "global fvalue : %f\n", global_fvalue);
}
opt = lookup_cmd(command);
// fprintf(stderr, "lookup '%s' --> %d\n", command, opt);
switch(opt) {
case Equalize:
foo = essai_equalize(filename); break;
case Sfx0:
foo = essai_sfx0(filename); break;
case F3x3:
foo = essai_filtrage_3x3(filename); break;
2 years ago
case MIRE:
foo = essai_mire(filename, 0);
break;
case Wfits:
foo = essai_ecriture_fits(filename);
break;
case Wpng:
foo = essai_ecriture_png(filename);
break;
case Wtiff:
foo = essai_ecriture_tiff(filename);
break;
case Histo:
2 years ago
foo = essai_histogramme(filename, 98765);
break;
case Hsv:
foo = fimg_essai_hsv(filename);
break;
case Classif:
foo = essai_classif(filename, outfile, global_fvalue);
break;
case Ctr2x2:
foo = essai_contour_2x2(filename, outfile);
break;
case Qsortrgb:
foo = essai_qsort_rgb(filename, outfile);
break;
case Displace:
foo = essai_displacement(filename, outfile);
break;
case ReadPNG:
foo = essai_lecture_png(filename, outfile, 0);
break;
default:
fprintf(stderr, "%s : bad command\n", command);
exit(1);
3 years ago
}
if (foo) {
fprintf(stderr, "Essai ====> %d\n", foo);
}
fprintf(stderr, "+++++ end of %s pid %d\n", command, getpid());
return 0;
}
/* --------------------------------------------------------------------- */