two new operators (mini & maxi)
This commit is contained in:
parent
ca4bfcff05
commit
b62b5a4805
@ -10,4 +10,10 @@
|
||||
[794365.892937] usb 4-5: SerialNumber: 00000
|
||||
|
||||
|
||||
Comment imprimer ce code trop gruik ?
|
||||
|
||||
enscript -o - -Ec -f Courier9 -F Times-Roman14 --word-wrap \
|
||||
-i 6 --swap-even-page-margins v4l2_pr_structs.c |
|
||||
ps2pdf - /media/tth/BLIRBOU/v4l2_pr_structs.pdf
|
||||
|
||||
|
||||
|
@ -388,7 +388,9 @@ le calcul de la variance\index{variance}.
|
||||
|
||||
\subsection{fimgops}\index{fimgops}\label{fimgops}
|
||||
|
||||
Operations diverses sur ou entre des images.
|
||||
Operations diverses entre deeux images, qui doivent être
|
||||
de la même taille, et du même type \textsl{pour le moment,
|
||||
uniquement RGB}.
|
||||
|
||||
\begin{verbatim}
|
||||
usage:
|
||||
@ -398,14 +400,16 @@ operators:
|
||||
sub 2
|
||||
mix 3
|
||||
mul 4
|
||||
mini 5
|
||||
maxi 6
|
||||
options:
|
||||
-g convert output to gray
|
||||
-k N.N set float value
|
||||
-v increase verbosity
|
||||
\end{verbatim}
|
||||
|
||||
Pour des operateurs paramétrable (comme \texttt{mix}), le paramêtre flottant doit
|
||||
être fourni en utilisant l'option \texttt{-k}.
|
||||
Pour des operateurs paramétrable (comme \texttt{mix}), le paramêtre
|
||||
flottant doit être fourni en utilisant l'option \texttt{-k}.
|
||||
La véracité mathématique n'est pas garantie.
|
||||
|
||||
\subsection{fimg2png, fimg2pnm, fimg2tiff}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* floatimg.h
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION 76
|
||||
#define FIMG_VERSION 77
|
||||
|
||||
/*
|
||||
* in memory descriptor
|
||||
@ -68,6 +68,8 @@ int fimg_interpolate(FloatImg *s1, FloatImg *s2, FloatImg *d, float coef);
|
||||
int fimg_add(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||
int fimg_sub(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||
int fimg_mul(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d);
|
||||
|
||||
/* PNM files module */
|
||||
int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
|
||||
|
@ -66,7 +66,6 @@ for (idx=0; idx<nbiter; idx++) {
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/*
|
||||
* A * B -> D
|
||||
*/
|
||||
@ -94,3 +93,53 @@ for (idx=0; idx<nbiter; idx++) {
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d)
|
||||
{
|
||||
int idx, nbiter;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, a, b, d);
|
||||
#endif
|
||||
|
||||
if (3 != a->type || 3 != b->type || 3 != d->type) {
|
||||
fprintf(stderr, "%s : got a bad type fimg\n", __func__);
|
||||
return -8;
|
||||
}
|
||||
|
||||
nbiter = a->width * a->height * 3;
|
||||
|
||||
for (idx=0; idx<nbiter; idx++) {
|
||||
if (a->R[idx] > b->R[idx])
|
||||
d->R[idx] = a->R[idx];
|
||||
else
|
||||
d->R[idx] = b->R[idx];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d)
|
||||
{
|
||||
int idx, nbiter;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, a, b, d);
|
||||
#endif
|
||||
|
||||
if (3 != a->type || 3 != b->type || 3 != d->type) {
|
||||
fprintf(stderr, "%s : got a bad type fimg\n", __func__);
|
||||
return -8;
|
||||
}
|
||||
|
||||
nbiter = a->width * a->height * 3;
|
||||
|
||||
for (idx=0; idx<nbiter; idx++) {
|
||||
if (a->R[idx] < b->R[idx])
|
||||
d->R[idx] = a->R[idx];
|
||||
else
|
||||
d->R[idx] = b->R[idx];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
10
lib/runme.sh
10
lib/runme.sh
@ -1,13 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
../v4l2/grabvidseq -s 960x720 -n 10000 -p 0.193 \
|
||||
-vv -g -c none \
|
||||
../v4l2/grabvidseq -s 960x720 -n 100 -p 0.193 \
|
||||
-vv -c none \
|
||||
-o original.fimg
|
||||
|
||||
make t && ./t
|
||||
|
||||
for picz in original power2 squareroot cos_01
|
||||
../tools/fimgops original.fimg cos_01.fimg mini minimum.fimg
|
||||
../tools/fimgops original.fimg cos_01.fimg maxi maximum.fimg
|
||||
|
||||
|
||||
for picz in original power2 squareroot cos_01 minimum maximum
|
||||
do
|
||||
|
||||
echo _______________________ ${picz}
|
||||
|
@ -16,6 +16,8 @@ float global_fvalue;
|
||||
#define OP_SUB 2
|
||||
#define OP_MIX 3
|
||||
#define OP_MUL 4
|
||||
#define OP_MINI 5
|
||||
#define OP_MAXI 6
|
||||
typedef struct {
|
||||
int code;
|
||||
char *op;
|
||||
@ -26,6 +28,8 @@ Opcode opcodes[] = {
|
||||
{ OP_SUB, "sub" },
|
||||
{ OP_MIX, "mix" },
|
||||
{ OP_MUL, "mul" },
|
||||
{ OP_MINI, "mini" },
|
||||
{ OP_MAXI, "maxi" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
static void pr_opcodes(void)
|
||||
@ -57,11 +61,11 @@ static void help(int lj)
|
||||
{
|
||||
|
||||
puts("usage:\n\tfimgops [options] A.fimg B.fimg operator D.fimg");
|
||||
pr_opcodes();
|
||||
puts("options:");
|
||||
puts("\t-g convert output to gray");
|
||||
puts("\t-k N.N set float value");
|
||||
puts("\t-v increase verbosity");
|
||||
pr_opcodes();
|
||||
if (verbosity) fimg_print_version(1);
|
||||
exit(0);
|
||||
}
|
||||
@ -83,6 +87,10 @@ switch (action) {
|
||||
break;
|
||||
case OP_MUL:
|
||||
foo = fimg_add(A, B, D); break;
|
||||
case OP_MINI:
|
||||
foo = fimg_maximum(A, B, D); break;
|
||||
case OP_MAXI:
|
||||
foo = fimg_minimum(A, B, D); break;
|
||||
default:
|
||||
foo = -99; break;
|
||||
|
||||
@ -125,7 +133,7 @@ if (action < 0) {
|
||||
}
|
||||
|
||||
/*
|
||||
* load the two source files, and check comatibility
|
||||
* load the two source files, and check compatibility
|
||||
*/
|
||||
if ((foo=fimg_create_from_dump(argv[optind], &srcA))) {
|
||||
fprintf(stderr, "read error on '%s' is %d\n", argv[optind], foo);
|
||||
|
Loading…
Reference in New Issue
Block a user