Bonjour
j'ai mon interface d'accuei, dans l'une des fonctions défini dans cet interface sera construit une structure de donnée "com" qui contient plusieurs champs. je veux afficher le contenue de l'un des champs de cette structure dans une nouvelle interface. le problème c'est que je n'arrive pas à le faire même en déclarant cette structure comme global. voici mon code de la première interface
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
function Untitled_18_Callback(hObject, eventdata, handles)
% déclaration d'une variable globale com ( structure représentant une composante connexe) utilisable pour toutes les fonctions
% déclarant cette variable comme globale
global com;
global num;
comp=imcomplement(handles.img);
comp=im2bw(comp);
 
%Calcul des composantes connexes
[L,num] = bwlabel(comp,4);
s  = regionprops(L, 'all');
 
for compo=1:num
    [ligne,colonne]=find(L==compo);
    l_min=min(ligne);
    l_max=max(ligne);
    c_min=min(colonne);
    c_max=max(colonne);
    %figure;
    vect_shapes{compo} = imcrop(handles.img,[c_min l_min c_max-c_min l_max-l_min]);
    com(compo).a=vect_shapes{compo};
    com(compo).l_min=l_min;
    com(compo).l_max=l_max;
    com(compo).c_min=c_min;
    com(compo).c_max=c_max;
    com(compo).ul='';
    com(compo).pos='lin';
    com(compo).pri=0;
    com(compo).zonne='';
    com(compo).dom=0;
end
%-------------------- treating component having segment from other
%-------------------- components
for i=1:compo
    h=com(i).a;
    h = (h == 0);
    [E,n]=bwlabel(h,8);
    h = (h == 1);
    if n>1
        b=1;
        for c=1:n
            [ligne,colonne]=find(E==c);
            l_min=min(ligne);
            l_max=max(ligne);
            c_min=min(colonne);
            c_max=max(colonne);
            vt_shapes{c} = imcrop(h,[c_min l_min c_max-c_min l_max-l_min]);
            cm(c).a=vect_shapes{c};
            %figure;imshow(cm(c).a);
            cm(c).l_min=l_min;
            cm(c).l_max=l_max;
            cm(c).c_min=c_min;
            cm(c).c_max=c_max;
        end
        lmin=10000000000000000;
        for c=1:n
            if cm(c).l_min<lmin
                b=c;
                lmin=cm(c).l_min;
 
            end
        end
        for c=1:n
            if c~=b
                h(cm(c).l_min:cm(c).l_max,cm(c).c_min:cm(c).c_max)=0;
            end
        end
        h=(h==0);
        com(i).a=h;
    end
end
% affichage de la formule avec les composantes connexes recadrées
f=figure('Menubar', 'none','color',[1 1 1],'numbertitle','off',...
    'name',' Connected Components');
    set(f,'Units','Normalized','Position',[.3 .2 .5 .5]);
 
imshow(handles.img,'InitialMagnification','fit');
x=num;
for i=1:num
ccs=int2str(i);
[r,c] = find(L==i);
maxr=max(r);
minr=min(r);
maxc=max(c);
minc=min(c);
c=(maxc-2*minc+3/2)/2;
rectangle('position',[minc-1/2,minr-1/2,maxc-minc+1,maxr-minr+1],'edgecolor','r');
hold on;
ccx=minc;
ccy=minr;
text(ccx,ccy,['\color{magenta}' ccs ' '],'BackgroundColor',[.7 .9 .7],'FontSize',9);
%parcours de tous les composantes connexes pour les encadrer
end
 
uicontrol('style','pushbutton','Callback','exit','string','exit','position',[10 30 70 20]);
uicontrol('style','pushbutton','Callback','show_ccx','tag',num2str(x),'string','show the different connected components','position',[10 10 270 20]);
 
% remplissage d'un fichier dataRL_FS contenant les vecteurs
% caractéristique des symboles de la formule à reconnaitre.
fid = fopen('dataRL_FS.arff','w');
 
%Préambule
fprintf(fid,'%s\n\n','@relation ''data''');
fprintf(fid,'%s\n','@attribute rlNH numeric');
fprintf(fid,'%s\n','@attribute r2NH numeric');
fprintf(fid,'%s\n','@attribute r3NH numeric');
fprintf(fid,'%s\n','@attribute r4NH numeric');
fprintf(fid,'%s\n','@attribute r5NH numeric');
 
fprintf(fid,'%s\n','@attribute rlNV numeric');
fprintf(fid,'%s\n','@attribute r2NV numeric');
fprintf(fid,'%s\n','@attribute r3NV numeric');
fprintf(fid,'%s\n','@attribute r4NV numeric');
fprintf(fid,'%s\n','@attribute r5NV numeric');
 
fprintf(fid,'%s\n','@attribute rlND numeric');
fprintf(fid,'%s\n','@attribute r2ND numeric');
fprintf(fid,'%s\n','@attribute r3ND numeric');
fprintf(fid,'%s\n','@attribute r4ND numeric');
fprintf(fid,'%s\n','@attribute r5ND numeric');
 
fprintf(fid,'%s\n','@attribute mH1 numeric');
fprintf(fid,'%s\n','@attribute mH2 numeric');
fprintf(fid,'%s\n','@attribute mC1 numeric');
fprintf(fid,'%s\n','@attribute mC2 numeric');
 
fprintf(fid,'%s\n','@attribute bwb numeric');
 
fprintf(fid,'%s\n','@attribute BLH numeric');
fprintf(fid,'%s\n','@attribute BLV numeric');
fprintf(fid,'%s\n','@attribute BLD1 numeric');
fprintf(fid,'%s\n','@attribute BLD2 numeric');
 
 
fprintf(fid,'%s\n\n','@attribute class {1_9af 2_alif+hamza 3_dal 4_ha 5_hamza 6_na 7_noun 8_sad 9_sin 10_tête_flèche 11_BFO 12_flèche 13_moin 14_mult 15_plus 16_inf 17_sup 18_BFH 19_point_zero 20_un_alif 21_deux 22_trois 23_quatre 24_cinq1 25_cinq2 26_six 27_sept 28_huit 29_neuf 30_cosinus 31_sinus 32_cot1 33_cot2 34_tan1 35_tan2 36_integrale 37_limite1 38_limite2 39_logarithme 40_produit 41_racine 42_par_fer 43_par_ouv 44_somme}');
fprintf(fid,'%s\n','@data');
 
liste = dir('C:\Users\user\Documents\MATLAB\test guide\Interface-RDF_N\Interface-RDF\baseSymboles');
for r = 3:size(liste,1)
    sr=liste(r).name;
  %  rep = strcat('C:\Users\user\Documents\MATLAB\test guide\Interface-RDF_N\Interface-RDF\baseSymboles\',sr);
   % disp(rep);
    %ext = '*.tif';
    %chemin = fullfile(rep,ext);
    %list = dir(chemin);
    for n = 1:num
        img = com(n).a;
        RI=im2bw(img);
        %Descripteur de type Run length : H, V, D
        data=runlengthNH(RI); %nombre de pixel en horizentale
        data=[data runlengthNV(RI)]; %nombre de pixel en verticale
        data=[data runlengthND(RI)]; %nombre de pixel en diagonale
 
        %Descripteur de type Moments de Zernike et centraux
        res1=humoments(RI);
        figNo=false;
        res2=moments(RI,figNo);
        data2=[res1(1) res1(2) res2]; % on prend uniquement les moments de hu d'ordre 1 et 2 
        data=[data data2];
        %Descripteur de type triplets : BWB
        data=[data tripletsBWB(RI)];
 
        %Descripteur de type Bilevel-Coccurrence
        H= graycomatrix(RI, 'offset', [0 1]);%paires horizontales
        V= graycomatrix(RI, 'offset', [-1 0]);%paires verticales
        D1= graycomatrix(RI, 'offset', [-1 -1]);%Diagonales Nord-Ouest
        D2= graycomatrix(RI, 'offset', [-1 1]);%Diagonales Nord-Est
 
        x=[H(1,1) V(1,1) D1(1,1) D2(1,1)];
 
        data=[data x];
 
        fprintf(fid,' %d',data);
        fprintf(fid,' %s\n',sr);
    end
end
 
    fclose(fid);
clear java;
javaaddpath('C:\Program Files\Weka-3-6\weka.jar')
javaaddpath(fullfile(matlabroot,'work','myClassifier.jar'));
[M,X,J]=inmem;
myJava = myClassifier;
b=myJava.test;
[x y]=size(b);
for n = 1:x
        com(n).code=b(n);
end
voici le code de la deuxième fonction
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function show_ccx
global com;
i=get(gcbo,'tag');
num=str2num(i);
for compo=1:num
    %r=rec_symbol(com(compo).a);
    figure('Menubar', 'none','Units','Normalized','position',[.3 .2 .5 .5],'color',[1 1 1],'numbertitle','off',...
    'name',' RIMAF');
    imshow(com(compo).a);
    com(compo).code
    uicontrol('style','edit',...
                'units','normalized',...
                'position',[0.7 0.7 0.3 0.2],...
                'tag',num2str(compo),'string',com(compo).code);%
    uicontrol('style','pushbutton','Callback', 'pushbutton_Callback_code','tag',num2str(compo),'string','Ok');
end
d'avance merci