more and more tools

This commit is contained in:
tth 2022-06-28 15:14:08 +02:00
parent 6ce9f49c55
commit 60409a050c
9 changed files with 456 additions and 10 deletions

2
.gitignore vendored
View File

@ -12,9 +12,11 @@ Lib/t_t16x24
Tools/genplot2
Tools/tga_cadre
Tools/tga_combine
Tools/tga_dither
Tools/tga_tools
Tools/tga_effects
Tools/tga_equalize
Tools/tga_filtres
Tools/tga_remap
Tools/tga_television

View File

@ -103,6 +103,7 @@ rgbmask.o: rgbmask.c $(DEPS)
scale.o: scale.c $(DEPS)
sobel4.o: sobel4.c $(DEPS)
stereo.o: stereo.c $(DEPS)
tamppool.o: tamppool.c $(DEPS)
tele_2.o: tele_2.c $(DEPS)
@ -131,6 +132,7 @@ OBJECTS = 7seg.o \
calculs.o classif.o \
col4bits.o colors.o colors2.o col_reduc.o col_xyz.o \
combine.o combine2.o combine3.o combine4.o combine5.o \
combine6.o combine_rnd.o \
contrast.o \
detect.o distances.o \
dither.o dither2.o dither3.o dither4.o \
@ -151,7 +153,7 @@ OBJECTS = 7seg.o \
pov_hf15e.o pov_hf15e.o pov_hf15f.o pov_synth.o \
ptlist.o \
recurse.o rgbmask.o \
scale.o sobel4.o \
scale.o sobel4.o stereo.o \
tamppool.o tele_2.o television.o \
text0.o text1.o text16x24.o \
tga.o tools.o \

View File

@ -9,7 +9,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "tthimage.h"
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
/*

View File

@ -1314,7 +1314,7 @@ if (NULL == dst)
foo = Image_lissage_3x3(src, dst);
Image_TGA_save("Pictures/filtre-liss3x3.tga", dst, 0);
if (foo) { fprintf(stderr, "%s: liss3x3 -> %d\n", foo); }
if (foo) { fprintf(stderr, "%s: liss3x3 -> %d\n", __func__, foo); }
foo = Image_filtre_Prewitt(src, dst, 5);
Image_TGA_save("Pictures/filtre-prewitt-5.tga", dst, 0);
foo = Image_filtre_passe_haut(src, dst);

126
Lib/stereo.c Normal file
View File

@ -0,0 +1,126 @@
/*
+[
S=T=R=E=R=E=O
]+
*/
#include <stdio.h>
#include <stdlib.h>
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
/*
* première fonction, assez primitive, mais qui marche.
*/
int
Image_combine_stereo_0(Image_Desc *gauche, Image_Desc *droite,
Image_Desc *stereo)
{
int x, y, foo;
int rouge, vert;
if ( (foo=Image_compare_desc(gauche, droite)) )
{
fprintf(stderr, "Combine Stereo 0: sources are differents (%d)\n", foo);
return foo;
}
if ( (foo=Image_compare_desc(gauche, stereo)) )
{
fprintf(stderr, "Combine Stereo 0: dest have a bad dim (%d)\n", foo);
return foo;
}
for (y=0; y<gauche->height; y++)
{
for (x=0; x<droite->width; x++)
{
rouge = ( Image_R_pixel(droite, x, y)+
Image_G_pixel(droite, x, y)+
Image_B_pixel(droite, x, y) ) / 3;
vert = ( Image_R_pixel(gauche, x, y)+
Image_G_pixel(gauche, x, y)+
Image_B_pixel(gauche, x, y) ) / 3;
Image_plotRGB(stereo, x, y, rouge, vert, 0);
}
}
stereo->modified = 1;
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/*
* celui-ci semble le meme que le '_0', mais il va probablement
* evoluer... Et il serait vraiment bien que je trouve de la doc
* sur les differents parametres chromatiques.
* =============================================================
* En fait (30 janv 2008, ave StEx) au lieu de faire du Rouge/Vert
* il va faire du Rouge/Bleu. A la demande de Ker2x.
*/
int
Image_combine_stereo_1(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int kr, int kg, int kb)
{
int x, y, foo, cumul;
int rouge, bleu;
if ( (foo=Image_compare_desc(s1, s2)) )
{
fprintf(stderr, "Combine Stereo 1: sources are differents (%d)\n", foo);
return foo;
}
if ( (foo=Image_compare_desc(s1, d)) )
{
fprintf(stderr, "Combine Stereo 1: dest have a bad dim (%d)\n", foo);
return foo;
}
cumul = kr + kg + kb;
#if DEBUG_LEVEL
fprintf(stderr, "Combine Stereo 1: coefs are %d %d %d\n", kr, kg, kb);
fprintf(stderr, "Combine Stereo 1: cumul is %d\n", cumul);
#endif
for (y=0; y<s1->height; y++)
{
for (x=0; x<s1->width; x++)
{
rouge = Image_R_pixel(s2, x, y) * kr +
Image_G_pixel(s2, x, y) * kg +
Image_B_pixel(s2, x, y) * kb;
rouge /= cumul;
bleu = Image_R_pixel(s1, x, y) * kr +
Image_G_pixel(s1, x, y) * kg +
Image_B_pixel(s1, x, y) * kb;
bleu /= cumul;
Image_plotRGB(d, x, y, rouge, 0, bleu);
}
}
d->modified = 1;
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/*
* Et pour celui-ci, il faudrait trouver une façon de définir
* les composantes pour l'image destination, afin de tenir
* compte des filtres qui seront dans les lunettes...
*/
int
Image_combine_stereo_2(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
char cr, char cl)
{
/* XXX
int x, y, foo;
int rouge, vert, bleu;
XXX */
fprintf(stderr, "%s: %s missing, sorry.\n", __FILE__, __func__);
return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/

View File

@ -10,8 +10,9 @@ DEPS = ../tthimage.h Makefile tga_outils.h
all: genplot2 \
tga_cadre tga_effects tga_filtres tga_remap tga_tools \
tga_combine \
tga_television tga_dither tga_applymap tga_makehf15 \
tga_mires tga_incrust tga_pattern
tga_mires tga_incrust tga_pattern tga_equalize
# 'tga_info.c' do not compile yet
@ -33,12 +34,18 @@ tga_applymap: tga_applymap.c $(DEPS) fonctions.o
tga_cadre: tga_cadre.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_combine: tga_combine.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_dither: tga_dither.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_effects: tga_effects.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_equalize: tga_equalize.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_filtres: tga_filtres.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@

306
Tools/tga_combine.c Normal file
View File

@ -0,0 +1,306 @@
/*
un outil pour combiner deux images TGA
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
#define MIX_SEUILS 10
#define MIX_GRAY 11
#define MIX_RGB 12
#define MIX_LINES 20
#define MIX_COLUMNS 21
#define MIX_CHECKER 22
#define MIX_RANDOM 23
#define MIX_RNDRGB 24
#define MIX_POWER 25
#define MIX_POWERM 26 /* new 14 mars 2014 */
#define MIX_XOR 27 /* new 25 sept 2018 */
#define MIX_DIAGO 40
#define MIX_HSPLIT0 50 /* new 29 nov 2013 */
#define MIX_VSPLIT0 51 /* new 29 nov 2013 */
#define MIX_MINMAX 60
#define MIX_STEREO 70
#define MIX_STEREOK 71
#define MIX_STEREO3 73
#define MIX_WAOU 80
#define MIX_WAUO 81
#define MIX_CIRCLE0 84
#define MIX_HDEG 100
#define MIX_VDEG 101
#define MIX_PROTO 110
#define MIX_IFNOTBLACK 200
static char no_help[] = "no help";
static char h_mix_gray[] = "param: 1..10000";
static char h_mix_rgb[] = "params: 3*1..10000";
static char h_lico[] = "taille offset 0";
static char h_random[] = "param: 1..10000";
static char h_minmax[] = "0:min 1:max";
static char h_waou[] = "ubyte ubyte ubyte bit";
static char h_wauo[] = "must be 0";
static char h_circle0[] = "must be 0";
static char h_deg[] = "0 or 1";
mot_clef les_types[] =
{
{ "mixer", MIX_GRAY, "i", no_help },
{ "mix_gray", MIX_GRAY, "i", h_mix_gray },
{ "mix_rgb", MIX_RGB, "iii", h_mix_rgb },
{ "seuils", MIX_SEUILS, "iii", "P in [0..255]" },
{ "lines", MIX_LINES, "iii", h_lico },
{ "columns", MIX_COLUMNS, "iii", h_lico },
{ "checker", MIX_CHECKER, "iiiii", no_help },
{ "random", MIX_RANDOM, "i", h_random },
{ "rndrgb", MIX_RNDRGB, "i", h_random },
{ "diago", MIX_DIAGO, "fii", no_help },
{ "diagonale", MIX_DIAGO, "fii", no_help },
{ "hsplit", MIX_HSPLIT0, "ii", "position 0" },
{ "vsplit", MIX_VSPLIT0, "ii", "P in pixels" },
{ "minmax", MIX_MINMAX, "i", h_minmax },
{ "power", MIX_POWER, "", "" },
{ "powerm", MIX_POWERM, "", "" },
{ "xor", MIX_XOR, "", "" },
{ "waou", MIX_WAOU, "iiii", h_waou },
{ "wauo", MIX_WAUO, "i", h_wauo },
{ "circle0", MIX_CIRCLE0, "i", h_circle0 },
{ "hdeg", MIX_HDEG, "f", h_deg },
{ "vdeg", MIX_VDEG, "f", h_deg },
{ "ifnotblack", MIX_IFNOTBLACK, "", "new mars 2007" },
{ "stereo", MIX_STEREO, "", "rouge/vert" },
{ "stereok", MIX_STEREOK, "iii", "rouge/bleu coefs" },
{ "proto", MIX_PROTO, "", "prototype" },
{ NULL, 0, NULL, NULL }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "* Tga Combine v 0.1.43 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
if (flag)
fprintf(stderr, "* compiled : " __DATE__ " *\n");
Image_print_version(0);
fputs("Usage:\n", stderr);
fputs("\ttga_combine s1.tga s2.tga MODE d.tga [PARAMS]\n", stderr);
fputs("\n", stderr);
if (flag) liste_mots_clefs(les_types, 0);
exit(0);
}
/*::------------------------------------------------------------------::*/
int combine_proto(Image_Desc *sa, Image_Desc *sb, Image_Desc *dest)
{
fprintf(stderr, "%p + %p -> %p\n", sa, sb, dest);
return 42;
}
/*::------------------------------------------------------------------::*/
/*
* arg[1] s1.tga
* arg[2] s2.tga
* arg[3] mode
* arg[4] dst.tga
*/
#define FIRST_PARAM 5
int main(int argc, char *argv[])
{
Image_Desc *s1, *s2, *d;
int foo;
int idx, mode, nbarg;
char *dstname;
int kr, kg, kb;
dump_command_line(argc, argv, 0);
if (argc==2 && !strcmp(argv[1], "list")) usage(1);
if (argc < 5 ) usage(0);
if ((idx=cherche_mot_clef(argv[3], les_types, &mode, &nbarg)) == -1)
{
fprintf(stderr, "mode '%s' inconnu\n", argv[3]);
exit(1);
}
#if DEBUG_LEVEL
fprintf(stderr, "%s --> idx=%d, mode=%d, %d args\n", argv[3], idx, mode, nbarg);
fprintf(stderr, "argc = %d\n", argc);
#endif
if (mode == -1)
{
fprintf(stderr, "mode '%s' inconnu\n", argv[3]);
exit(5);
}
/* analyse des paramètres */
foo = parse_parametres(argc, argv, les_types[idx].ptypes, FIRST_PARAM);
#if DEBUG_LEVEL
fprintf(stderr, "parse params -> %d\n", foo);
#endif
if ((s1 = Image_TGA_alloc_load(argv[1]))==NULL)
{
fprintf(stderr, "tga_combine: can't load image #1\n");
exit(5);
}
if (must_be_verbose())
{
fprintf(stderr, "%s loaded at %p\n", argv[1], s1);
}
if ((s2 = Image_TGA_alloc_load(argv[2]))==NULL)
{
fprintf(stderr, "tga_combine: can't load image #2\n");
exit(5);
}
if (must_be_verbose())
{
fprintf(stderr, "%s loaded at %p\n", argv[2], s2);
}
if ((d = Image_clone(s2, 0))==NULL)
{
fprintf(stderr, "tga_combine: erreur clonage destination\n");
exit(5);
}
switch (mode)
{
case MIX_SEUILS:
foo = Image_combine_seuils(s1, s2, d, GIP(0), GIP(1), GIP(2));
break;
case MIX_GRAY:
foo = Image_mix(s1, s2, d, GIP(0));
break;
case MIX_RGB:
foo = Image_mix_rgb(s1, s2, d, GIP(0), GIP(1), GIP(2));
break;
case MIX_LINES:
foo = Image_combine_lines(s1, s2, d, GIP(0), GIP(1), GIP(2));
break;
case MIX_COLUMNS:
foo = Image_combine_columns(s1, s2, d, GIP(0), GIP(1), GIP(2));
break;
case MIX_CHECKER:
foo = Image_combine_checker(s1, s2, d, GIP(0), GIP(1), GIP(2),
GIP(3), GIP(4));
break;
case MIX_RANDOM:
foo = Image_combine_random_point(s1, s2, d, GIP(0));
break;
case MIX_RNDRGB:
fprintf(stderr, "SEGFAULT, COREDUMP, what else ?\n");
foo = Image_combine_random_rgb(s1, s2, d, GIP(0));
break;
case MIX_DIAGO:
/* oui, bon, a quoi servent les parametres ? */
/* 17sept2009: le 0 est le sens de la coupure,
et les 1 & 2 sont 'not used' */
foo = Image_combine_diagonale(s1, s2, d,
GFP(0), GIP(1), GIP(2));
break;
case MIX_HSPLIT0:
foo = Image_combine_Hsplit(s1, s2, d, GIP(0), GIP(1));
break;
case MIX_VSPLIT0:
foo = Image_combine_Vsplit(s1, s2, d, GIP(0), GIP(1));
break;
case MIX_MINMAX:
foo = Image_combine_minmax(s1, s2, d, GIP(0));
break;
case MIX_POWER:
foo = Image_combine_power(s1, s2, d);
fprintf(stderr, "combine power -> %d\n", foo);
break;
case MIX_POWERM:
foo = Image_combine_power_m(s1, s2, d);
fprintf(stderr, "combine power_m -> %d\n", foo);
break;
case MIX_WAOU:
foo = Image_combine_waou(s1,s2,d,GIP(0),GIP(1),GIP(2),GIP(3));
break;
case MIX_WAUO:
foo = Image_combine_wauo(s1, s2, d, GIP(0));
break;
case MIX_CIRCLE0:
foo = Image_combine_cercle_flou(s1, s2, d, 0);
break;
/* FIXME 16 sept 2009 : je pense que hdeg et vdeg sont inverses */
case MIX_HDEG:
foo = Image_combine_Hdegrade(s1, s2, d, GFP(0));
break;
case MIX_VDEG:
foo = Image_combine_Vdegrade(s1, s2, d, GFP(0));
break;
case MIX_IFNOTBLACK:
foo = Image_combine_if_not_black(s1, s2, d);
break;
case MIX_XOR:
foo = Image_XOR(s1, s2, d, 1);
if (666==foo) fputs("#####################", stderr);
break;
case MIX_STEREO:
foo = Image_combine_stereo_0(s1, s2, d);
break;
case MIX_STEREOK:
kr = GIP(0);
kg = GIP(1);
kb = GIP(2);
foo = Image_combine_stereo_1(s1, s2, d, kr, kg, kb);
break;
default:
fprintf(stderr, "mode operation %d non implemente\n", mode);
exit(1);
break;
}
if (foo)
Image_print_error("Combination", foo);
dstname = argv[4];
foo = Image_TGA_save(dstname, d, 0);
#if DEBUG_LEVEL
fprintf(stderr, "image '%s' ecrite (%d)\n", dstname, foo);
#endif
return 0;
}
/*::------------------------------------------------------------------::*/

View File

@ -38,10 +38,11 @@ mot_clef mots_clef[] =
/*::------------------------------------------------------------------::*/
int usage(int flag)
{
fprintf(stderr, "* TGA incrustator v 0.1.2 [%s] %s \n",
fprintf(stderr, "* TGA incrustator v 0.1.3 [%s] %s \n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__);
fprintf(stderr, "tga_incrust orig insert mode out\n");
fprintf(stderr, "usage:\n\ttga_incrust orig insert mode out\n");
if (flag) {
Image_print_version(0);
@ -72,7 +73,7 @@ dump_command_line(argc, argv, 0);
if (argc==2 && !strcmp(argv[1], "-?")) usage(0);
if (argc==2 && !strcmp(argv[1], "list")) usage(1);
if (argc < 4) usage(0);
if (argc < 4) usage(1);
if (must_be_verbose())
{
@ -125,7 +126,7 @@ switch (commande)
break;
default:
fprintf(stderr, "%d bad command\n", commande);
fprintf(stderr, "%d command not implemented\n", commande);
exit(1);
}

View File

@ -37,14 +37,16 @@ mot_clef mots_clef[] =
{ "pix0", TV_PIX0, "iii", "func not finished" },
{ "pix1", TV_PIX1, "iii", "func not finished" },
{ "triligne", TV_TRILIGNE, "f", "flag : rand or modulo" },
{ "cplus0", TV_PROTO, "i", "premier cplus" },
{ "proto", TV_PROTO, "i", "prototype canal+" }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "* tga_television v 0.0.23 [%s] %s\n",
fprintf(stderr, "* tga_television v 0.0.24 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "Usage: tga_television <src.tga> method <dst.tga> [params]\n");
fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__);
fprintf(stderr, "Usage:\n\ttga_television <src.tga> method <dst.tga> [params]\n");
Image_print_version(0);
liste_mots_clefs(mots_clef, 42);