added a new function : fimg_rotate_90, need more tests
This commit is contained in:
parent
394b24bc92
commit
e9a61bb96a
|
@ -29,6 +29,7 @@
|
|||
\setlength \parskip {0.40em}
|
||||
|
||||
\makeatletter
|
||||
% exlpication de ce truc ?
|
||||
\def\verbatim@font{\normalfont\ttfamily\small}
|
||||
\makeatother
|
||||
|
||||
|
@ -208,8 +209,9 @@ lesquels sont décrits en page \pageref{outils}.
|
|||
|
||||
Vous devez, en dehors des outils classiques (bash, gcc, make\dots),
|
||||
avoir quelques bibliothèques installées\footnote{Les \texttt{-dev}
|
||||
pour Debian et dérivées}~: libv4l2, libpnglite, libtiff, libnetpbm,
|
||||
libz,
|
||||
pour Debian et dérivées}~:
|
||||
\textsf{libv4l2, libpnglite, libtiff, libnetpbm, libz},
|
||||
éventuellement avec le \textsf{-dev} correspondant,
|
||||
et probablement d'autres choses.
|
||||
|
||||
Il est même quasiment certain que Bash soit indispensable, tout
|
||||
|
@ -496,7 +498,6 @@ Et pour attendre, un truc improbable, voire même
|
|||
inutile, en fait l'inverse de l'upscaling.
|
||||
|
||||
\begin{lstlisting}
|
||||
/* module funcs/geometry.c */
|
||||
int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused);
|
||||
\end{lstlisting}
|
||||
|
||||
|
@ -506,7 +507,6 @@ contenir d'image, et doit être effacé avec un bon
|
|||
Et le résultat est très moyen : il n'y a pas d'interpolation.
|
||||
|
||||
\begin{lstlisting}
|
||||
/* module funcs/geometry.c */
|
||||
int fimg_extract_0(FloatImg *src, FloatImg *dst, int x, int y);
|
||||
\end{lstlisting}
|
||||
|
||||
|
@ -514,6 +514,14 @@ Contrairement à la fonction précédente, celle-ci demande absolument une
|
|||
image de destination initialisée aux dimensions (largeur et hauteur)
|
||||
désirées.
|
||||
|
||||
\begin{lstlisting}
|
||||
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
|
||||
\end{lstlisting}
|
||||
|
||||
Rotation de 90 degrés dans le sens horlogique d'une image RGB.
|
||||
L'image de destination peut être soir vierge, soit pré-allouée
|
||||
aux bonnes dimensions (échange W et H).
|
||||
|
||||
% ----------------------------------
|
||||
|
||||
\subsection{Exportation \& Importation}\index{export}\label{export}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* floatimg.h
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION 95
|
||||
#define FIMG_VERSION 96
|
||||
|
||||
/*
|
||||
* in memory descriptor
|
||||
|
@ -96,6 +96,9 @@ int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr);
|
|||
int fimg_killcolors_a(FloatImg *fimg, float fval);
|
||||
int fimg_killcolors_b(FloatImg *fimg, float fval);
|
||||
|
||||
/* funcs/rotate.c module */
|
||||
/* #coronamaison */
|
||||
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused);
|
||||
|
||||
/* PNM files module */
|
||||
int fimg_save_as_pnm(FloatImg *head, char *fname, int flags);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
COPT = -Wall -fpic -g -pg -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
|
||||
fimg-libpnm.o rampes.o sfx0.o geometry.o rotate.o
|
||||
|
||||
#---------------------------------------------------------------
|
||||
|
||||
|
@ -33,6 +33,9 @@ filtrage.o: filtrage.c $(DEPS)
|
|||
geometry.o: geometry.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
rotate.o: rotate.c $(DEPS)
|
||||
gcc $(COPT) -DDEBUG_LEVEL=1 -c $<
|
||||
|
||||
sfx0.o: sfx0.c $(DEPS)
|
||||
gcc $(COPT) -c $<
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* FLOATIMG
|
||||
* rotation matricielle des images
|
||||
* #coronamaison Mon 23 Mar 2020 11:45:59 AM CET
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused)
|
||||
{
|
||||
int foo;
|
||||
int x, y;
|
||||
float rgb[3];
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
||||
src, dst, notused);
|
||||
#endif
|
||||
|
||||
if (src->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s: src type %d not valid\n", __func__,
|
||||
src->type);
|
||||
return -6;
|
||||
}
|
||||
|
||||
/* check if dst pic is not allocated */
|
||||
if ( 0 == (dst->type | dst->width | dst->height) ) {
|
||||
fprintf(stderr, "in %s, %p is empty\n", __func__, dst);
|
||||
/* OK allocate a new fpic */
|
||||
foo = fimg_create(dst, src->height, src->width, src->type);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err %d create new pic\n", __func__, foo);
|
||||
return -887;
|
||||
}
|
||||
if (verbosity) fimg_describe(dst, "new pic");
|
||||
}
|
||||
|
||||
/* check if dst and src are conpatibles */
|
||||
if ( (src->type != dst->type) ||
|
||||
(src->width != dst->height) || (src->height != dst->width) ) {
|
||||
fprintf(stderr, "%s: src & dst not compatibles\n", __func__);
|
||||
return -888;
|
||||
}
|
||||
|
||||
/*
|
||||
* THIS IS A CRUDE IMPLEMENTATION
|
||||
*/
|
||||
for (y=0; y<src->height; y++) {
|
||||
for (x=0; x<src->width; x++) {
|
||||
fimg_get_rgb(src, x, y, rgb);
|
||||
fimg_plot_rgb(dst, y, x, rgb[0], rgb[1], rgb[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* we don't have any cleanup to make */
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
|
|
44
funcs/t.c
44
funcs/t.c
|
@ -12,12 +12,43 @@ int verbosity;
|
|||
|
||||
float global_fvalue;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int essai_rotate(char *infile)
|
||||
{
|
||||
FloatImg src, dst;
|
||||
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();
|
||||
}
|
||||
|
||||
fimg_save_as_png(&src, "test.png", 0);
|
||||
|
||||
foo = fimg_rotate_90(&src, &dst, 0);
|
||||
fprintf(stderr, "rotate 90 -> %d\n", foo);
|
||||
|
||||
foo = fimg_save_as_png(&dst, "rotated90.png", 0);
|
||||
foo = fimg_save_as_pnm(&dst, "rotated90.pnm", 0);
|
||||
|
||||
fimg_destroy(&src);
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int essai_filtrage_3x3(char *infile)
|
||||
{
|
||||
FloatImg src, dst;
|
||||
int foo, idx;
|
||||
char buffer[100];
|
||||
int foo; /// , idx;
|
||||
// char buffer[100];
|
||||
|
||||
FimgFilter3x3 filter_a = {
|
||||
|
||||
|
@ -54,7 +85,10 @@ else {
|
|||
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) {
|
||||
|
@ -310,9 +344,9 @@ if (foo) {
|
|||
}
|
||||
*/
|
||||
|
||||
foo = essai_filtrage_3x3(filename);
|
||||
foo = essai_rotate(filename);
|
||||
if (foo) {
|
||||
fprintf(stderr, "Filtre 3x3 ====> %d\n", foo);
|
||||
fprintf(stderr, "Essai ====> %d\n", foo);
|
||||
}
|
||||
|
||||
fprintf(stderr, "++++++++++++++ end of pid %d\n", getpid());
|
||||
|
|
Loading…
Reference in New Issue