/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        G E N E R A T I O N   D ' U N   C H A M P   C O M P L E T E M E N T   A L E A T O I R E   P A R   N I V E A U X  :         */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Definition :                                                                                                               */
/*                                                                                                                                   */
/*                    Cette commande genere dans l'image                                                                             */
/*                  nomme un champ completement aleatoire                                                                            */
/*                  ("random") en ce qui concerne les niveaux.                                                                       */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xci/random.01$K' :                                                                                             */
/*                                                                                                                                   */
/*                    Jean-Francois COLONNA (LACTAMME, 1987??????????).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        I N T E R F A C E   ' listG '  :                                                                                           */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        :Debut_listG:                                                                                                              */
/*        :Fin_listG:                                                                                                                */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D I R E C T I V E S   S P E C I F I Q U E S   D E   C O M P I L A T I O N  :                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        F I C H I E R S   D ' I N C L U D E S  :                                                                                   */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  INCLUDES_BASE
#include  image_image_IMAGESF_EXT
#include  image_image_ALEATOIRES_1_EXT

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        P A R A M E T R E S  :                                                                                                     */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  xci/substitue.01.I"
                                        /* Introduit le 20110401191527...                                                            */

#define   GRAINE                                                                                                                        \
                    PARE(1789)                                                                                                          \
                                        /* Graine initiale.                                                                          */ \
                                        /*                                                                                           */ \
                                        /* Le 20081124153024 la valeur par defaut est passee de 'DEUX' a 'PARE(1789)' car, en        */ \
                                        /* effet, la valeur 'DEUX' donnait, quel que soit le '$formatI' les lignes d'ordonnees       */ \
                                        /* 'Ymin' (=0) et 'Ymin+2' (=2) identiques. A cette date-la, tous les '$Fnota's et les       */ \
                                        /* '$U's qui referencaient '$xci/random.01$X', sans specifier de graines, se sont vu         */ \
                                        /* modifier par ajout de l'argument :                                                        */ \
                                        /*                                                                                           */ \
                                        /*                  graine=2                                                                 */ \
                                        /*                                                                                           */ \
                                        /* assurant ainsi la compatibilite anterieure...                                             */

#define   BORNE_INFERIEURE                                                                                                              \
                    FLOT__NOIR
#define   BORNE_SUPERIEURE                                                                                                              \
                    FLOT__BLANC

#define   GARANTIR_L_EQUIREPARTITION                                                                                                    \
                    VRAI                                                                                                                \
                                        /* Introduit le 20190124133051. Le 20190125092046 il y a eu passage de 'FAUX' a 'VRAI' car,  */ \
                                        /* en effet, c'est plus de garantir par defaut l'equirepartition...                          */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        M A C R O S   U T I L E S  :                                                                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  xci/substitue.02.I"
                                        /* Introduit le 20110401191527...                                                            */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        G E N E R A T I O N   D ' U N   C H A M P   C O M P L E T E M E N T   A L E A T O I R E   P A R   N I V E A U X  :         */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
BCommande(nombre_d_arguments,arguments)
/*-----------------------------------------------------------------------------------------------------------------------------------*/
     Bblock
     DEFV(CHAR,INIC(POINTERc(nom_imageR),NOM_PIPE));

     DEFV(Int,INIT(graine,GRAINE));
                                        /* Graine du generateur aleatoire...                                                         */

     DEFV(Float,INIT(borne_inferieure,BORNE_INFERIEURE));
     DEFV(Float,INIT(borne_superieure,BORNE_SUPERIEURE));

     DEFV(Logical,INIT(garantir_l_equirepartition,GARANTIR_L_EQUIREPARTITION));
                                        /* Introduit le 20190124133051. Le 20190125092046 il y a eu passage de 'FAUX' a 'VRAI' car,  */
                                        /* en effet, c'est plus de garantir par defaut l'equirepartition...                          */

#include  xci/substitue.03.I"
                                        /* Introduit le 20110401191527...                                                            */
     /*..............................................................................................................................*/
     GET_ARGUMENTSi(nombre_d_arguments
                   ,BLOC(GET_ARGUMENT_L("equirepartition=""equi=",garantir_l_equirepartition);
                         GET_ARGUMENT_N("compatibilite_20190124=",garantir_l_equirepartition);
                                        /* Parametres introduits le 20190124133051 et completes le 20190125091746 avec               */
                                        /* l'introduction de la compatibilite...                                                     */

                         GET_ARGUMENT_C("imageR=""R=",nom_imageR);
                         GET_ARGUMENT_I("methode=",gen_ft_____methode_standard);
                         GET_ARGUMENT_I("graine=",graine);
                         GET_ARGUMENT_L("affiner_rdn=",rdnIFnD_____affiner_la_generation);
                         GET_ARGUMENT_L("iterer_rdn=",rdnIFnD_____iterer_la_generation);

                         GET_ARGUMENT_F("PrdnI2D_NEUT=""NEUT=",rdnI2D_____ponderation_NEUT);
                         GET_ARGUMENT_F("PrdnI2D_GAUS=""GAUS=",rdnI2D_____ponderation_GAUS);
                         GET_ARGUMENT_F("PrdnI2D_GAUS_esperance=""GAUS_esperance=",rdnI2D_____ponderation_GAUS_esperance_);
                         GET_ARGUMENT_F("PrdnI2D_GAUS_ecart_type=""GAUS_ecart_type=",rdnI2D_____ponderation_GAUS_ecart_type);
                                        /* Parametres introduits le 20110325114739...                                                */

                         CONTROLE_DE_L_ADAPTATION_A_UNE_LOI_DE_DISTRIBUTION_QUELCONQUE;
                                        /* Introduit le 20110401182358 sous cette forme...                                           */

                         GET_ARGUMENT_F("borne_inferieure=""inf=",borne_inferieure);
                         GET_ARGUMENT_F("borne_superieure=""sup=",borne_superieure);
                         GET_ARGUMENT_L("standard=",les_images_sont_standards);

                         GET_ARGUMENTS2_F("maximum_ouvert_ferme=""mof="
                                         ,Irandom_niveaux_____maximum_ouvert
                                         ,Irandom_niveaux_____maximum_ferme
                                          );
                                        /* Parametres introduits le 20190124113722 pour permettre de garantir, si besoin est,        */
                                        /* l'equirepartition des niveaux y compris aux deux extremites 'NOIR' et 'BLANC' d'un        */
                                        /* histogramme. On doit alors utiliser :                                                     */
                                        /*                                                                                           */
                                        /*                  maximum_ouvert_ferme=256                                                 */
                                        /*                  sup=256                                                                  */
                                        /*                                                                                           */
                                        /* D'ou l'introduction de 'garantir_l_equirepartition' le 20190124133051...                  */

                         GET_ARGUMENT_L("aleatoire=""a=",rdnI2D_____generer_une_valeur_aleatoire);
                         GET_ARGUMENT_N("non_aleatoire=""na=",rdnI2D_____generer_une_valeur_aleatoire);
                         GET_ARGUMENT_F("non_aleatoire_ponderation_X=""napx=",rdnI2D_____ponderation_X);
                         GET_ARGUMENT_F("non_aleatoire_ponderation_Y=""napy=",rdnI2D_____ponderation_Y);
                         GET_ARGUMENT_F("non_aleatoire_translation_XY=""natxy=",rdnI2D_____translation_XY);
                                        /* Parametres introduits le 20220116110147...                                                */

                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_NEUT=""napNEUT="
                                       ,FfTransformUniverselle1_____ponderation_de_NEUT
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_COSX=""napCOSX="
                                       ,FfTransformUniverselle1_____ponderation_de_COSX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_SINX=""napSINX="
                                       ,FfTransformUniverselle1_____ponderation_de_SINX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_TANX=""napTANX="
                                       ,FfTransformUniverselle1_____ponderation_de_TANX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_ATAN=""napATAN="
                                       ,FfTransformUniverselle1_____ponderation_de_ATAN
                                        );
                         GET_ARGUMENT_F("non_aleatoire_arg_x_ATAN=""naaxATAN="
                                       ,FfTransformUniverselle1_____arg_x_ATAN
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_COHX=""napCOHX="
                                       ,FfTransformUniverselle1_____ponderation_de_COHX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_SIHX=""napSIHX="
                                       ,FfTransformUniverselle1_____ponderation_de_SIHX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_TAHX=""napTAHX="
                                       ,FfTransformUniverselle1_____ponderation_de_TAHX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_CSHX=""napCSHX="
                                       ,FfTransformUniverselle1_____ponderation_de_CSHX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_SSHX=""napSSHX="
                                       ,FfTransformUniverselle1_____ponderation_de_SSHX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_CTHX=""napCTHX="
                                       ,FfTransformUniverselle1_____ponderation_de_CTHX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_ATAH=""napATAH="
                                       ,FfTransformUniverselle1_____ponderation_de_ATAH
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_SLOGX=""napSLOGX="
                                       ,FfTransformUniverselle1_____ponderation_de_SLOGX
                                        );
                         GET_ARGUMENT_F("non_aleatoire_ponderation_de_EXPX=""napEXPX="
                                       ,FfTransformUniverselle1_____ponderation_de_EXPX
                                        );
                                        /* Parametres introduits le 20220116165734...                                                */
                         )
                    );

#include  xci/substitue.05.I"
                                        /* Introduit le 20110401191527...                                                            */

     Test(EST_VRAI(les_images_sont_standards))
          Bblock
                                        /* Cas d'une image 'image' (test introduit le 20190606122407...) :                           */
          Test(IL_FAUT(garantir_l_equirepartition))
                                        /* Test introduit le 20190124133051...                                                       */
               Bblock
               Test(IFEQ(borne_superieure,BORNE_SUPERIEURE))
                                        /* Test introduit le 20190606122407, le probleme ne se posant que si la borne superieure     */
                                        /* est vraiment "extremale"...                                                               */
                    Bblock
                    EGAL(borne_superieure,SUCN(BORNE_SUPERIEURE));

                    EGAL(Irandom_niveaux_____maximum_ouvert,borne_superieure);
                    EGAL(Irandom_niveaux_____maximum_ferme,borne_superieure);
                                        /* Ainsi, dans l'histogramme, 'BLANC' sera bien atteint a la fois a gauche (par exces) et    */
                                        /* a droite (par defaut). De plus, 'BLANC+1' sera lui-aussi atteint mais uniquement par      */
                                        /* la gauche (par exces) et se retrouvera, via le "modulo" dans [NOIR,BLANC], a completer    */
                                        /* le 'NOIR' qui lui n'est atteint que par la droite (par defaut). Il y a donc bien alors    */
                                        /* equirepartition...                                                                        */
                    Eblock
               ATes
                    Bblock
                    Eblock
               ETes
               Eblock
          ATes
               Bblock
               Eblock
          ETes
          Eblock
     ATes
          Bblock
          Eblock
     ETes

     Test(IFOU(IFGT(borne_superieure,Irandom_niveaux_____maximum_ouvert)
              ,IFGT(borne_superieure,Irandom_niveaux_____maximum_ferme)
               )
          )
          Bblock
          PRINT_ATTENTION("les maxima 'ouvert' et 'ferme' sont rendus compatibles avec la borne superieure");

          EGAL(Irandom_niveaux_____maximum_ouvert,borne_superieure);
          EGAL(Irandom_niveaux_____maximum_ferme,borne_superieure);
                                        /* Introduit le 20190124120742...                                                            */
          Eblock
     ATes
          Bblock
          Eblock
     ETes

     CALi(gInettoyage(les_images_sont_standards,ImageR,IFmageR));
                                        /* Initialisation de l'image Resultat.                                                       */

     Test(EST_VRAI(les_images_sont_standards))
          Bblock
                                        /* Cas d'une image 'image' :                                                                 */
          CALS(Irandom_niveaux(ImageR,graine,borne_inferieure,borne_superieure));
          Eblock
     ATes
          Bblock
                                        /* Cas d'une image 'imageF' :                                                                */
          CALS(IFrandom_niveaux(IFmageR,graine,borne_inferieure,borne_superieure));
          Eblock
     ETes

     CALi(gIupdate_image(les_images_sont_standards,nom_imageR,ImageR,IFmageR));

     RETU_Commande;
     Eblock
ECommande



Copyright © Jean-François COLONNA, 2019-2024.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / École polytechnique, Institut Polytechnique de Paris, 2019-2024.