commit du soir, espoir
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#---------------------------------------------------------------
|
||||
|
||||
COPT = -Wall -fpic -g -pg -no-pie -DDEBUG_LEVEL=0
|
||||
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
|
||||
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
|
||||
fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o \
|
||||
equalize.o
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
||||
@@ -36,6 +37,9 @@ geometry.o: geometry.c $(DEPS)
|
||||
rotate.o: rotate.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
equalize.o: equalize.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
sfx0.o: sfx0.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
|
||||
39
funcs/equalize.c
Normal file
39
funcs/equalize.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* FLOATIMG
|
||||
* egalisation dinamique approximative
|
||||
* #coronamaison Thu 09 Apr 2020 03:37:10 PM CEST
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_equalize_compute(FloatImg *src, void *vptr)
|
||||
{
|
||||
float minmax[6];
|
||||
int foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p )\n", __func__, src);
|
||||
#endif
|
||||
|
||||
foo = fimg_get_minmax_rgb(src, minmax);
|
||||
printf("Rmin %12.4g Rmax %12.4g\n", minmax[0], minmax[1]);
|
||||
printf("Gmin %12.4g Gmax %12.4g\n", minmax[2], minmax[3]);
|
||||
printf("Bmin %12.4g Bmax %12.4g\n", minmax[4], minmax[5]);
|
||||
|
||||
if ( (minmax[0]<0.0) || (minmax[2]<0.0) || (minmax[4]<0.0) ) {
|
||||
fprintf(stderr, "%s: negative value ?\n", __func__);
|
||||
return -4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
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