3 * \brief test de reduction par MV et contriante de ligne de niveaux
12 #include <sys/ptrace.h>
21 #include "lib_alloc.h"
22 #include "lib_images.h"
24 #include "lib_pretraitement.h"
29 int main(int argc, char **argv)
33 if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0) return(0) ;
36 /* declaration des variables */
39 int Prof ; /* profondeur en octets */
40 int I_dim ; /* hauteur de l'image */
41 int J_dim ; /* largeur de l'image */
42 int Nb_level ; /* dynamique de l'image */
47 int **Image_in1, **Image_out1 ;
48 int **Image_in2=NULL, **Image_in3=NULL ;
49 int **Image_out2=NULL, **Image_out3=NULL ;
52 /* variables de calculs */
53 struct timeval chrono ;
55 /* debug : affichage snake */
60 /* lecture argument entree (basique!) */
63 fprintf(stderr, "USAGE : LNIV pgm_file <params>\n") ;
73 /* verif type image (pgm 8/16) */
74 ret = type_image_ppm(&Prof, &I_dim, &J_dim, &Nb_level, File_name) ;
79 /* tentative image bin */
80 ret = load_dim_image_bin(&I_dim, &J_dim, File_name) ;
83 printf("format non pris en charge ... exit\n") ;
86 Nb_level = 65536 ; // quantif 16 bits pour les bin
94 printf("Image : %s\n", File_name) ;
95 printf("lecture OK : %d\n", ret) ;
96 printf("Image (%d x %d) pixels\n", I_dim, J_dim) ;
97 printf("Dynamique : %d\n", Nb_level) ;
98 printf("Canaux : %d\n", Prof) ;
102 Image_in1 = new_matrix_int(I_dim, J_dim) ;
103 Image_out1 = new_matrix_int(I_dim, J_dim) ;
106 Image_in2 = new_matrix_int(I_dim, J_dim) ;
107 Image_out2 = new_matrix_int(I_dim, J_dim) ;
108 Image_in3 = new_matrix_int(I_dim, J_dim) ;
109 Image_out3 = new_matrix_int(I_dim, J_dim) ;
112 /* chargement image d'entree */
115 load_bin2int(Image_in1, I_dim, J_dim, Nb_level, File_name) ;
118 load_pgm2int(Image_in1, I_dim, J_dim, Nb_level, File_name) ;
119 else /* (Prof == 3) */
121 load_ppm2int(Image_in1, Image_in2, Image_in3, I_dim, J_dim, File_name ) ;
122 //RGB2YUV(Image_in1[0], Image_in2[0], Image_in3[0], I_dim*J_dim) ;
125 toc(chrono, "temps chargement image") ;
126 if (Display) image16(Image_in1, I_dim, J_dim) ;
127 if ((Display)&&(Prof == 3)) image16(Image_in2, I_dim, J_dim) ;
128 if ((Display)&&(Prof == 3)) image16(Image_in3, I_dim, J_dim) ;
130 /* sequence de parametre */
131 if (argc >= 3) PARAM = argv[2] ;
133 double poids = 15.0 ;
139 printf("poids contrainte : %.3f\n", poids) ;
140 printf("nombre d'iteration GN : %d\n", nb_iter) ;
143 mv_gaussien_lniv(Image_in1, Image_out1, I_dim, J_dim, poids, nb_iter) ;
144 toc(chrono, "temps lniv_image") ;
146 wimage16(Image_out1, I_dim, J_dim, "output.pgm") ;
153 printf("image couleur (YUV)\n") ;
154 printf("poids contrainte : %.3f\n", poids) ;
155 printf("nombre d'iteration GN : %d\n", nb_iter) ;
159 mv_gaussien_lniv(Image_in1, Image_out1, I_dim, J_dim, poids, nb_iter) ;
160 mv_gaussien_lniv(Image_in2, Image_out2, I_dim, J_dim, poids, nb_iter) ;
161 mv_gaussien_lniv(Image_in3, Image_out3, I_dim, J_dim, poids, nb_iter) ;
163 toc(chrono, "temps lniv_image") ;
165 image16(Image_out1, I_dim, J_dim) ;
166 image16(Image_out2, I_dim, J_dim) ;
167 image16(Image_out3, I_dim, J_dim) ;
168 write_intRGB2ppm8(Image_out1, Image_out2, Image_out3, I_dim, J_dim, "output.ppm") ;
174 del_matrix_int(Image_in1, I_dim) ;
175 del_matrix_int(Image_out1, I_dim) ;
178 del_matrix_int(Image_in2, I_dim) ;
179 del_matrix_int(Image_out2, I_dim) ;
180 del_matrix_int(Image_in3, I_dim) ;
181 del_matrix_int(Image_out3, I_dim) ;