commit du soir, espoir
This commit is contained in:
132
funcs/t.c
132
funcs/t.c
@@ -12,6 +12,37 @@ int verbosity;
|
||||
|
||||
float global_fvalue;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
|
||||
foo = fimg_equalize_compute(&src, NULL);
|
||||
fprintf(stderr, "equalize compute --> %d\n", foo);
|
||||
|
||||
|
||||
fimg_destroy(&src);
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int essai_rotate(char *infile)
|
||||
{
|
||||
@@ -82,19 +113,24 @@ else {
|
||||
fimg_test_pattern(&src, 0, 255.0);
|
||||
}
|
||||
|
||||
fimg_save_as_png(&src, "test.png", 0);
|
||||
// fimg_save_as_png(&src, "test.png", 0);
|
||||
|
||||
foo = fimg_clone(&src, &dst, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err clone %p\n", __func__, &src);
|
||||
return -44;
|
||||
}
|
||||
|
||||
|
||||
fimg_filter_3x3(&src, &dst, &filter_a);
|
||||
|
||||
|
||||
foo = fimg_clamp_negativ(&dst);
|
||||
|
||||
if (foo) {
|
||||
fprintf(stderr, "clamped %d negative pixels\n", foo);
|
||||
}
|
||||
foo = fimg_save_as_png(&dst, "f3x3a.png", 0);
|
||||
// foo = fimg_save_as_png(&dst, "f3x3a.png", 0);
|
||||
// foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
|
||||
|
||||
fimg_filter_3x3(&src, &dst, &filter_b);
|
||||
@@ -102,7 +138,7 @@ foo = fimg_clamp_negativ(&dst);
|
||||
if (foo) {
|
||||
fprintf(stderr, "clamped %d negative pixels\n", foo);
|
||||
}
|
||||
foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
|
||||
// foo = fimg_save_as_png(&dst, "f3x3b.png", 0);
|
||||
// foo = fimg_save_as_pnm(&dst, "f3x3a.pnm", 0);
|
||||
|
||||
fimg_destroy(&src); fimg_destroy(&dst);
|
||||
@@ -315,36 +351,102 @@ fprintf(stderr, "save as png -> %d\n", foo);
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
enum nCmd { Equalize=1, Rotate, Sfx0, F3x3 };
|
||||
typedef struct {
|
||||
char *name;
|
||||
int Cmd;
|
||||
} Command;
|
||||
|
||||
Command commands[] = {
|
||||
{ "equalize", Equalize },
|
||||
{ "rotate", Rotate },
|
||||
{ "sfx0", Sfx0 },
|
||||
{ "f3x3", F3x3 },
|
||||
{ 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 command in-filename\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;
|
||||
char *filename, *command;
|
||||
|
||||
puts("++++++++++++++++++++++++++++++++");
|
||||
puts("++++++++ test des fonctions +++++++");
|
||||
|
||||
global_fvalue = 1.0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "hk:v")) != -1) {
|
||||
switch(opt) {
|
||||
// case 'h': help(0); break;
|
||||
case 'h': help(0); break;
|
||||
case 'k': global_fvalue = atof(optarg); break;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "argc %d optind %d\n", argc, optind);
|
||||
// fprintf(stderr, "argc %d optind %d\n", argc, optind);
|
||||
|
||||
filename = NULL;
|
||||
if (1 == argc-optind) filename = argv[optind];
|
||||
|
||||
/*
|
||||
foo = essai_filtrage_2x2(filename);
|
||||
if (foo) {
|
||||
fprintf(stderr, "Filtre 2x2 ====> %d\n", foo);
|
||||
if (2 != argc-optind) {
|
||||
fprintf(stderr, "%s: bad command line\n", argv[0]);
|
||||
help(1);
|
||||
}
|
||||
|
||||
command = argv[optind];
|
||||
filename = argv[optind+1];
|
||||
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "running command '%s' on '%s'\n", command, filename);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s : bad command\n", command);
|
||||
exit(1);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
foo = essai_rotate(filename);
|
||||
if (foo) {
|
||||
fprintf(stderr, "Essai ====> %d\n", foo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user