commit du soir, espoir
This commit is contained in:
parent
22e16d2ba6
commit
83af701479
@ -956,7 +956,7 @@ encore un peu rudimentaire
|
||||
vers le programme de capture d'image décrit page \pageref{grabvidseq}.
|
||||
Il utilise deux fichiers dans le répertoire de travail~:
|
||||
\textit{reglages} et \textit{compteur}. Le premier est, en fait,
|
||||
un bout de shell affectant quelques variables, ou plutôt, les surchargent.
|
||||
un bout de shell affectant quelques variables, ou plutôt, les surchargant.
|
||||
|
||||
\begin{lstlisting}
|
||||
OPTIONS="${OPTIONS} -v -c pow2 "
|
||||
|
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* floatimg.h
|
||||
* floatimg.h
|
||||
* ugly code from tTh
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION 98
|
||||
#define FIMG_VERSION 100
|
||||
|
||||
/*
|
||||
* in memory descriptor
|
||||
@ -115,6 +116,10 @@ int fimg_power_2(FloatImg *s, FloatImg *d, double maxval);
|
||||
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval);
|
||||
int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
|
||||
|
||||
/* module funcs/geometry.c */
|
||||
int fimg_equalize_compute(FloatImg *src, void *vptr);
|
||||
|
||||
|
||||
int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k);
|
||||
int fimg_desaturate(FloatImg *src, FloatImg *dst, int k);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ if (NULL==fptr) {
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, " got %d bytes at %p\n", size, fptr);
|
||||
fprintf(stderr, " %s: got %d bytes at %p\n", __func__, size, fptr);
|
||||
#endif
|
||||
|
||||
fimg->width = w; fimg->height = h;
|
||||
|
@ -19,7 +19,7 @@ extern int verbosity; /* must be declared around main() */
|
||||
float fimg_get_maxvalue(FloatImg *head)
|
||||
{
|
||||
float maxval;
|
||||
int foo;
|
||||
int foo, surface;
|
||||
|
||||
if (head->type != FIMG_TYPE_RGB && head->type != FIMG_TYPE_GRAY) {
|
||||
fprintf(stderr, "%s : type %d invalide\n",
|
||||
@ -29,15 +29,17 @@ if (head->type != FIMG_TYPE_RGB && head->type != FIMG_TYPE_GRAY) {
|
||||
|
||||
maxval = 0.0; /* no negative values allowed */
|
||||
|
||||
surface = head->width*head->height;
|
||||
|
||||
switch (head->type) {
|
||||
case FIMG_TYPE_RGB:
|
||||
for (foo=0; foo<(head->width*head->height); foo++) {
|
||||
for (foo=0; foo<surface; foo++) {
|
||||
if (head->R[foo] > maxval) maxval = head->R[foo];
|
||||
if (head->G[foo] > maxval) maxval = head->G[foo];
|
||||
if (head->B[foo] > maxval) maxval = head->B[foo];
|
||||
}
|
||||
case FIMG_TYPE_GRAY:
|
||||
for (foo=0; foo<(head->width*head->height); foo++) {
|
||||
for (foo=0; foo<surface; foo++) {
|
||||
if (head->R[foo] > maxval) maxval = head->R[foo];
|
||||
}
|
||||
}
|
||||
@ -209,6 +211,19 @@ for (idx=0; idx<nbre; idx++) {
|
||||
}
|
||||
}
|
||||
|
||||
/* WTF 12 avril 2020, valgrind me cause mal ?
|
||||
==28943== Conditional jump or move depends on uninitialised value(s)
|
||||
==28943== at 0x4045E9: fimg_clamp_negativ (fimg-math.c:208)
|
||||
==28943== by 0x4018C9: essai_filtrage_3x3 (t.c:128)
|
||||
==28943== by 0x4024D5: main (t.c:444)
|
||||
==28943== Uninitialised value was created by a heap allocation
|
||||
==28943== at 0x483577F: malloc (vg_replace_malloc.c:299)
|
||||
==28943== by 0x40284D: fimg_create (fimg-core.c:107)
|
||||
==28943== by 0x402AB3: fimg_clone (fimg-core.c:174)
|
||||
==28943== by 0x401861: essai_filtrage_3x3 (t.c:118)
|
||||
==28943== by 0x4024D5: main (t.c:444)
|
||||
*/
|
||||
|
||||
return count;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
@ -48,7 +48,7 @@ else
|
||||
fi
|
||||
|
||||
# ------------------------------------
|
||||
# take and display the fancy picture
|
||||
# grab and display the fancy picture
|
||||
$GVS -d $DEV -n $NBRE -p $PERIOD $OPTIONS -s $SZ -o $outfile
|
||||
|
||||
if [ ${SHOW} == "yes" ]
|
||||
|
Loading…
Reference in New Issue
Block a user