Bonjour,

Je débute en matlab et je suis entrain de créer une interface graphique. J’ai un problème ou je ne connais pas comment la corriger…

Voila le code que j’utilise:

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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
 
function fig = FM(action)
load FM;
 
if nargin<1,
  action='initialize';
end;
 
if strcmp(action,'initialize'),
   oldFigNumber=watchon;
 
   begin;
 
  figNumber=figure( ...
  'Name','Image and Color Map', ...
  'Color', [.8 .8 .8], ...
  'NumberTitle','off', ...
  'Color', 'black', ...
  'DoubleBuffer', 'on', ...
  'Visible','off');
 
 
h0 = figure('Number','off',...  
	'Name','XXXX', ...
	'PointerShapeCData',mat1, ...
   'Position',[252 286 800 680], ...
   'Tag','Fig1', ...
   'Resize','on', ...
	'UserData',mat2);
hp = uipanel('Parent',h0,'Title','Entrées','FontSize',12,'FontWeight','bold',...
             'Position',[.023 .53 .95 .45]);
hp1 = uipanel('Parent',hp,'Title','Info','FontSize',12,'FontWeight','bold',...
             'Position',[.72 .6 .2 .2]);
hp2 = uipanel('Parent',h0,'Title','Sorties','FontSize',12,'FontWeight','bold',...
             'Position',[.023 .07 .95 .45]);
 
h1 = uicontrol('Parent',hp, ...
   'Units','points', ...
 	'BackgroundColor',[0.5 0.5 0.7], ...
	'ListboxTop',0, ...
   'Position',[30 100 90 100], ...
   'Style','text', ...
   'Tag','StaticText1');
h1 = uicontrol('Parent',hp, ...
   'Units','points', ...
 	'BackgroundColor',[0.5 0.5 0.7], ...
	'ListboxTop',0, ...
   'Position',[425 80 86 40], ...
   'Style','text', ...
   'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
   'Units','points', ...
 	'BackgroundColor',[0.5 0.5 0.7], ...
	'ListboxTop',0, ...
   'Position',[190 1 200 31], ...
   'Style','text', ...
   'Tag','StaticText1');
 
 
Mlistehandle = uicontrol('Parent',hp, ...
   'Units','points', ...
   'BackgroundColor',[1 0.7 0.9], ...
   'Callback','FM(''Selec'')', ...
   'Position',[32 127 86 68], ...
   'String',tab2, ...
   'Style','listbox', ...
   'Tag','Listbox1', ...
   'Value',3);
 
Menuhandle = uicontrol('Parent',hp, ...
   'Units','points', ...
   'BackgroundColor',[0 0 0.25], ...
	'Callback','FM(''bin'')', ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, ...
	'Position',[600 170.25 66.75 19.5], ...
	'String',[''], ...
	'Style','text', ...
	'Tag','StaticText3', ...
   'Value',1)
   ;
h1 = uicontrol('Parent',hp, ...
'Units','points', ...
 'ListboxTop',0, ...
 'Position',[35 105 80 15], ...
 'String','Sélection Images', ...
 'Style','text', ...
 'Tag','StaticText3');
 
lancerhandle = uicontrol('Parent',hp, ...
   'Units','points', ...
	'Callback','FM(''lancer'')', ...
	'ListboxTop',0, ...
	'Position',[433 87  69 26], ...
	'String','Identification', ...
   'Tag','Pushbutton1');
 
infohandle = uicontrol('Parent',h0, ...
   'Units','points', ...
	'Callback','helpwin', ...
	'ListboxTop',0, ...
	'Position',[212 3 69 26], ... 
	'String','Aide', ...
	'Tag','Pushbutton1');
 
quitterhandle = uicontrol('Parent',h0, ...
   'Units','points', ...
	'Callback','close(gcf)', ...
	'ListboxTop',0, ...
	'Position',[299 3 69 26], ...
	'String','Quitter', ...
   'Tag','Pushbutton2');
 
 
hp3 = uipanel('Parent',hp2,'Title','Info','FontSize',12,'FontWeight','bold',...
             'Position',[.72 .5 .2 .2]);
 
h11 = uicontrol('Parent',h0,'FontSize',12,'FontWeight','bold', ...
'Units','points', ...
 'ListboxTop',0, ...
 'Position',[425 420 100 15], ...
 'String','', ...
 'Style','text', ...
 'Tag','texte3');
 
h12 = uicontrol('Parent',h0,'FontSize',12,'FontWeight','bold', ...
'Units','points', ...
 'ListboxTop',0, ...
 'Position',[425 165 100 15], ...
 'String','', ...
 'Style','text', ...
 'Tag','Text4');
 
h13 = uicontrol('Parent',h0,'FontSize',14,'FontWeight','bold', ...
'Units','points', ...
 'ListboxTop',0, ...
 'Position',[35 120 140 40], ...
 'String','', ...
 'Style','text', ...
 'Tag','Text5');
hndlList=[quitterhandle infohandle lancerhandle Menuhandle Mlistehandle];
 passPrmt.handle=hndlList
  passPrmt.clmap=[];
  passPrmt.imgfile=imglist;
  figNumber=gcf;
   set(figNumber,'Visible','off', ...
     'UserData',passPrmt);
 watchoff(oldFigNumber);
  figure(figNumber);
 
im3=imread('Identification.JPG');
axes('position',[.315 .08 .30 .4]);
imshow(im3);  
 
im2=imread('PalmLogo32.JPG');
axes('position',[.27 .54 .4 .41]);
imshow(im2);
 
 
 
elseif strcmp(action,'Selec'),
 
    begin;
   figNumber=gcf
   passPrmt=get(figNumber, 'UserData')
   hndlList=passPrmt.handle
   imglist=passPrmt.imgfile
   popupHndl=hndlList(5)
 
   ClpopupHndl=hndlList(4);
   n=get(popupHndl, 'Value')
   set(ClpopupHndl, 'Value', 1);
  [t1 t2]=size(tab2);
  filename=tab2(n,1:t2);
   pos=findstr(filename,' ');
   [t3 t4]=size(pos);
      if (t4>0) filename=filename(1:pos(1,1)-1);end;
   file=filename
 
   lecture;
im=imrotate(im,-90);
   imshow(im);
   image=im;
 
imshow(im);
 
 
 
 
h=findobj('Tag','texte3');
set(h,'string',file)
 
 
 
   elseif strcmp(action,'lancer'),
   figNumber=gcf;
  passPrmt=get(figNumber, 'UserData');
   hndlList=passPrmt.handle;
   VpopupHndl=hndlList(4);
  begin;
   VpopupHndl=hndlList(5);
   n2=get(VpopupHndl, 'Value')
   [t1 t2]=size(tab2);
  filename=tab2(n2,1:t2)
   pos=findstr(filename,' ')
   [t3 t4]=size(pos);
   if (t4>0) filename=filename(1:pos(1,1)-1);end;
 
   image=filename
  [test,nom]=main(image);
texte=['P:' nom(1:4) 'C:' nom(10:11)];
he=findobj('Tag','Text4');
set(he,'string',texte)
 
if(test==0)
froot = './ImageDroite';
list = dir(sprintf('%s\\*.jpg', froot));
fns = sprintf('%s\\%s', froot, nom);
fprintf(fns);
im3= imread(fns);
axes('position',[.315 .08 .3 .4]);
imageGalerie=imrotate(im3,-90);
imshow(imageGalerie);
else
froot = './ImageGauche';
list = dir(sprintf('%s\\*.jpg', froot));
fns = sprintf('%s\\%s', froot, nom);
fprintf(fns);
im3= imread(fns);
axes('position',[.315 .08 .3 .4]);
imageGalerie=imrotate(im3,-90);
imshow(imageGalerie);
end
y=nom(1:4);
z=image(1:4);
if(strcmp(y,z))
    he1=findobj('Tag','Text5');
    set(he1,'string','Correctement,'ForegroundColor','green')
else
    he1=findobj('Tag','Text5');
    set(he1,'string','Mal,'ForegroundColor','red')end;
 
end
Lors de la première exécution tout va bien et ça marche correctement mais l’ors des prochaines exécutions je n’obtiens pas ce que je veux: mon but c’est à chaque sélection j’affiche l’image sélectionner dans le premier axes et à chaque appuis sur le bouton Exécution j’affiche le résultat dans le deuxième axes; lors de la première sélection tout ça marche mais malheureusement si je veux sélectionner une autre fois une autre image à identifier elle s’affiche dans l’axes de la zone spécifier au résultat ?? Je n’arrive pas à connaitre ou est le problème dans mon code et comment je peux la corriger ??

Merci