bzr branch
http://suren.me/webbzr/normxcorr/trunk
1
by Suren A. Chilingaryan
Initial import |
1 |
% Initialize data
|
2 |
% written by Chris and Dan
|
|
3 |
||
4 |
% Displacement.m allows you to analyze the data you aquiered with the
|
|
5 |
% correlation, fitting or mean routine. It only needs the validx and
|
|
6 |
% validy and can calculate strain from it. Before you start you should
|
|
7 |
% consider cleaning up the data as described in the guide. After that step
|
|
8 |
% you can analyze parts of your data, or the full set. Try to use also the
|
|
9 |
% console command, e.g. if you want to analyze only image 100-110 since
|
|
10 |
% something really interesting happend there, load validx and validy into
|
|
11 |
% your workspace and call
|
|
12 |
% displacement(validx(:,100:110),validy(:,100:110));
|
|
13 |
% In this case displacement only loads the important images and you can
|
|
14 |
% clean this part of your data set.
|
|
15 |
||
16 |
% Changed 3. February 2008
|
|
17 |
||
18 |
||
19 |
function [validx,validy]=displacement(validx,validy); |
|
20 |
||
21 |
%load data in case you did not load it into workspace yet
|
|
22 |
if exist('validx')==0 |
|
23 |
[validxname,Pathvalidx] = uigetfile('*.dat','Open validx.dat'); |
|
24 |
if validxname==0 |
|
25 |
disp('You did not select a file!') |
|
26 |
return
|
|
27 |
end
|
|
28 |
cd(Pathvalidx); |
|
29 |
validx=importdata(validxname,'\t'); |
|
30 |
end
|
|
31 |
if exist('validy')==0 |
|
32 |
[validyname,Pathvalidy] = uigetfile('*.dat','Open validy.dat'); |
|
33 |
if validyname==0 |
|
34 |
disp('You did not select a file!') |
|
35 |
return
|
|
36 |
end
|
|
37 |
cd(Pathvalidy); |
|
38 |
validy=importdata(validyname,'\t'); |
|
39 |
end
|
|
40 |
||
41 |
%define the size of the data set |
|
42 |
sizevalidx=size(validx); |
|
43 |
sizevalidy=size(validy); |
|
44 |
looppoints=sizevalidx(1,1); |
|
45 |
loopimages=sizevalidx(1,2); |
|
46 |
||
47 |
%calculate the displacement relative to the first image in x and y
|
|
48 |
%direction
|
|
49 |
clear displx; |
|
50 |
validxfirst=zeros(size(validx)); |
|
51 |
validxfirst=mean(validx(:,1),2)*ones(1,sizevalidx(1,2)); |
|
52 |
displx=validx-validxfirst; |
|
53 |
clear validxfirst |
|
54 |
clear disply; |
|
55 |
validyfirst=zeros(size(validy)); |
|
56 |
validyfirst=mean(validy(:,1),2)*ones(1,sizevalidy(1,2)); |
|
57 |
disply=validy-validyfirst; |
|
58 |
clear validyfirst |
|
59 |
||
60 |
%Prompt user for type of plotting / visualization
|
|
61 |
selection10 = menu(sprintf('How do you want to visualize your data?'),'3D Mesh Plot of Displacement'... |
|
62 |
,'Full Strain Plots','Strain Measurement between 2 Points','1D Average Strain Measurement',... |
|
63 |
'Rotate Orientation (exchange x and y)','Remove badly tracked marker, one by one (Position)',... |
|
64 |
'Delete multible markers (Position)','Delete markers from displacement vs. position plot',... |
|
65 |
'Delete points moving relative to their neighbours','Select Markers to Analyze ',... |
|
66 |
'Save validx and validy','Average a couple of images','Cancel'); |
|
67 |
||
68 |
% Selection for Cancel - All windows will be closed and you jump back to
|
|
69 |
% the command line
|
|
70 |
if selection10==13 |
|
71 |
close all; |
|
72 |
return
|
|
73 |
end
|
|
74 |
||
75 |
% This selection will average up a specified number of images to reduce the
|
|
76 |
% noise of the data set. I would like to point out that you will need to
|
|
77 |
% average your other sensor data (e.g. load data), too, to match it to your
|
|
78 |
% strain data.
|
|
79 |
if selection10==12 |
|
80 |
prompt = {'How many images would you like to combine as a base image?'}; |
|
81 |
dlg_title = 'Input number of images:'; |
|
82 |
num_lines= 1; |
|
83 |
def = {'5'}; |
|
84 |
answer = inputdlg(prompt,dlg_title,num_lines,def); |
|
85 |
if str2num(cell2mat(answer(1)))==0 |
|
86 |
disp('Get out, you changed your mind?') |
|
87 |
[validx validy]=displacement(validx,validy); |
|
88 |
return
|
|
89 |
else
|
|
90 |
baseimages = str2num(cell2mat(answer(1))); |
|
91 |
if baseimages==[] |
|
92 |
disp('Give me a number, will you?') |
|
93 |
[validx validy]=displacement(validx,validy); |
|
94 |
return
|
|
95 |
end
|
|
96 |
if baseimages>loopimages |
|
97 |
disp('That is too large?!') |
|
98 |
else
|
|
99 |
baseimagemean=mean(validx(:,1:baseimages),2); |
|
100 |
validx(:,1:baseimages-1)=[]; |
|
101 |
validx(:,1)=baseimagemean; |
|
102 |
baseimagemean=mean(validy(:,1:baseimages),2); |
|
103 |
validy(:,1:baseimages-1)=[]; |
|
104 |
validy(:,1)=baseimagemean; |
|
105 |
end
|
|
106 |
end
|
|
107 |
[validx validy]=displacement(validx,validy); |
|
108 |
return
|
|
109 |
end
|
|
110 |
||
111 |
% Save validx and validy, very useful if you cleaned up your dataset. Data
|
|
112 |
% will be saved as -ascii text file. If you send data like this by email
|
|
113 |
% you can reduce the size tremendously by compressing it. Use ZIP or RAR.
|
|
114 |
if selection10==11 |
|
115 |
[FileName,PathName] = uiputfile('validx_corr.dat','Save validx'); |
|
116 |
if FileName==0 |
|
117 |
disp('You did not save your file!') |
|
118 |
[validx validy]=displacement(validx,validy); |
|
119 |
return
|
|
120 |
else
|
|
121 |
cd(PathName) |
|
122 |
save(FileName,'validx','-ascii') |
|
123 |
[FileName,PathName] = uiputfile('validy_corr.dat','Save validy'); |
|
124 |
if FileName==0 |
|
125 |
disp('You did not save your file!') |
|
126 |
[validx validy]=displacement(validx,validy); |
|
127 |
else
|
|
128 |
cd(PathName)
|
|
129 |
save(FileName,'validy','-ascii') |
|
130 |
end
|
|
131 |
[validx validy]=displacement(validx,validy); |
|
132 |
return
|
|
133 |
end
|
|
134 |
end
|
|
135 |
||
136 |
% Select Points from detailed Analysis
|
|
137 |
if selection10==10 |
|
138 |
[validx validy validxbackup validybackup]=ppselection_func(validx,validy); |
|
139 |
if validx==0 |
|
140 |
validx=validxbackup; |
|
141 |
validy=validybackup; |
|
142 |
end
|
|
143 |
if validy==0 |
|
144 |
validx=validxbackup; |
|
145 |
validy=validybackup; |
|
146 |
end
|
|
147 |
[validx validy]=displacement(validx,validy); |
|
148 |
end
|
|
149 |
||
150 |
% Remove markers moving relativ to their neighbours |
|
151 |
if selection10==9 |
|
152 |
[validx,validy,displx,disply]=delete_jumpers(validx,validy,displx,disply); |
|
153 |
[validx validy]=displacement(validx,validy); |
|
154 |
end
|
|
155 |
||
156 |
% Remove markers from the displacement vs. position plot |
|
157 |
if selection10==8 |
|
158 |
[validx,validy,displx,disply]=removepoints_func(validx,validy,displx,disply); |
|
159 |
[validx validy]=displacement(validx,validy); |
|
160 |
end
|
|
161 |
||
162 |
% Remove bad points |
|
163 |
if selection10==7 |
|
164 |
[validx,validy]=removepoints_func2(validx,validy); |
|
165 |
[validx validy]=displacement(validx,validy); |
|
166 |
end
|
|
167 |
||
168 |
% Remove bad points |
|
169 |
if selection10==6 |
|
170 |
[validx validy]=removepoints_func3(validx,validy); |
|
171 |
[validx validy]=displacement(validx,validy); |
|
172 |
end
|
|
173 |
||
174 |
% Rotate Matrix |
|
175 |
if selection10==5 |
|
176 |
[validx, validy]=rotatematrix(validx,validy); |
|
177 |
[validx validy]=displacement(validx,validy); |
|
178 |
end
|
|
179 |
||
180 |
% 1D Strain plot using average strains for ELASTIC STRAIN only |
|
181 |
if selection10==4 |
|
182 |
[validx validy]=strain_1D_average_func(validx, validy,displx,disply); |
|
183 |
[validx validy]=displacement(validx,validy); |
|
184 |
end
|
|
185 |
||
186 |
% 1D Strain plot |
|
187 |
if selection10==3 |
|
188 |
[validx, validy,displx,disply]=strain_1D_2Points_func(validx, validy,displx,disply); |
|
189 |
[validx validy]=displacement(validx,validy); |
|
190 |
end
|
|
191 |
||
192 |
% Fast plotting, cropping needed for polynomial fit |
|
193 |
if selection10==2 |
|
194 |
[validx, validy,displx,disply]=polyfit3D(validx, validy,displx,disply); |
|
195 |
[validx validy]=displacement(validx,validy); |
|
196 |
end
|
|
197 |
||
198 |
% 3D Mesh Plotting |
|
199 |
if selection10==1 |
|
200 |
if sizevalidx(1,1)>2 |
|
201 |
[validx, validy,displx,disply]=meshplot(validx,validy,displx,disply); |
|
202 |
else
|
|
203 |
disp('You need at least three markers to display the 3D-plot')
|
|
204 |
msgbox('You need at least three markers to display the 3D-plot','3D-Plot','warn'); |
|
205 |
end
|
|
206 |
[validx validy]=displacement(validx,validy); |
|
207 |
end
|
|
208 |
||
209 |
%---------------------------------
|
|
210 |
||
211 |
function [validx,validy,displx,disply]=delete_jumpers(validx,validy,displx,disply); |
|
212 |
||
213 |
% written by Chris
|
|
214 |
||
215 |
% This is a filter which helps to find jumpy data points which are
|
|
216 |
% oscillating or stop moving.
|
|
217 |
% The Filter starts by finding the next 10 datapoint neighbours
|
|
218 |
% (num_neighbours), calculates their mean position and then plots the
|
|
219 |
% difference between each data point and its neighbours versus image
|
|
220 |
% number. If a data point is jumping around it will show up as a spike. But
|
|
221 |
% be careful, one bad one will also affect his neighbours, therefore its
|
|
222 |
% worthwhile to use this filter step by step.
|
|
223 |
||
224 |
% Changed 3. February 2008
|
|
225 |
||
226 |
num_neighbours=10; |
|
227 |
||
228 |
doitonemoretime=1 |
|
229 |
||
230 |
while doitonemoretime==1 |
|
231 |
% defining variables
|
|
232 |
sizevalidx=size(validx); |
|
233 |
sizevalidy=size(validy); |
|
234 |
looppoints=sizevalidx(1,1); |
|
235 |
loopimages=sizevalidx(1,2); |
|
236 |
||
237 |
% clear the used ones
|
|
238 |
clear validxtemp |
|
239 |
clear validytemp |
|
240 |
clear meandistancetemp |
|
241 |
clear sizevalidxtemp |
|
242 |
clear sizevalidytemp |
|
243 |
clear looppointstemp |
|
244 |
clear loopimagestemp |
|
245 |
clear max_distance |
|
246 |
clear min_distance |
|
247 |
clear dist_matrix |
|
248 |
clear dist_sort |
|
249 |
clear dist_index |
|
250 |
clear meandistance |
|
251 |
tic
|
|
252 |
% calculate the distance to the next data points |
|
253 |
% dist_matrix=zeros(looppoints,looppoints);
|
|
254 |
meandistance=zeros(sizevalidx); |
|
255 |
||
256 |
g=waitbar(0,'Processing the markers...'); |
|
257 |
for i=1:looppoints |
|
258 |
waitbar(i/looppoints); |
|
259 |
dist_matrix=(((validx(:,1)-validx(i,1)).^2+(validy(:,1)-validy(i,1)).^2).^(0.5))'; |
|
260 |
% end
|
|
261 |
||
262 |
% find the next neighbours by indexing the ones closest
|
|
263 |
[dist_sort, dist_index]=sort(dist_matrix); |
|
264 |
||
265 |
% take the mean position of the closest data points of each for all
|
|
266 |
% images
|
|
267 |
meandistance(i,:)= validx(i,:)-mean(validx(dist_index(2:num_neighbours),:),1); |
|
268 |
max_distance(i)= max(diff(meandistance(i,:)-meandistance(i,1))); |
|
269 |
min_distance(i)= min(diff(meandistance(i,:)-meandistance(i,1))); |
|
270 |
end
|
|
271 |
close(g)
|
|
272 |
toc
|
|
273 |
for i=1:looppoints |
|
274 |
plot(diff(meandistance(i,:)-meandistance(i,1))) |
|
275 |
hold on |
|
276 |
end
|
|
277 |
toc
|
|
278 |
% Select an upper and lower boundary
|
|
279 |
xlabel('Image number[ ]') |
|
280 |
ylabel('Relative marker dispacement [Pixels]') |
|
281 |
title(sprintf('Define the upper and lower bound by clicking above and below the valid points')) |
|
282 |
marker_pt=(ginput(1)); |
|
283 |
x_mark(1,1) = marker_pt(1); |
|
284 |
y_mark(1,1) = marker_pt(2); |
|
285 |
plot([1;loopimages],[y_mark(1,1);y_mark(1,1)],'r'); |
|
286 |
||
287 |
title(sprintf('Define the upper and lower bound by clicking above and below the valid points')) |
|
288 |
marker_pt=(ginput(1)); |
|
289 |
x_mark(1,2) = marker_pt(1); |
|
290 |
y_mark(1,2) = marker_pt(2); |
|
291 |
plot([1;loopimages],[y_mark(1,2);y_mark(1,2)],'r'); |
|
292 |
||
293 |
upperbound=max(y_mark); |
|
294 |
lowerbound=min(y_mark); |
|
295 |
||
296 |
hold off |
|
297 |
||
298 |
validxtemp=validx; |
|
299 |
validytemp=validy; |
|
300 |
meandistancetemp=meandistance; |
|
301 |
||
302 |
||
303 |
validxtemp(find(max_distance>upperbound | min_distance<lowerbound),:)=[]; |
|
304 |
validytemp(find(max_distance>upperbound | min_distance<lowerbound),:)=[]; |
|
305 |
meandistancetemp(find(max_distance>upperbound |min_distance<lowerbound),:)=[]; |
|
306 |
sizevalidxtemp=size(validxtemp); |
|
307 |
sizevalidytemp=size(validytemp); |
|
308 |
looppointstemp=sizevalidxtemp(1,1); |
|
309 |
loopimagestemp=sizevalidxtemp(1,2); |
|
310 |
||
311 |
for i=1:looppointstemp |
|
312 |
plot(diff(meandistancetemp(i,:)-meandistancetemp(i,1))) |
|
313 |
hold on |
|
314 |
end
|
|
315 |
plot([1;loopimages],[y_mark(1,1);y_mark(1,1)],'r'); |
|
316 |
plot([1;loopimages],[y_mark(1,2);y_mark(1,2)],'r'); |
|
317 |
||
318 |
hold off |
|
319 |
||
320 |
selection_filter = menu('Do you like the result?','Take it as is','Want to select more','Try again','Cancel'); |
|
321 |
if selection_filter==1 |
|
322 |
validx=validxtemp; |
|
323 |
validy=validytemp; |
|
324 |
doitonemoretime=0; |
|
325 |
elseif selection_filter==2 |
|
326 |
validx=validxtemp; |
|
327 |
validy=validytemp; |
|
328 |
doitonemoretime=1; |
|
329 |
elseif selection_filter==3 |
|
330 |
doitonemoretime=1; |
|
331 |
elseif selection_filter==4 |
|
332 |
return
|
|
333 |
end
|
|
334 |
end
|
|
335 |
||
336 |
%---------------------------------
|
|
337 |
% Rotate Matrix
|
|
338 |
% written by Chris
|
|
339 |
function [validx, validy]=rotatematrix(validx,validy); |
|
340 |
validxrot=validx; |
|
341 |
clear validx; |
|
342 |
validyrot=validy; |
|
343 |
clear validy; |
|
344 |
validy=validxrot; |
|
345 |
validx=validyrot; |
|
346 |
||
347 |
||
348 |
%---------------------------------
|
|
349 |
% Delete points from the displacement plot
|
|
350 |
% written by Chris
|
|
351 |
function [validx,validy,displx,disply] = removepoints_func(validx,validy,displx,disply) ; %delete points |
|
352 |
||
353 |
close all |
|
354 |
||
355 |
if exist('validx')==0 |
|
356 |
[validx,Pathvalidx] = uigetfile('*.mat; *.txt','Open validx.mat or validx.txt'); |
|
357 |
cd(Pathvalidx); |
|
358 |
validx=importdata(validx,'\t'); |
|
359 |
[validy,Pathvalidy] = uigetfile('*.mat;*.txt','Open validy.mat or validy.txt'); |
|
360 |
cd(Pathvalidy); |
|
361 |
validy=importdata(validy,'\t'); |
|
362 |
end
|
|
363 |
||
364 |
selectremove1 = menu(sprintf('Do you want to delete makers?'),'Yes','No'); |
|
365 |
if selectremove1==2 |
|
366 |
return
|
|
367 |
end
|
|
368 |
||
369 |
% if yes
|
|
370 |
if selectremove1==1 |
|
371 |
||
372 |
sizevalidx=size(validx); |
|
373 |
sizevalidy=size(validy); |
|
374 |
||
375 |
selectionremove2=selectremove1; |
|
376 |
counter=0 |
|
377 |
sizevalidx=size(validx); |
|
378 |
looppoints=sizevalidx(1,1); |
|
379 |
loopimages=sizevalidx(1,2); |
|
380 |
defaultimage=loopimages |
|
381 |
numberbadpoints=0 |
|
382 |
||
383 |
while selectionremove2==1 |
|
384 |
counter=counter+1 |
|
385 |
clear xplot |
|
386 |
clear sizevalidx |
|
387 |
clear selectremove11 |
|
388 |
clear selection2 |
|
389 |
% clear badpoints
|
|
390 |
||
391 |
sizevalidx=size(validx); |
|
392 |
looppoints=sizevalidx(1,1); |
|
393 |
loopimages=sizevalidx(1,2); |
|
394 |
||
395 |
% update temporary matrices
|
|
396 |
validxtemp=validx; |
|
397 |
validytemp=validy; |
|
398 |
displxtemp=displx; |
|
399 |
displytemp=disply; |
|
400 |
||
401 |
% get the image number from which the bad points will be chosen
|
|
402 |
prompt = {'From which image do you want to delete markers?'}; |
|
403 |
dlg_title = 'Marker removal'; |
|
404 |
num_lines= 1; |
|
405 |
if numberbadpoints==0 |
|
406 |
defaultimage=loopimages |
|
407 |
end
|
|
408 |
if numberbadpoints~0 |
|
409 |
defaultimage=numberbadpoints |
|
410 |
end
|
|
411 |
def = {num2str(defaultimage)}; |
|
412 |
answer = inputdlg(prompt,dlg_title,num_lines,def); |
|
413 |
numberbadpoints = str2num(cell2mat(answer(1,1))); |
|
414 |
if numberbadpoints>loopimages |
|
415 |
numberbadpoints=loopimages |
|
416 |
end
|
|
417 |
if numberbadpoints<1 |
|
418 |
numberbadpoints=1 |
|
419 |
end
|
|
420 |
||
421 |
% displx(:,1)=-validx(:,1)+validx(:,numberbadpoints); |
|
422 |
% disply(:,1)=-validy(:,1)+validy(:,numberbadpoints);
|
|
423 |
||
424 |
plot(validx(:,numberbadpoints),displx(:,numberbadpoints),'o'); |
|
425 |
xlabel('position [pixel]') |
|
426 |
ylabel('displacement [pixel]') |
|
427 |
title(['Displacement versus position',sprintf(' (Current image #: %1g)',numberbadpoints)]); |
|
428 |
||
429 |
% validxtemp=validx;
|
|
430 |
% validytemp=validy;
|
|
431 |
displxtemp=displx; |
|
432 |
validxdelete=validxtemp; |
|
433 |
validydelete=validytemp; |
|
434 |
displxdelete=displxtemp; |
|
435 |
displydelete=displytemp; |
|
436 |
||
437 |
title(sprintf('Define the region of interest. \n All points ouside that region will be deleted')) |
|
438 |
||
439 |
[xgrid,ygrid]=ginput(2); |
|
440 |
x(1,1) = xgrid(1); |
|
441 |
x(1,2) = xgrid(2); |
|
442 |
y(1,1) = ygrid(2); |
|
443 |
y(1,2) = ygrid(1); |
|
444 |
||
445 |
deletepoints=find(validxdelete(:,numberbadpoints)>min(x) & validxdelete(:,numberbadpoints)<max(x) & displxdelete(:,numberbadpoints)<max(y) & displxdelete(:,numberbadpoints)>min(y)); |
|
446 |
[loopnum one]=size(deletepoints); |
|
447 |
||
448 |
validxdelete(deletepoints,:)=[]; |
|
449 |
validydelete(deletepoints,:)=[]; |
|
450 |
||
451 |
||
452 |
% update temporary data matrices; delete bad points
|
|
453 |
displxtemp(deletepoints,:)=[]; |
|
454 |
displytemp(deletepoints,:)=[]; |
|
455 |
validxtemp(deletepoints,:)=[]; |
|
456 |
validytemp(deletepoints,:)=[]; |
|
457 |
||
458 |
plot(validxtemp(:,numberbadpoints),displxtemp(:,numberbadpoints),'o'); |
|
459 |
||
460 |
% delete point permanently?
|
|
461 |
selectremove3 = menu(sprintf('Do you want to delete these markers permanently?'),'Yes','No'); |
|
462 |
if selectremove3==1 |
|
463 |
displx=displxtemp; |
|
464 |
disply=displytemp; |
|
465 |
validx=validxtemp; |
|
466 |
validy=validytemp; |
|
467 |
end
|
|
468 |
if selectremove3==2 |
|
469 |
displxtemp=displx; |
|
470 |
displytemp=disply; |
|
471 |
validxtemp=validx; |
|
472 |
validytemp=validy; |
|
473 |
end
|
|
474 |
selectremove2 = menu(sprintf('Do you want to mark another bad point?'),'Yes','No'); |
|
475 |
if selectremove2==2 |
|
476 |
clear displx; |
|
477 |
clear disply; |
|
478 |
validxfirst=zeros(size(validx)); |
|
479 |
validxfirst=validx(:,1)*ones(1,sizevalidx(1,2)); |
|
480 |
validyfirst=zeros(size(validy)); |
|
481 |
validyfirst=validy(:,1)*ones(1,sizevalidy(1,2)); |
|
482 |
displx=validx-validxfirst; |
|
483 |
disply=validy-validyfirst; |
|
484 |
return
|
|
485 |
end
|
|
486 |
end
|
|
487 |
||
488 |
end
|
|
489 |
||
490 |
%---------------------------------
|
|
491 |
% Delete single points
|
|
492 |
% written by Chris
|
|
493 |
function [validx,validy]=removepoints_func3(validx,validy); |
|
494 |
||
495 |
%sort out badpoints?
|
|
496 |
||
497 |
selection1 = menu(sprintf('Do you want to mark bad points?'),'Yes','No'); |
|
498 |
if selection1==2 |
|
499 |
close all; |
|
500 |
return
|
|
501 |
end
|
|
502 |
||
503 |
% if yes
|
|
504 |
if selection1==1 |
|
505 |
selection2=selection1; |
|
506 |
% figure
|
|
507 |
counter=0 |
|
508 |
sizevalidx=size(validx); |
|
509 |
looppoints=sizevalidx(1,1); |
|
510 |
loopimages=sizevalidx(1,2)-1; |
|
511 |
defaultimage=loopimages |
|
512 |
numberbadpoints=0 |
|
513 |
||
514 |
while selection2==1 |
|
515 |
counter=counter+1 |
|
516 |
clear xplot |
|
517 |
clear sizevalidx |
|
518 |
clear selection1 |
|
519 |
clear selection2 |
|
520 |
clear badpoints |
|
521 |
||
522 |
sizevalidx=size(validx); |
|
523 |
looppoints=sizevalidx(1,1); |
|
524 |
loopimages=sizevalidx(1,2)-1; |
|
525 |
||
526 |
clear displx; |
|
527 |
validxfirst=zeros(size(validx)); |
|
528 |
validxfirst=validx(:,1)*ones(1,sizevalidx(1,2)); |
|
529 |
displx=validx-validxfirst; |
|
530 |
||
531 |
% update temporary matrices
|
|
532 |
displxtemp=displx; |
|
533 |
validxtemp=validx; |
|
534 |
validytemp=validy; |
|
535 |
% resnormxtemp=resnormx;
|
|
536 |
||
537 |
% get the image number from which the bad points will be chosen
|
|
538 |
prompt = {'From which image do you want to choose the bad points?'}; |
|
539 |
dlg_title = 'Bad points removal'; |
|
540 |
num_lines= 1; |
|
541 |
if numberbadpoints==0 |
|
542 |
defaultimage=loopimages |
|
543 |
end
|
|
544 |
if numberbadpoints~0 |
|
545 |
defaultimage=numberbadpoints |
|
546 |
end
|
|
547 |
def = {num2str(defaultimage)}; |
|
548 |
answer = inputdlg(prompt,dlg_title,num_lines,def); |
|
549 |
numberbadpoints = str2num(cell2mat(answer(1,1))); |
|
550 |
if numberbadpoints>loopimages |
|
551 |
numberbadpoints=loopimages |
|
552 |
end
|
|
553 |
if numberbadpoints<1 |
|
554 |
numberbadpoints=1 |
|
555 |
end
|
|
556 |
||
557 |
gridsizex=10*round(min(min(validx))/10):10:10*round(max(max(validx))/10); |
|
558 |
gridsizey=10*round(min(min(validy))/10):10:10*round(max(max(validy))/10); |
|
559 |
[XI,YI]=meshgrid(gridsizex,gridsizey); |
|
560 |
ZI=griddata(validx(:,numberbadpoints),validy(:,numberbadpoints),displx(:,numberbadpoints),XI,YI,'cubic'); |
|
561 |
epsxx = gradient(ZI,10,10); |
|
562 |
||
563 |
% find max and min point and point them out
|
|
564 |
mindisplx=find(displx(:,numberbadpoints)==min(displx(:,numberbadpoints))); |
|
565 |
maxdisplx=find(displx(:,numberbadpoints)==max(displx(:,numberbadpoints))); |
|
566 |
||
567 |
||
568 |
pcolor(XI,YI,epsxx); |
|
569 |
axis('equal') |
|
570 |
caxis([min(min(epsxx)) max(max(epsxx))]) |
|
571 |
colorbar
|
|
572 |
shading('interp')
|
|
573 |
hold on |
|
574 |
plot3(validx(:,numberbadpoints),validy(:,numberbadpoints),displx(:,numberbadpoints)-min(displx(:,numberbadpoints)),'o','MarkerEdgeColor','k','MarkerFaceColor','g'), hold on; |
|
575 |
plot3(validx(mindisplx,numberbadpoints),validy(mindisplx,numberbadpoints),displx(mindisplx,numberbadpoints)-min(displx(:,numberbadpoints)),'o','MarkerEdgeColor','y','MarkerFaceColor','b') |
|
576 |
plot3(validx(maxdisplx,numberbadpoints),validy(maxdisplx,numberbadpoints),displx(maxdisplx,numberbadpoints)-min(displx(:,numberbadpoints)),'o','MarkerEdgeColor','y','MarkerFaceColor','r') |
|
577 |
axis([min(min(XI))-10 max(max(XI))+10 min(min(YI))-10 max(max(YI))+10]) |
|
578 |
drawnow; |
|
579 |
hold off |
|
580 |
||
581 |
% get the bad point position
|
|
582 |
||
583 |
title(sprintf('Click on the bad point',counter)) |
|
584 |
[badpoint]=ginput(1); |
|
585 |
badpointx = badpoint(1,1); |
|
586 |
badpointy = badpoint(1,2); |
|
587 |
||
588 |
% find the point matching the given position
|
|
589 |
wherethehellisthispoint=abs(validx(:,numberbadpoints)-badpoint(1,1))+abs(validy(:,numberbadpoints)-badpoint(1,2)); |
|
590 |
badpointnum=find(wherethehellisthispoint==min(wherethehellisthispoint)); |
|
591 |
||
592 |
% update temporary data matrices; delete bad points
|
|
593 |
||
594 |
displxtemp(badpointnum,:)=[]; |
|
595 |
validxtemp(badpointnum,:)=[]; |
|
596 |
validytemp(badpointnum,:)=[]; |
|
597 |
mindisplx=find(displxtemp(:,numberbadpoints)==min(displxtemp(:,numberbadpoints))); |
|
598 |
maxdisplx=find(displxtemp(:,numberbadpoints)==max(displxtemp(:,numberbadpoints))); |
|
599 |
||
600 |
% update the figure
|
|
601 |
ZI=griddata(validxtemp(:,numberbadpoints),validytemp(:,numberbadpoints),displxtemp(:,numberbadpoints),XI,YI,'cubic'); |
|
602 |
epsxx = gradient(ZI,10,10); |
|
603 |
pcolor(XI,YI,epsxx); |
|
604 |
axis('equal') |
|
605 |
caxis([min(min(epsxx)) max(max(epsxx))]) |
|
606 |
colorbar
|
|
607 |
shading('interp')
|
|
608 |
hold on |
|
609 |
plot3(validxtemp(:,numberbadpoints),validytemp(:,numberbadpoints),displxtemp(:,numberbadpoints),'o','MarkerEdgeColor','k','MarkerFaceColor','g') |
|
610 |
plot3(validxtemp(mindisplx,numberbadpoints),validytemp(mindisplx,numberbadpoints),displxtemp(mindisplx,numberbadpoints)-min(displxtemp(:,numberbadpoints)),'o','MarkerEdgeColor','y','MarkerFaceColor','b') |
|
611 |
plot3(validxtemp(maxdisplx,numberbadpoints),validytemp(maxdisplx,numberbadpoints),displxtemp(maxdisplx,numberbadpoints)-min(displxtemp(:,numberbadpoints)),'o','MarkerEdgeColor','y','MarkerFaceColor','r') |
|
612 |
axis([min(min(XI))-10 max(max(XI))+10 min(min(YI))-10 max(max(YI))+10]) |
|
613 |
drawnow;hold off; |
|
614 |
||
615 |
% delete point permanently?
|
|
616 |
selection3 = menu(sprintf('Do you want to delete this point permanently?'),'Yes','No'); |
|
617 |
if selection3==1 |
|
618 |
displx=displxtemp; |
|
619 |
validx=validxtemp; |
|
620 |
validy=validytemp; |
|
621 |
% resnormx=resnormxtemp;
|
|
622 |
end
|
|
623 |
if selection3==2 |
|
624 |
displxtemp=displx; |
|
625 |
validxtemp=validx; |
|
626 |
validytemp=validy; |
|
627 |
% resnormxtemp=resnormx;
|
|
628 |
end
|
|
629 |
selection2 = menu(sprintf('Do you want to mark another bad point?'),'Yes','No'); |
|
630 |
if selection2==2 |
|
631 |
close all; |
|
632 |
return
|
|
633 |
end
|
|
634 |
||
635 |
end
|
|
636 |
end
|
|
637 |
||
638 |
%---------------------------------
|
|
639 |
% Strain between two markers
|
|
640 |
% written by Chris
|
|
641 |
function [validx, validy,displx,disply] = strain_1D_2Points_func(validx, validy,displx,disply) ; % 1D strain calculation |
|
642 |
||
643 |
sizevalidx=size(validx); |
|
644 |
looppoints=sizevalidx(1,1); |
|
645 |
loopimages=sizevalidx(1,2)-1; |
|
646 |
defaultimage=loopimages; |
|
647 |
numberbadpoints=0; |
|
648 |
clear selection3; selection3=1; |
|
649 |
||
650 |
while selection3==1 |
|
651 |
||
652 |
clear xplot |
|
653 |
clear sizevalidx |
|
654 |
clear selection1 |
|
655 |
clear selection2 |
|
656 |
clear badpoints |
|
657 |
||
658 |
sizevalidx=size(validx); |
|
659 |
looppoints=sizevalidx(1,1); |
|
660 |
loopimages=sizevalidx(1,2)-1; |
|
661 |
||
662 |
% update temporary matrices
|
|
663 |
displxtemp=displx; |
|
664 |
validxtemp=validx; |
|
665 |
validytemp=validy; |
|
666 |
% resnormxtemp=resnormx;
|
|
667 |
||
668 |
% get the image number from which the bad points will be chosen
|
|
669 |
prompt = {'Which image do you want for point selection?'}; |
|
670 |
dlg_title = '1D Strain Plotting'; |
|
671 |
num_lines= 1; |
|
672 |
if numberbadpoints==0 |
|
673 |
defaultimage=loopimages; |
|
674 |
end
|
|
675 |
if numberbadpoints~0 |
|
676 |
defaultimage=numberbadpoints |
|
677 |
end
|
|
678 |
def = {num2str(defaultimage)}; |
|
679 |
answer = inputdlg(prompt,dlg_title,num_lines,def); |
|
680 |
numberbadpoints = str2num(cell2mat(answer(1,1))); |
|
681 |
if numberbadpoints>loopimages |
|
682 |
numberbadpoints=loopimages; |
|
683 |
end
|
|
684 |
if numberbadpoints<1 |
|
685 |
numberbadpoints=1; |
|
686 |
end
|
|
687 |
||
688 |
gridsizex=10*round(min(min(validx))/10):10:10*round(max(max(validx))/10); |
|
689 |
gridsizey=10*round(min(min(validy))/10):10:10*round(max(max(validy))/10); |
|
690 |
[XI,YI]=meshgrid(gridsizex,gridsizey); |
|
691 |
ZI=griddata(validx(:,numberbadpoints),validy(:,numberbadpoints),displx(:,numberbadpoints),XI,YI,'cubic'); |
|
692 |
||
693 |
pcolor(XI,YI,ZI); |
|
694 |
axis('equal') |
|
695 |
caxis([min(min(ZI)) max(max(ZI))]) |
|
696 |
colorbar
|
|
697 |
shading('interp')
|
|
698 |
hold on |
|
699 |
plot3(validx(:,numberbadpoints),validy(:,numberbadpoints),abs(displx(:,numberbadpoints)),'o','MarkerEdgeColor','k','MarkerFaceColor','g'); |
|
700 |
axis([min(min(XI))-10 max(max(XI))+10 min(min(YI))-10 max(max(YI))+10]) |
|
701 |
drawnow; |
|
702 |
||
703 |
% get the bad point position
|
|
704 |
||
705 |
title(sprintf('Click on the two points for strain measurement')) |
|
706 |
[badpoint]=ginput(2); |
|
707 |
badpointx = badpoint(1,1); |
|
708 |
badpointy = badpoint(1,2); |
|
709 |
badpointx2 = badpoint(2,1); |
|
710 |
badpointy2 = badpoint(2,2); |
|
711 |
||
712 |
% find the point matching the given position
|
|
713 |
wherethehellisthispoint=abs(validx(:,numberbadpoints)-badpoint(1,1))+abs(validy(:,numberbadpoints)-badpoint(1,2)); |
|
714 |
badpointnum=find(wherethehellisthispoint==min(wherethehellisthispoint)); |
|
715 |
wherethehellisthispoint2=abs(validx(:,numberbadpoints)-badpoint(2,1))+abs(validy(:,numberbadpoints)-badpoint(2,2)); |
|
716 |
badpointnum2=find(wherethehellisthispoint2==min(wherethehellisthispoint2)); |
|
717 |
||
718 |
||
719 |
% update the figure
|
|
720 |
ZI=griddata(validxtemp(:,numberbadpoints),validytemp(:,numberbadpoints),displxtemp(:,numberbadpoints),XI,YI,'cubic'); |
|
721 |
caxis([min(min(ZI)) max(max(ZI))]) |
|
722 |
plot3(validxtemp(badpointnum,numberbadpoints),validytemp(badpointnum,numberbadpoints),displxtemp(badpointnum,numberbadpoints),'+','MarkerEdgeColor','k','MarkerFaceColor','g') |
|
723 |
plot3(validxtemp(badpointnum2,numberbadpoints),validytemp(badpointnum2,numberbadpoints),displxtemp(badpointnum2,numberbadpoints),'+','MarkerEdgeColor','k','MarkerFaceColor','r') |
|
724 |
hold off; |
|
725 |
axis([min(min(XI))-10 max(max(XI))+10 min(min(YI))-10 max(max(YI))+10]) |
|
726 |
drawnow; |
|
727 |
||
728 |
epsilon1D=(displxtemp(badpointnum,:)-displxtemp(badpointnum2,:))/(validxtemp(badpointnum,1)-validxtemp(badpointnum2,1)); |
|
729 |
epsilonsize=size(epsilon1D); |
|
730 |
figure; plot(1:epsilonsize(1,2),epsilon1D,'.'); |
|
731 |
title(['True strain versus image from two picked points']); |
|
732 |
xlabel('Image number [ ]'); |
|
733 |
ylabel('True Strain [ ]'); |
|
734 |
||
735 |
||
736 |
selection3 = menu(sprintf('Do you want to choose 2 other points?'),'Yes','No'); |
|
737 |
||
738 |
if selection3==2 |
|
739 |
selection40 = menu(sprintf('Do you want to save the data as a text file?'),'Yes','No'); |
|
740 |
if selection40==2 |
|
741 |
return
|
|
742 |
end
|
|
743 |
if selection40==1 |
|
744 |
numimagtemp = [1:epsilonsize(1,2)]'; |
|
745 |
alltemp = [numimagtemp epsilon1D']; |
|
746 |
[FileNameBase,PathNameBase] = uiputfile('','Save file with image# vs. 1Dstrain'); |
|
747 |
cd(PathNameBase) |
|
748 |
save(FileNameBase,'alltemp','-ASCII'); |
|
749 |
% save image_1Dstrain.txt alltemp -ASCII
|
|
750 |
return
|
|
751 |
end
|
|
752 |
end
|
|
753 |
close(gcf)
|
|
754 |
end
|
|
755 |
%---------------------------------
|
|
756 |
% Measure elastic slope
|
|
757 |
% written by Chris
|
|
758 |
function [validx, validy,displx,disply] = strain_1D_average_func(validx, validy,displx,disply) ; % 1D strain calculation |
|
759 |
videoselection = menu(sprintf('Do you want to create a video?'),'Yes','No'); |
|
760 |
if videoselection==1 |
|
761 |
mkdir('videostrain') |
|
762 |
cd('videostrain'); |
|
763 |
Vid='Vid'; |
|
764 |
end
|
|
765 |
selection50=1; |
|
766 |
validx_fit=validx; |
|
767 |
displx_fit=displx; |
|
768 |
minminvalidx=min(min(validx)); |
|
769 |
maxmaxvalidx=max(max(validx)); |
|
770 |
minminvalidy=min(min(validy)); |
|
771 |
maxmaxvalidy=max(max(validy)); |
|
772 |
minmindisplx=min(min(displx)); |
|
773 |
maxmaxdisplx=max(max(displx)); |
|
774 |
h= figure |
|
775 |
while selection50==1 |
|
776 |
% figure
|
|
777 |
[pointnumber imagenumber]=size(displx); |
|
778 |
for i=1:imagenumber; |
|
779 |
plot(validx_fit(:,i),displx_fit(:,i),'o'); |
|
780 |
xdata=validx_fit(:,i); |
|
781 |
ydata=displx_fit(:,i); |
|
782 |
if i==1 |
|
783 |
x(1)=0 |
|
784 |
x(2)=0 |
|
785 |
end
|
|
786 |
[x,resnormx,residual,exitflagx,output] = lsqcurvefit(@linearfit, [x(1) x(2)], xdata, ydata); |
|
787 |
hold on; |
|
788 |
ydatafit=x(1)*xdata+x(2); |
|
789 |
plot(xdata,ydatafit,'r'); |
|
790 |
||
791 |
hold off |
|
792 |
slope(i,:)=[i x(1)]; |
|
793 |
axis([minminvalidx maxmaxvalidx minmindisplx maxmaxdisplx]) |
|
794 |
xlabel('position [pixel]') |
|
795 |
ylabel('displacement [pixel]') |
|
796 |
title(['Displacement versus position',sprintf(' (Current image #: %1g)',i)]); |
|
797 |
drawnow
|
|
798 |
if videoselection==1 |
|
799 |
u=i+10000; |
|
800 |
ustr=num2str(u); |
|
801 |
videoname=[Vid ustr '.jpg'] |
|
802 |
saveas(h,videoname,'jpg') |
|
803 |
end
|
|
804 |
end
|
|
805 |
g1 = figure, plot(slope(:,1),slope(:,2)); |
|
806 |
hold on |
|
807 |
plot(slope(:,1),slope(:,2),'.'); |
|
808 |
xlabel('Image [ ]') |
|
809 |
ylabel('True Strain [ ]') |
|
810 |
title(['True Strain vs. Image #']); |
|
811 |
||
812 |
selection40 = menu(sprintf('Do you want to save the data as file?'),'Yes','No'); |
|
813 |
if selection40==2 |
|
814 |
||
815 |
end
|
|
816 |
if selection40==1 |
|
817 |
alltemp = [slope(:,1) slope(:,2)]; |
|
818 |
[FileNameBase,PathNameBase] = uiputfile('','Save file with image# vs. 1Dstrain'); |
|
819 |
cd(PathNameBase) |
|
820 |
save(FileNameBase,'alltemp','-ASCII'); |
|
821 |
% save image_1Dstrain_avg.txt alltemp -ASCII
|
|
822 |
end
|
|
823 |
||
824 |
selection50 = menu(sprintf('Do you want to analyse a selected area again?'),'Yes','No'); |
|
825 |
if selection50==2 |
|
826 |
clear validx_fit |
|
827 |
clear displx_fit |
|
828 |
return
|
|
829 |
end
|
|
830 |
if selection50==1 |
|
831 |
close(g1) |
|
832 |
plot(validx_fit(:,imagenumber),displx_fit(:,imagenumber),'o'); |
|
833 |
title(['True strain versus image from all markers']); |
|
834 |
xlabel('Image number [ ]'); |
|
835 |
ylabel('True Strain [ ]'); |
|
836 |
prompt = {'Min. x-position:','Max. x-position:'}; |
|
837 |
dlg_title = 'Regime to be analyzed in pixels'; |
|
838 |
num_lines= 1; |
|
839 |
def = {'800','1200'}; |
|
840 |
answer = inputdlg(prompt,dlg_title,num_lines,def); |
|
841 |
minx= str2num(cell2mat(answer(1,1))); |
|
842 |
maxx= str2num(cell2mat(answer(2,1))); |
|
843 |
counter=0 |
|
844 |
clear validx_fit |
|
845 |
clear displx_fit |
|
846 |
selectedmarkers=find(validx(:,imagenumber)>minx & validx(:,imagenumber)<maxx); |
|
847 |
validx_fit=validx(selectedmarkers,:); |
|
848 |
displx_fit=displx(selectedmarkers,:); |
|
849 |
continue
|
|
850 |
end
|
|
851 |
||
852 |
end
|
|
853 |
||
854 |
||
855 |
%---------------------------------
|
|
856 |
% 3D mesh plotting
|
|
857 |
% written by Chris
|
|
858 |
function [validx, validy,displx,disply]=meshplot(validx,validy,displx,disply); |
|
859 |
h=figure; |
|
860 |
sizevalidx=size(validx); |
|
861 |
sizevalidy=size(validy); |
|
862 |
looppoints=sizevalidx(1,1); |
|
863 |
loopimages=sizevalidx(1,2); |
|
864 |
||
865 |
videoselection = menu(sprintf('Do you want to create a video?'),'Yes','No'); |
|
866 |
if videoselection==1 |
|
867 |
mkdir('video') |
|
868 |
cd('video'); |
|
869 |
Vid='Vid'; |
|
870 |
end
|
|
871 |
gridsizex=10*round(min(min(validx))/10):10:10*round(max(max(validx))/10); |
|
872 |
gridsizey=10*round(min(min(validy))/10):10:10*round(max(max(validy))/10); |
|
873 |
[XI,YI]=meshgrid(gridsizex,gridsizey); |
|
874 |
minminvalidx=min(min(validx)); |
|
875 |
maxmaxvalidx=max(max(validx)); |
|
876 |
minminvalidy=min(min(validy)); |
|
877 |
maxmaxvalidy=max(max(validy)); |
|
878 |
minmindisplx=min(min(displx)); |
|
879 |
maxmaxdisplx=max(max(displx)); |
|
880 |
minmindisply=min(min(disply)); |
|
881 |
maxmaxdisply=max(max(disply)); |
|
882 |
for i=1:(loopimages-1) |
|
883 |
ZI=griddata(validx(:,i),validy(:,i),displx(:,i),XI,YI,'cubic'); |
|
884 |
mesh(XI,YI,ZI); hold on |
|
885 |
bottomplot=ones(size(validx))*minmindisplx; |
|
886 |
backyplaneplot=ones(size(validx))*maxmaxvalidy; |
|
887 |
backxplaneplot=ones(size(validx))*minminvalidx; |
|
888 |
plot3(validx(:,i),validy(:,i),displx(:,i),'.b'); |
|
889 |
% plot3(validx(:,i),backyplaneplot(:,i),displx(:,i),'.');
|
|
890 |
plot3(backxplaneplot(:,i),validy(:,i),displx(:,i),'.g'); |
|
891 |
xlabel('x-position [pixel]') |
|
892 |
ylabel('y-position [pixel]') |
|
893 |
zlabel('displacement [pixel]') |
|
894 |
% plot3(validx(:,i),validy(:,i),bottomplot(:,i),'.');
|
|
895 |
hold off |
|
896 |
title(['Displacement versus x-y-position',sprintf(' (Current image #: %1g)',i)]); |
|
897 |
axis([minminvalidx maxmaxvalidx minminvalidy maxmaxvalidy minmindisplx maxmaxdisplx]) |
|
898 |
drawnow
|
|
899 |
if videoselection==1 |
|
900 |
u=i+10000; |
|
901 |
ustr=num2str(u); |
|
902 |
videoname=[Vid ustr '.jpg'] |
|
903 |
saveas(h,videoname,'jpg') |
|
904 |
end
|
|
905 |
end
|
|
906 |
||
907 |
if videoselection==1 |
|
908 |
cd('..') |
|
909 |
end
|
|
910 |
||
911 |
%-------------------------------
|
|
912 |
% polyfit function
|
|
913 |
% written by Dan slightly changed by Chris
|
|
914 |
function [validx, validy,displx,disply]=polyfit3D(validx, validy,displx,disply); |
|
915 |
close all |
|
916 |
plot3dsurface_func(validx,validy,displx); |
|
917 |
||
918 |
%---------------------------------------
|
|
919 |
% Just plot it
|
|
920 |
% written by Dan slightly changed by Chris
|
|
921 |
function plot3dsurface_func(validx,validy,displx,gridstyle,cropxx,cropyy) |
|
922 |
||
923 |
sizevalidx=size(validx); |
|
924 |
looppoints=sizevalidx(1,1); |
|
925 |
loopimages=sizevalidx(1,2); |
|
926 |
gridsizex=10*round(min(min(validx))/10):10:10*round(max(max(validx))/10); |
|
927 |
gridsizey=10*round(min(min(validy))/10):10:10*round(max(max(validy))/10); |
|
928 |
[XI,YI]=meshgrid(gridsizex,gridsizey); |
|
929 |
ZI=griddata(validx(:,1),validy(:,1),displx(:,1),XI,YI,'cubic'); |
|
930 |
ZIsize=size(ZI); |
|
931 |
displcolor = [-7 1]; |
|
932 |
straincolor = [-0.005 0.03]; |
|
933 |
||
934 |
maxminusminvalidx=(max(max(validx))-min(min(validx))); |
|
935 |
maxminusminvalidy=(max(max(validx))-min(min(validy))); |
|
936 |
||
937 |
for i=1:(loopimages-1) |
|
938 |
||
939 |
ZI=griddata(validx(:,i),validy(:,i),displx(:,i),XI,YI,'cubic'); |
|
940 |
ZIsize=size(ZI); |
|
941 |
epsxx = gradient(ZI,(maxminusminvalidx/ZIsize(1,1)),(maxminusminvalidy/ZIsize(1,2))); |
|
942 |
||
943 |
subplot(2,1,1) |
|
944 |
pcolor(XI,YI,ZI) |
|
945 |
axis('equal') |
|
946 |
shading('interp') |
|
947 |
caxis(displcolor) |
|
948 |
h1 = colorbar; |
|
949 |
set(h1, 'PlotBoxAspectRatio',[2.0 10 8.0]) |
|
950 |
set(h1, 'FontSize', 12); |
|
951 |
title(['Raw Displacement in x-direction',sprintf(' (Current image #: %1g)',i)]); |
|
952 |
||
953 |
subplot(2,1,2) |
|
954 |
pcolor(XI,YI,epsxx) |
|
955 |
axis('equal') |
|
956 |
shading('interp') |
|
957 |
caxis(straincolor) |
|
958 |
h1 = colorbar; |
|
959 |
set(h1, 'PlotBoxAspectRatio',[2.0 10 8.0]) |
|
960 |
set(h1, 'FontSize', 12); |
|
961 |
title('Raw Strain in x-direction'); |
|
962 |
||
963 |
drawnow
|
|
964 |
||
965 |
end
|
|
966 |
||
967 |
%--------------------------------------
|
|
968 |
% Delete some markers
|
|
969 |
% written by Chris
|
|
970 |
function [validx,validy] = removepoints_func2(validx,validy) ; %delete points |
|
971 |
||
972 |
if exist('validx')==0 |
|
973 |
[validx,Pathvalidx] = uigetfile('*.mat; *.txt','Open validx.mat or validx.txt'); |
|
974 |
cd(Pathvalidx); |
|
975 |
validx=importdata(validx,'\t'); |
|
976 |
[validy,Pathvalidy] = uigetfile('*.mat;*.txt','Open validy.mat or validy.txt'); |
|
977 |
cd(Pathvalidy); |
|
978 |
validy=importdata(validy,'\t'); |
|
979 |
end
|
|
980 |
||
981 |
||
982 |
selectremove1 = menu(sprintf('Do you want to delete makers?'),'Yes','No'); |
|
983 |
if selectremove1==2 |
|
984 |
||
985 |
return
|
|
986 |
end
|
|
987 |
||
988 |
% if yes
|
|
989 |
if selectremove1==1 |
|
990 |
selectionremove2=selectremove1; |
|
991 |
% figure
|
|
992 |
counter=0 |
|
993 |
sizevalidx=size(validx); |
|
994 |
looppoints=sizevalidx(1,1); |
|
995 |
loopimages=sizevalidx(1,2); |
|
996 |
defaultimage=loopimages |
|
997 |
numberbadpoints=0 |
|
998 |
||
999 |
while selectionremove2==1 |
|
1000 |
counter=counter+1 |
|
1001 |
clear xplot |
|
1002 |
clear sizevalidx |
|
1003 |
clear selectremove11 |
|
1004 |
clear selection2 |
|
1005 |
% clear badpoints
|
|
1006 |
||
1007 |
sizevalidx=size(validx); |
|
1008 |
looppoints=sizevalidx(1,1); |
|
1009 |
loopimages=sizevalidx(1,2); |
|
1010 |
||
1011 |
% update temporary matrices
|
|
1012 |
% displxtemp=displx;
|
|
1013 |
validxtemp=validx; |
|
1014 |
validytemp=validy; |
|
1015 |
% resnormxtemp=resnormx;
|
|
1016 |
||
1017 |
% get the image number from which the bad points will be chosen
|
|
1018 |
prompt = {'From which image do you want to delete markers?'}; |
|
1019 |
dlg_title = 'Marker removal'; |
|
1020 |
num_lines= 1; |
|
1021 |
if numberbadpoints==0 |
|
1022 |
defaultimage=loopimages |
|
1023 |
end
|
|
1024 |
if numberbadpoints~0 |
|
1025 |
defaultimage=numberbadpoints |
|
1026 |
end
|
|
1027 |
def = {num2str(defaultimage)}; |
|
1028 |
answer = inputdlg(prompt,dlg_title,num_lines,def); |
|
1029 |
numberbadpoints = str2num(cell2mat(answer(1,1))); |
|
1030 |
if numberbadpoints>loopimages |
|
1031 |
numberbadpoints=loopimages |
|
1032 |
end
|
|
1033 |
if numberbadpoints<1 |
|
1034 |
numberbadpoints=1 |
|
1035 |
end
|
|
1036 |
||
1037 |
displx(:,1)=-validx(:,1)+validx(:,numberbadpoints); |
|
1038 |
displx(:,1)=displx(:,1)-min(displx(:,1)); |
|
1039 |
||
1040 |
gridsizex=10*round(min(min(validx))/10):10:10*round(max(max(validx))/10); |
|
1041 |
gridsizey=10*round(min(min(validy))/10):10:10*round(max(max(validy))/10); |
|
1042 |
[XI,YI]=meshgrid(gridsizex,gridsizey); |
|
1043 |
ZI=griddata(validx(:,numberbadpoints),validy(:,numberbadpoints),displx(:,1),XI,YI,'cubic'); |
|
1044 |
epsxx = gradient(ZI,10,10); |
|
1045 |
||
1046 |
pcolor(XI,YI,epsxx); |
|
1047 |
axis('equal') |
|
1048 |
caxis([min(min(epsxx)) max(max(epsxx))]) |
|
1049 |
colorbar
|
|
1050 |
shading('interp')
|
|
1051 |
hold on |
|
1052 |
plot3(validx(:,numberbadpoints),validy(:,numberbadpoints),displx(:,1),'.','MarkerEdgeColor','k','MarkerFaceColor','g'), hold off; |
|
1053 |
axis([min(min(XI))-10 max(max(XI))+10 min(min(YI))-10 max(max(YI))+10]) |
|
1054 |
drawnow; |
|
1055 |
||
1056 |
validxtemp=validx; |
|
1057 |
validytemp=validy; |
|
1058 |
displxtemp=displx; |
|
1059 |
validxdelete=validxtemp; |
|
1060 |
validydelete=validytemp; |
|
1061 |
displxdelete=displxtemp; |
|
1062 |
||
1063 |
title(sprintf('Define the region of interest. \n All points ouside that region will be deleted')) |
|
1064 |
||
1065 |
[xgrid,ygrid]=ginput(2); |
|
1066 |
x(1,1) = xgrid(1); |
|
1067 |
x(1,2) = xgrid(2); |
|
1068 |
y(1,1) = ygrid(2); |
|
1069 |
y(1,2) = ygrid(1); |
|
1070 |
||
1071 |
deletepoints=find(validxdelete(:,numberbadpoints)>min(x) & validxdelete(:,numberbadpoints)<max(x) & validydelete(:,numberbadpoints)<max(y) & validydelete(:,numberbadpoints)>min(y)); |
|
1072 |
[loopnum one]=size(deletepoints); |
|
1073 |
||
1074 |
validxdelete(deletepoints,:)=[]; |
|
1075 |
validydelete(deletepoints,:)=[]; |
|
1076 |
||
1077 |
plot3(validxtemp(:,numberbadpoints),validytemp(:,numberbadpoints),displxtemp(:,1),'o','MarkerEdgeColor','k','MarkerFaceColor','g'), hold off; |
|
1078 |
||
1079 |
% update temporary data matrices; delete bad points
|
|
1080 |
displxtemp(deletepoints,:)=[]; |
|
1081 |
validxtemp(deletepoints,:)=[]; |
|
1082 |
validytemp(deletepoints,:)=[]; |
|
1083 |
||
1084 |
% update the figure
|
|
1085 |
gridsizex=10*round(min(min(validxtemp))/10):10:10*round(max(max(validxtemp))/10); |
|
1086 |
gridsizey=10*round(min(min(validytemp))/10):10:10*round(max(max(validytemp))/10); |
|
1087 |
[XI,YI]=meshgrid(gridsizex,gridsizey); |
|
1088 |
ZI=griddata(validxtemp(:,numberbadpoints),validytemp(:,numberbadpoints),displxtemp(:,1),XI,YI,'cubic'); |
|
1089 |
epsxx = gradient(ZI,10,10); |
|
1090 |
pcolor(XI,YI,epsxx); |
|
1091 |
axis('equal') |
|
1092 |
caxis([min(min(epsxx)) max(max(epsxx))]) |
|
1093 |
colorbar
|
|
1094 |
shading('interp')
|
|
1095 |
hold on |
|
1096 |
plot3(validxtemp(:,numberbadpoints),validytemp(:,numberbadpoints),displxtemp(:,1),'o','MarkerEdgeColor','k','MarkerFaceColor','g'), hold off; |
|
1097 |
axis([min(min(XI))-10 max(max(XI))+10 min(min(YI))-10 max(max(YI))+10]) |
|
1098 |
drawnow; |
|
1099 |
||
1100 |
% delete point permanently?
|
|
1101 |
selectremove3 = menu(sprintf('Do you want to delete these markers permanently?'),'Yes','No'); |
|
1102 |
if selectremove3==1 |
|
1103 |
displx=displxtemp; |
|
1104 |
validx=validxtemp; |
|
1105 |
validy=validytemp; |
|
1106 |
end
|
|
1107 |
if selectremove3==2 |
|
1108 |
displxtemp=displx; |
|
1109 |
validxtemp=validx; |
|
1110 |
validytemp=validy; |
|
1111 |
end
|
|
1112 |
selectremove2 = menu(sprintf('Do you want to mark another bad point?'),'Yes','No'); |
|
1113 |
if selectremove2==2 |
|
1114 |
clear displx; |
|
1115 |
validxfirst=zeros(size(validx)); |
|
1116 |
validxfirst=validx(:,1)*ones(1,sizevalidx(1,2)); |
|
1117 |
displx=validx-validxfirst; |
|
1118 |
return
|
|
1119 |
end
|
|
1120 |
end
|
|
1121 |
end
|
|
1122 |