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
| function [Is,x,y,I2]= proj2222(filename)
close all
figmain = figure
set( figmain , 'position' , [ 10, 10 ,4500 ,4500 ])
text1 = uicontrol( figmain , 'style' , 'text' , 'position' , [10,1000,170,30] ,...
'string' , 'Hello' , 'fontsize' , 15 )
rep = 'C:\Thomas';
ext = '*.jpg';
chemin = fullfile(rep,ext);
list = dir(chemin);
n=numel(list);
for n = 1:numel(list)
I = imread(fullfile(rep, list(n).name), ext(3:end));
%position of pushbutton
if n<=20
pos = [10 1000-(45*n) 60 30 ];
elseif n>=21 && n<=40
pos = [360 1000-(45*(n-20)) 60 30 ];
elseif n>=41 && n<=60
pos = [710 1000-(45*(n-40)) 60 30 ];
elseif n>=61 && n<=80
pos = [1060 1000-(45*(n-60)) 60 30 ];
elseif n>=81
pos = [1410 1000-(45*(n-80)) 60 30 ];
end
%unable button if no flaw
if length(x)<1 || length(y)<1
bpnf = uicontrol ( figmain , 'style' , 'push' , 'position' , pos,...
'string' , 'no flaw' , 'callback' , 'plot(T,X)' );
set(bpnf , 'enable' , 'off' )
%ceate able pushbuton if there is flaw
else
%find the position and size of the flaw following x and y
x( x>500 ) = []
SizeX=x(1,1)-x(length(x),1);
Posx=(x((length(x)/2),1)-20)*Sx/400;
y( y>700 ) = []
SizeY=y(1,1)-y(length(y),1);
Posy=(y((length(y)/2),1)-21)*Sy1/638;
Posy=Posy-(Sy1-Sy2);
%Define position and print associate the text with the flaw size/position
if n<=20
pos2 = [100 1015-(45*n) 95 15 ];
elseif n>=21 && n<=40
pos2 = [450 1015-(45*(n-20)) 95 15 ];
elseif n>=41 && n<=60
pos2 = [800 1015-(45*(n-40)) 95 15 ];
elseif n>=61 && n<=80
pos2 = [1150 1015-(45*(n-60)) 95 15 ];
elseif n>=81
pos2 = [1500 1015-(45*(n-80)) 95 15 ];
end
if n<=20
pos3 = [100 1000-(45*n) 95 15 ];
elseif n>=21 && n<=40
pos3 = [450 1000-(45*(n-20)) 95 15 ];
elseif n>=41 && n<=60
pos3 = [800 1000-(45*(n-40)) 95 15 ];
elseif n>=61 && n<=80
pos3 = [1150 1000-(45*(n-60)) 95 15 ];
elseif n>=81
pos3 = [1500 1000-(45*(n-80)) 95 15 ];
end
if n<=20
pos4 = [200 1015-(45*n) 95 15 ];
elseif n>=21 && n<=40
pos4 = [550 1015-(45*(n-20)) 95 15 ];
elseif n>=41 && n<=60
pos4 = [900 1015-(45*(n-40)) 95 15 ];
elseif n>=61 && n<=80
pos4 = [1250 1015-(45*(n-60)) 95 15 ];
elseif n>=81
pos4 = [1600 1015-(45*(n-80)) 95 15 ];
end
if n<=20
pos5 = [200 1000-(45*n) 95 15 ];
elseif n>=21 && n<=40
pos5 = [550 1000-(45*(n-20)) 95 15 ];
elseif n>=41 && n<=60
pos5 = [900 1000-(45*(n-40)) 95 15 ];
elseif n>=61 && n<=80
pos5 = [1250 1000-(45*(n-60)) 95 15 ];
elseif n>=81
pos5 = [1600 1000-(45*(n-80)) 95 15 ];
end
textn = uicontrol( figmain ,'style' , 'text' ,'position' , pos2 ,...
'string' , ['Posx=',num2str(Posx),'mm'])
text2n = uicontrol( figmain ,'style' , 'text' ,'position' , pos3 ,...
'string' , ['Posy=',num2str(Posy),'mm'])
text3n = uicontrol( figmain ,'style' , 'text' ,'position' , pos4 ,...
'string' , ['sizeX=',num2str(SizeX),'mm'])
text4n = uicontrol( figmain ,'style' , 'text' ,'position' , pos5 ,...
'string' , ['sizeY=',num2str(SizeY),'mm'])
handle.bpn=num2str(n);
bpn = uicontrol ( figmain ,...
'style' , 'push' ,...
'position' , pos,...
'string' , ['flaw',num2str(n)] ,...
'callback' , @pushbutton );
handle.bpn=num2str(n);
end
end
end |
Partager