/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        R E C H E R C H E   B I D I M E N S I O N N E L L E   D E   P O I N T S   V O I S I N S   D A N S   U N E   I M A G E  :   */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xrv/PointsVoisins_2D.01$K' :                                                                                   */
/*                                                                                                                                   */
/*                    Jean-Francois COLONNA (LACTAMME, 20150703102402).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        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

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        V A L E U R S   I M P L I C I T E S   D E S   P A R A M E T R E S  :                                                       */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#define   NIVEAU_DES_POINTS                                                                                                             \
                    BLANC                                                                                                               \
                                        /* Niveau des points a etudier...                                                            */
#define   COORDONNEE_Z                                                                                                                  \
                    FZERO                                                                                                               \
                                        /* Coordonnee 'Z' par defaut (dans le cas bidimensionnel).                                   */

#define   NOMBRE_DE_VOISINS_CHERCHES                                                                                                    \
                    SIX                                                                                                                 \
                                        /* Nombre de voisins recherches.                                                             */
#define   NOMBRE_MAXIMAL_DE_POINTS_A_TESTER                                                                                             \
                    MILLE                                                                                                               \
                                        /* Nombre maximal de points a tester autour de chaque point de 'niveau_des_points'.          */
#define   DISTANCE_MINIMALE_ENTRE_DEUX_POINTS                                                                                           \
                    FZERO
#define   DISTANCE_MAXIMALE_ENTRE_DEUX_POINTS                                                                                           \
                    F_INFINI
                                        /* Distances extremales entre deux points voisins (le minimum a ete introduit                */
                                        /* 20150812093721).                                                                          */
#define   TRIER_LES_DEUX_POINTS_DANS_UN_COUPLE                                                                                          \
                    VRAI                                                                                                                \
                                        /* Faut-il trier les deux points d'un couple {A,B} de facon a ce que {B,A} apparaissent      */
                                        /* sous la forme {A,B} ('VRAI') ou pas ('FAUX') ?                                            */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        D E F I N I T I O N   D E S   F I C H I E R S  :                                                                           */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#include  xrv/ARITHMET.1d.I"
#include  xrv/ARITHMET.21.I"
#include  xrv/champs_5.41.I"

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        M A C R O S   U T I L E S  :                                                                                               */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
#define   IMAGE_Z                                                                                                                       \
                    IFmageA1                                                                                                            \
                                        /* Image donnant la troisieme dimension...                                                   */
#define   IMAGE_V                                                                                                                       \
                    IFmageA2                                                                                                            \
                                        /* Image donnant le nombre de voisins (introduite le 20150704095038).                        */
#define   IMAGE_Dm                                                                                                                      \
                    IFmageA3
#define   IMAGE_DM                                                                                                                      \
                    IFmageA4
                                        /* Images donnant les distances extremales (introduite le 20150704095038 et complete         */
                                        /* le 20150812093721 par le minimum).                                                        */

#define   CHARGEMENT_IMAGE(image,nom_image,valeur_par_defaut)                                                                           \
                    Bblock                                                                                                              \
                    Test(IFEQ_chaine(nom_image,NOM_PIPE_Local))                                                                         \
                         Bblock                                                                                                         \
                         CALi(IFinitialisation(image,valeur_par_defaut));                                                               \
                                        /* On notera que 'IFinitialisation(...)' ne peut etre fait a priori avant le 'Test(...)'     */ \
                                        /* precedent a cause du cas ou 'nom_image' serait en fait une valeur flottante destinee      */ \
                                        /* a initialiser l'image, ce que ce 'IFinitialisation(...)' execute ensuite "annulerait"...  */ \
                         Eblock                                                                                                         \
                    ATes                                                                                                                \
                         Bblock                                                                                                         \
                         Test(PAS_D_ERREUR(CODE_ERROR(IloadF_image(image,nom_image))))                                                  \
                              Bblock                                                                                                    \
                              Eblock                                                                                                    \
                         ATes                                                                                                           \
                              Bblock                                                                                                    \
                              CALi(IFinitialisation(image,valeur_par_defaut));                                                          \
                                        /* On lira la remarque relative a 'IFinitialisation(...)' ci-dessus...                       */ \
                              Test__CODE_ERREUR__ERREUR07;                                                                              \
                              Eblock                                                                                                    \
                         ETes                                                                                                           \
                         Eblock                                                                                                         \
                    ETes                                                                                                                \
                    Eblock                                                                                                              \
                                        /* Procedure de chargement et/ou initialisation d'une image (introduite le 20150704094141).  */

/*===================================================================================================================================*/
/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        R E C H E R C H E   B I D I M E N S I O N N E L L E   D E   P O I N T S   V O I S I N S   D A N S   U N E   I M A G E  :   */
/*                                                                                                                                   */
/*************************************************************************************************************************************/
BCommande(nombre_d_arguments,arguments)
/*-----------------------------------------------------------------------------------------------------------------------------------*/
     Bblock
#include  xrv/ARITHMET.22.I"
#include  xci/valeurs.03.I"

     DEFV(CHAR,INIT(POINTERc(nom_imageA),NOM_PIPE_Local));
     DEFV(CHAR,INIT(POINTERc(nom_imageZ),NOM_PIPE_Local));
     DEFV(CHAR,INIT(POINTERc(nom_imageV),NOM_PIPE_Local));
     DEFV(CHAR,INIT(POINTERc(nom_imageDm),NOM_PIPE_Local));
     DEFV(CHAR,INIT(POINTERc(nom_imageDM),NOM_PIPE_Local));
                                        /* Nom des images.                                                                           */

     DEFV(genere_p,INIT(niveau_des_points,NIVEAU_DES_POINTS));
                                        /* Niveau des points a etudier...                                                            */
     DEFV(Float,INIT(coordonnee_Z,COORDONNEE_Z));
                                        /* Coordonnee 'Z' par defaut (dans le cas bidimensionnel).                                   */

     DEFV(Positive,INIT(nombre_de_voisins_cherches,NOMBRE_DE_VOISINS_CHERCHES));
                                        /* Nombre de voisins recherches.                                                             */
     DEFV(Positive,INIT(nombre_maximal_de_points_a_tester,NOMBRE_MAXIMAL_DE_POINTS_A_TESTER));
                                        /* Nombre maximal de points a tester autour de chaque point de 'niveau_des_points'.          */
     DEFV(Float,INIT(distance_minimale_entre_deux_points,DISTANCE_MINIMALE_ENTRE_DEUX_POINTS));
     DEFV(Float,INIT(distance_maximale_entre_deux_points,DISTANCE_MAXIMALE_ENTRE_DEUX_POINTS));
                                        /* Distances extremales entre deux points voisins (le minimum a ete introduit                */
                                        /* 20150812093721).                                                                          */

     DEFV(Logical,INIT(trier_les_deux_points_dans_un_couple,TRIER_LES_DEUX_POINTS_DANS_UN_COUPLE));
                                        /* Faut-il trier les deux points d'un couple {A,B} de facon a ce que {B,A} apparaissent      */
                                        /* sous la forme {A,B} ('VRAI') ou pas ('FAUX') ?                                            */
     /*..............................................................................................................................*/
     GET_ARGUMENTSi(nombre_d_arguments
                   ,BLOC(PROCESS_ARGUMENT_I("nombre_elements=""ne=",nombre_d_elements
                                           ,BLOC(VIDE;)
                                           ,BLOC(Bblock
                                                 PRINT_AVERTISSEMENT("'ne=' doit etre defini avant toute entree de fichiers");
                                                 Eblock
                                                 )
                                            );

                         PROCESS_ARGUMENTS_DE_DEFINITION_DES_FICHIERS_01;

                         GET_ARGUMENT_C("imageA=""A=",nom_imageA);
                         GET_ARGUMENT_C("imageZ=""Z=",nom_imageZ);
                         GET_ARGUMENT_C("imageV=""V=",nom_imageV);
                         GET_ARGUMENT_C("imageDm=""Dm=",nom_imageDm);
                         GET_ARGUMENT_C("imageDM=""DM=",nom_imageDM);

                         GET_ARGUMENT_P("niveau=""n=",niveau_des_points);
                         GET_ARGUMENT_F("coordonnee_Z=""cZ=",coordonnee_Z);

                         GET_ARGUMENT_I("nombre_voisins=""nv=",nombre_de_voisins_cherches);
                         GET_ARGUMENT_I("nombre_points=""np=",nombre_maximal_de_points_a_tester);
                         GET_ARGUMENT_F("distance_minimale=""dm=",distance_minimale_entre_deux_points);
                         GET_ARGUMENT_F("distance_maximale=""dM=",distance_maximale_entre_deux_points);

                         GET_ARGUMENT_L("trier_couple=""trier=""tc=",trier_les_deux_points_dans_un_couple);
                         )
                    );

     CHARGEMENT_IMAGE(IMAGE_Z,nom_imageZ,coordonnee_Z);
     CHARGEMENT_IMAGE(IMAGE_V,nom_imageV,nombre_de_voisins_cherches);
     CHARGEMENT_IMAGE(IMAGE_Dm,nom_imageDm,distance_minimale_entre_deux_points);
     CHARGEMENT_IMAGE(IMAGE_DM,nom_imageDM,distance_maximale_entre_deux_points);

     Test(PAS_D_ERREUR(CODE_ERROR(Iload_image(ImageA,nom_imageA))))
          Bblock
          begin_image
               Bblock
               Test(IFEQ(load_point(ImageA,X,Y),niveau_des_points))
                    Bblock
                    DEFV(Float,INIT(coordonnee_Z1,loadF_point(IMAGE_Z,X,Y)));
                    DEFV(Float,INIT(nombre_local_de_voisins_cherches,loadF_point(IMAGE_V,X,Y)));
                    DEFV(Float,INIT(distance_minimale_locale_entre_deux_points,loadF_point(IMAGE_Dm,X,Y)));
                    DEFV(Float,INIT(distance_maximale_locale_entre_deux_points,loadF_point(IMAGE_DM,X,Y)));
                                        /* Definition des donnees locales au point courant {X,Y}...                                  */

                    DEFV(pointI_2D,point_courant);
                    SPIRALE_DEFINITION
                                        /* Donnees de generation d'une spirale de parcours d'une image.                              */

                    DEFV(Int,INIT(nombre_de_voisins_trouves,ZERO));
                    DEFV(Int,INIT(nombre_de_points_testes,ZERO));
                                        /* Compteurs divers...                                                                       */

                    SPIRALE_VALIDATION;
                    INITIALISATION_POINT_2D(point_courant,X,Y);

                    Tant(IFET(IFLT(nombre_de_points_testes,nombre_maximal_de_points_a_tester)
                             ,IFLT(nombre_de_voisins_trouves,nombre_local_de_voisins_cherches)
                              )
                         )
                         Bblock
                         Test(IFET(IFEQ(ASD1(point_courant,x),X),IFEQ(ASD1(point_courant,y),Y)))
                              Bblock
                                        /* Cas ou l'on est sur le point de depart {X,Y} qui ne peut donc etre son propre voisin...   */
                              Eblock
                         ATes
                              Bblock
                              Test(TEST_DANS_L_IMAGE(ASD1(point_courant,x),ASD1(point_courant,y)))
                                   Bblock
                                   Test(IFEQ(load_point(ImageA,ASD1(point_courant,x),ASD1(point_courant,y)),niveau_des_points))
                                        Bblock
                                        /* Cas ou le point courant de la spirale est un "bon" voisin du point courant {X,Y} de       */
                                        /* l'image :                                                                                 */
                                        DEFV(Float,INIT(coordonnee_X1,_____cNORMALISE_OX(X)));
                                        DEFV(Float,INIT(coordonnee_Y1,_____cNORMALISE_OY(Y)));
                                        DEFV(Float,INIT(coordonnee_X2,_____cNORMALISE_OX(ASD1(point_courant,x))));
                                        DEFV(Float,INIT(coordonnee_Y2,_____cNORMALISE_OY(ASD1(point_courant,y))));
                                        DEFV(Float,INIT(coordonnee_Z2
                                                       ,loadF_point(IMAGE_Z,ASD1(point_courant,x),ASD1(point_courant,y))
                                                        )
                                             );

#include  xrv/PointsVoisins_2D.01.I"
                                        EDITION_D_UN_POINT_VOISIN;
                                        /* Introduit le 20150809091459 sous cette forme...                                           */
                                        Eblock
                                   ATes
                                        Bblock
                                        Eblock
                                   ETes
                                   Eblock
                              ATes
                                   Bblock
                                   Eblock
                              ETes
                              Eblock
                         ETes

                         SPIRALE_INITIALISATION;
                                        /* Initialisation dynamique de 'spirale_nombre_de_points_a_traiter'.                         */
                         SPIRALE_DEPLACEMENT(ASD1(point_courant,x),ASD1(point_courant,y));
                                        /* Deplacement du point courant de la spirale...                                             */
                                        /* ATTENTION : on n'utilise pas 'SPIRALE_DEPLACEMENT_ET_PARCOURS(...)' afin de garantir la   */
                                        /* terminaison du processus 'Tant(...)'.                                                     */
                         SPIRALE_PARCOURS;
                                        /* Parcours de la spirale avec rotation eventuelle de PI/2 du bras courant...                */

                         INCR(nombre_de_points_testes,I);
                                        /* Comptage des points testes (meme ceux qui sont hors album et ce afin de ne pas creer      */
                                        /* d'effets de bord...).                                                                     */
                         Eblock
                    ETan
                    Eblock
               ATes
                    Bblock
                    Eblock
               ETes
               Eblock
          end_image
          Eblock
     ATes
          Bblock
          Test__CODE_ERREUR__ERREUR07;
          Eblock
     ETes

     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.