Ignore:
Timestamp:
Feb 4, 2016, 6:25:22 PM (9 years ago)
Author:
meunier
Message:
  • Ajout de quelques fonction dans la lib math
  • Déplacement de certaines fonctions de stdlib vers string
Location:
soft/giet_vm/applications/rosenfeld
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/rosenfeld/include/ecc_generation.h

    r772 r777  
    1414void generate_granularity_density_float(uint8 **X, int i0, int i1, int j0, int j1, int granularity, float density, int seed);
    1515   
    16 void generate_size_granularity_name            (char *name, int size, int granularity,                               char *filename);
    17 void generate_granularity_density_name         (char *name,           int granularity, int density,                  char *filename);
    18 void generate_granularity_density_ext_name     (char *name,           int granularity, int density, char *extension, char *filename);
     16void generate_size_granularity_name            (char *name, int size, int granularity,                               char *filename, int maxlen);
     17void generate_granularity_density_name         (char *name,           int granularity, int density,                  char *filename, int maxlen);
     18void generate_granularity_density_ext_name     (char *name,           int granularity, int density, char *extension, char *filename, int maxlen);
    1919   
    20 void generate_size_granularity_density_name    (char *name, int size, int granularity, int density,                  char *filename);
    21 void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename);
     20void generate_size_granularity_density_name    (char *name, int size, int granularity, int density,                  char *filename, int maxlen);
     21void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename, int maxlen);
    2222
    23 void generate_name100(char *name, int granularity, float density, char *filename);
     23void generate_name100(char *name, int granularity, float density, char *filename, int maxlen);
    2424
    2525int test_generation(int argc, char* argv[]);
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio0.h

    r772 r777  
    2020#endif
    2121
    22 IMAGE_EXPORT(void) generate_filename_k_ndigit          (char *filename, int k, int ndigit,                  char *complete_filename);
    23 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename);
     22IMAGE_EXPORT(void) generate_filename_k_ndigit          (char *filename, int k, int ndigit,                  char *complete_filename, int maxlen);
     23IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen);
    2424
    25 IMAGE_EXPORT(void) generate_path_filename                     (char *path, char *filename,                                            char *complete_filename);
    26 IMAGE_EXPORT(void) generate_path_filename_extension           (char *path, char *filename,                           char *extension, char *complete_filename);
    27 IMAGE_EXPORT(void) generate_path_filename_suffix_extension    (char *path, char *filename, char *suffix,             char *extension, char *complete_filename);
    28 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension  (char *path, char *filename, int k, int ndigit,        char *extension, char *complete_filename);
    29 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename);
     25IMAGE_EXPORT(void) generate_path_filename                     (char *path, char *filename,                                            char *complete_filename, int maxlen);
     26IMAGE_EXPORT(void) generate_path_filename_extension           (char *path, char *filename,                           char *extension, char *complete_filename, int maxlen);
     27IMAGE_EXPORT(void) generate_path_filename_suffix_extension    (char *path, char *filename, char *suffix,             char *extension, char *complete_filename, int maxlen);
     28IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension  (char *path, char *filename, int k, int ndigit,        char *extension, char *complete_filename, int maxlen);
     29IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen);
    3030
    3131void select_display_positive_parameters(int iformat, char **format, char **str);
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio0.c

    r772 r777  
    2626
    2727/* --------------------------------------------------------------------------------------------------- */
    28 IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename)
     28IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename, int maxlen)
    2929/* --------------------------------------------------------------------------------------------------- */
    3030{
     
    4343    case 9 : format = "%s%09d.txt"; break;
    4444  }
    45   sprintf(complete_filename, format, filename, k);
     45  snprintf(complete_filename, maxlen, format, filename, k);
    4646}
    47 /* ------------------------------------------------------------------------------------------------------------------------------ */
    48 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename)
    49 /* ------------------------------------------------------------------------------------------------------------------------------ */
     47/* ------------------------------------------------------------------------------------------------------------------------------------------ */
     48IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)
     49/* ------------------------------------------------------------------------------------------------------------------------------------------ */
    5050{
    5151  char *format = "%s%d.%s";
     
    6363    case 9 : format = "%s%09d.%s"; break;
    6464  }
    65   sprintf(complete_filename, format, filename, k, extension);
     65  snprintf(complete_filename, maxlen, format, filename, k, extension);
    6666}
    67 /* ---------------------------------------------------------------------------------------- */
    68 IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename)
    69 /* ---------------------------------------------------------------------------------------- */
     67/* ---------------------------------------------------------------------------------------------------- */
     68IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename, int maxlen)
     69/* ---------------------------------------------------------------------------------------------------- */
    7070{
    71   sprintf(complete_filename, "%s%s", path, filename);
     71  snprintf(complete_filename, maxlen, "%s%s", path, filename);
    7272}
    73 /* ------------------------------------------------------------------------------------------------------------------- */
    74 IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename)
    75 /* ------------------------------------------------------------------------------------------------------------------- */
     73/* ------------------------------------------------------------------------------------------------------------------------------- */
     74IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename, int maxlen)
     75/* ------------------------------------------------------------------------------------------------------------------------------- */
    7676{
    77   sprintf(complete_filename, "%s%s.%s", path, filename, extension);
     77  snprintf(complete_filename, maxlen, "%s%s.%s", path, filename, extension);
    7878}
    79 /* ---------------------------------------------------------------------------------------------------------------------------------------- */
    80 IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename)
    81 /* ---------------------------------------------------------------------------------------------------------------------------------------- */
     79/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
     80IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename, int maxlen)
     81/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
    8282{
    83     sprintf(complete_filename, "%s%s%s.%s", path, filename, suffix, extension);
     83    snprintf(complete_filename, maxlen, "%s%s%s.%s", path, filename, suffix, extension);
    8484}
    85 /* ----------------------------------------------------------------------------------------------------------------------------------------------- */
    86 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension(char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename)
    87 /* ----------------------------------------------------------------------------------------------------------------------------------------------- */
     85/* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */
     86IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension(char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)
     87/* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */
    8888{
    8989  char *format = "%s%s%d.%s";
     
    101101    case 9 : format = "%s%s%09d.%s"; break;
    102102  }
    103   sprintf(complete_filename, format, path, filename, k, extension);
     103  snprintf(complete_filename, maxlen, format, path, filename, k, extension);
    104104}
    105 /* -------------------------------------------------------------------------------------------------------------------------------------------------------- */
    106 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename)
    107 /* -------------------------------------------------------------------------------------------------------------------------------------------------------- */
     105/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
     106IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen)
     107/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
    108108{
    109109  char *format = "%s%s%d_%d.%s";
     
    121121    case 9 : format = "%s%s%09d_%09d.%s"; break;
    122122  }
    123   sprintf(complete_filename, format, path, filename, k, l, extension);
     123  snprintf(complete_filename, maxlen, format, path, filename, k, l, extension);
    124124}
    125125// ----------------------------------------------------------------------------
  • soft/giet_vm/applications/rosenfeld/src/ecc_common.c

    r772 r777  
    55#include <stdio.h>
    66#include <stdlib.h>
     7#include <string.h>
    78#include <math.h>
    89
     
    310311    char complete_filename[64];
    311312   
    312     sprintf(complete_filename, "%s.dot", filename);
     313    snprintf(complete_filename, 64, "%s.dot", filename);
    313314   
    314315    fd = open(complete_filename, O_CREAT | O_TRUNC);
     
    330331    char complete_filename[64];
    331332   
    332     sprintf(complete_filename, "%s.dot", filename);
     333    snprintf(complete_filename, 64, "%s.dot", filename);
    333334   
    334335   
     
    351352    char complete_filename[64];
    352353   
    353     sprintf(complete_filename, "%s.dot", filename);
     354    snprintf(complete_filename, 64, "%s.dot", filename);
    354355   
    355356   
     
    403404    char complete_filename[64];
    404405   
    405     sprintf(complete_filename, "%s.dot", filename);
     406    snprintf(complete_filename, 64, "%s.dot", filename);
    406407   
    407408   
  • soft/giet_vm/applications/rosenfeld/src/ecc_generation.c

    r772 r777  
    5858    generate_granularity_density_float(X, i0, i1, j0, j1, granularity, (float) density, seed);
    5959}
    60 // ---------------------------------------------------------------------------------------------
    61 void generate_granularity_density_name(char *name, int granularity, int density, char *filename)
    62 // ---------------------------------------------------------------------------------------------
    63 {
    64     sprintf(filename, "%s_%02d_%03d.pgm", name, granularity, density);
    65 }
    66 // ------------------------------------------------------------------------------------------------------------------
    67 void generate_granularity_density_ext_name(char *name, int granularity, int density, char *extension, char *filename)
    68 // ------------------------------------------------------------------------------------------------------------------
    69 {
    70     sprintf(filename, "%s_%02d_%03d.%s", name, granularity, density, extension);
    71 }
    72 // ------------------------------------------------------------------------------------------------------------
    73 void generate_size_granularity_density_name(char *name, int size, int granularity, int density, char *filename)
    74 // ------------------------------------------------------------------------------------------------------------
    75 {
    76     sprintf(filename, "%s_%d_%02d_%03d.pgm", name, size, granularity, density);
    77 }
    78 // ---------------------------------------------------------------------------------------------------------------------------------
    79 void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename)
    80 // ---------------------------------------------------------------------------------------------------------------------------------
    81 {
    82     sprintf(filename, "%s_%d_%02d_%03d.%s", name, size, granularity, density, extension);
    83 }
    84 // ---------------------------------------------------------------------------------------
    85 void generate_size_granularity_name(char *name, int size, int granularity, char *filename)
    86 // ---------------------------------------------------------------------------------------
    87 {
    88     sprintf(filename, "%s_%d_%02d.pgm", name, size, granularity);
    89 }// ------------------------------------------------------------------------------
    90 void generate_name100(char *name, int granularity, float density, char *filename)
    91 // ------------------------------------------------------------------------------
     60// ---------------------------------------------------------------------------------------------------------
     61void generate_granularity_density_name(char *name, int granularity, int density, char *filename, int maxlen)
     62// ---------------------------------------------------------------------------------------------------------
     63{
     64    snprintf(filename, maxlen, "%s_%02d_%03d.pgm", name, granularity, density);
     65}
     66// ------------------------------------------------------------------------------------------------------------------------------
     67void generate_granularity_density_ext_name(char *name, int granularity, int density, char *extension, char *filename, int maxlen)
     68// ------------------------------------------------------------------------------------------------------------------------------
     69{
     70    snprintf(filename, maxlen, "%s_%02d_%03d.%s", name, granularity, density, extension);
     71}
     72// ------------------------------------------------------------------------------------------------------------------------
     73void generate_size_granularity_density_name(char *name, int size, int granularity, int density, char *filename, int maxlen)
     74// ------------------------------------------------------------------------------------------------------------------------
     75{
     76    snprintf(filename, maxlen, "%s_%d_%02d_%03d.pgm", name, size, granularity, density);
     77}
     78// ---------------------------------------------------------------------------------------------------------------------------------------------
     79void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename, int maxlen)
     80// ---------------------------------------------------------------------------------------------------------------------------------------------
     81{
     82    snprintf(filename, maxlen, "%s_%d_%02d_%03d.%s", name, size, granularity, density, extension);
     83}
     84// ---------------------------------------------------------------------------------------------------
     85void generate_size_granularity_name(char *name, int size, int granularity, char *filename, int maxlen)
     86// ---------------------------------------------------------------------------------------------------
     87{
     88    snprintf(filename, maxlen, "%s_%d_%02d.pgm", name, size, granularity);
     89}// -----------------------------------------------------------------------------------------
     90void generate_name100(char *name, int granularity, float density, char *filename, int maxlen)
     91// ------------------------------------------------------------------------------------------
    9292{
    9393    // density en pourcentage: 0:100
    9494    // mais aussi <1, par exe 0.01
    9595    int d = (int) ceil(100 * density);
    96     sprintf(filename, "%s_%02d_%05d.pgm", name, granularity, d);
     96    snprintf(filename, maxlen, "%s_%02d_%05d.pgm", name, granularity, d);
    9797}
    9898// ----------------------------------------
     
    128128        for(d=dmin; d<=dmax; d+=dstep) {
    129129            generate_granularity_density_int(X, 0, n-1, 0, n-1, g, d, seed);
    130             generate_granularity_density_name("I", g, d, filename);
     130            generate_granularity_density_name("I", g, d, filename, 32);
    131131            printf(filename);
    132132            bin2gray_ui8matrix(X, 0, n-1, 0, n-1, X255);
     
    256256    X255 = ui8matrix(0, h-1, 0, w-1);
    257257   
    258     sprintf(filename, "spirale_simple_%d.pgm", n);
     258    snprintf(filename, 128, "spirale_simple_%d.pgm", n);
    259259    spirale_simple(X, h, w);
    260260    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
    261261    SavePGM_ui8matrix(X255, 0, h-1, 0, w-1, filename);
    262262   
    263     sprintf(filename, "spirale_double_%d.pgm", n);
     263    snprintf(filename, 128, "spirale_double_%d.pgm", n);
    264264    spirale_double(X, h, w);
    265265    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
     
    306306
    307307    generate_granularity_density_float(X, 0, h-1, 0, w-1, g, d, seed);
    308     generate_granularity_density_name("HGH", g, d, filename);
     308    generate_granularity_density_name("HGH", g, d, filename, 32);
    309309    printf(filename);
    310310    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
  • soft/giet_vm/applications/rosenfeld/src/ecc_main_rosenfeld_sa.c

    r772 r777  
    105105    binarisation_ui8matrix(X0, i0, i1, j0, j1, 1, 1, X);    // pour le traitement
    106106    binarisation_ui8matrix(X0, i0, i1, j0, j1, 1, 255, X0); // pour la verif visuelle
    107     generate_path_filename(dst_path, "verif.pgm", complete_filename);
     107    generate_path_filename(dst_path, "verif.pgm", complete_filename, 1024);
    108108    SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename);
    109109    display_ui8matrix_positive(X, i0, i1, j0, j1, 3, "X");
     
    131131    // traitement: desactiver FlattenL dans Rosenfeld
    132132    // pour voir l'image d'etiquettes  sans re-etiquetage
    133     na = Rosenfeld_UF_Org1_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
    134 
    135 
    136     na = Rosenfeld_UF_Org1_8C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_8C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
    137 
    138 
    139     na = Rosenfeld_UF_Org2_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org2_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
     133    na = Rosenfeld_UF_Org1_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename, 1024); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
     134
     135
     136    na = Rosenfeld_UF_Org1_8C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_8C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename, 1024); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
     137
     138
     139    na = Rosenfeld_UF_Org2_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org2_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename, 1024); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
    140140   
    141141    // free
     
    188188   
    189189    Palette_18ColorsBW(palette);
    190     generate_path_filename(pathSrc, filename, complete_filename);
     190    generate_path_filename(pathSrc, filename, complete_filename, 1024);
    191191
    192192    // chargement d'une image depuis le disque
     
    206206    binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 1, X); // pour le traitement
    207207    binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 255, X0); // pour la verif visuelle
    208     generate_path_filename(pathDst, "verif.pgm", complete_filename);
     208    generate_path_filename(pathDst, "verif.pgm", complete_filename, 1024);
    209209    SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename);
    210210
     
    236236    filename = "Rosenfeld_UF_Org1_8C.bmp";
    237237    mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8);
    238     generate_path_filename(pathDst, filename, complete_filename);
     238    generate_path_filename(pathDst, filename, complete_filename, 1024);
    239239    SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename);
    240240    zero_ui32matrix(E32, i0 - border, i1 + border, j0 - border, j1 + border);
  • soft/giet_vm/applications/rosenfeld/src/str_ext.c

    r772 r777  
    99#include <stdio.h>
    1010#include <stdlib.h>
     11#include <string.h>
    1112
    1213#include "nrc_os_config.h"
Note: See TracChangeset for help on using the changeset viewer.