1
function [validx,validy]=strain_lineprofile_marker;
3
%Code to use ISDG markers for 1-D Matlab DIC strain measurement
4
%Programmed by Dan and Rob
6
%Last revision: 3. February 2008
9
%Load the filenames to analyze
11
[r,c]=size(filenamelist);
14
[FileNameBase,PathNameBase] = uigetfile( ...
15
{'*.bmp;*.tif;*.jpg;*.TIF;*.BMP;*.JPG','Image files (*.bmp,*.tif,*.jpg)';'*.*', 'All Files (*.*)'}, ...
16
'Open base image for marker selection (color image best)');
18
im_base = imread(FileNameBase);
19
im_basetemp=mean(double(im_base),3);
22
maxcolor=max(max(im_base));
23
mincolor=min(min(im_base));
24
caxis([mincolor maxcolor]);
27
[imr,imc]=size(im_base);
29
%Select point in middle of marker
30
xlabel('Location On Image [Pixels]')
31
ylabel('Location On Image [Pixels]')
32
title(sprintf('Click on the center of one marker.'))
33
marker_pt=round(ginput(1));
34
x_mark = marker_pt(1);
35
y_mark = marker_pt(2);
37
%Prompt for integration width
38
prompt = {'Enter integration width [Pixels]:'};
39
dlg_title = 'Input integration width for the analysis';
42
answer = inputdlg(prompt,dlg_title,num_lines,def);
43
int_width = str2num(cell2mat(answer(1)));
45
%Calculate line profile data
47
ydata= sum(im_base((y_mark-int_width/2):(y_mark+int_width/2),:),1)/int_width;
50
set(h,'Position',[150,50,800,600])
52
xlabel('Location On Image [Pixels]')
53
ylabel('Pixel Intensity Value')
54
title(sprintf('First, single click at the base and middle of the LEFT PEAK (vertically even with the flat data).\n Then, single click on the max point of the RIGHT PEAK.'))
55
[xprof, yprof]=ginput(2);
56
mu1_guess = xprof(1,1);
57
mu2_guess = xprof(2,1);
58
back_guess = yprof(1,1);
59
amp_guess1 = yprof(2,1);
60
amp_guess2 = yprof(2,1);
65
saveas(h,'center_select.fig')
67
%Close all open images
70
%Initialize status bar and figure
72
g=waitbar(0,'Processing the images...');
73
set(g,'Position',[275,50,275,50]) %[left bottom width height]
74
% results_prof = zeros(r,2);
84
%Read in images from filenamelist
85
im_input = mean(double(imread(filenamelist(i,:))),3);
87
%Generate greyscale data (y-values)
88
ydata= sum(im_input((int8(y_mark-int_width/2)):(int8(y_mark+int_width/2)),:),1)/int_width;
91
%Fit gaussian function to peaks
92
[x,resnorm,residual,exitflag,output] = lsqcurvefit(@gauss_twopk, [amp_guess1 mu1_guess sig1_guess amp_guess2 mu2_guess sig2_guess back_guess], xdata, ydata);
96
ytest = (x(1)*exp((-(xtest-x(2)).^2)./(2.*x(3).^2))) + (x(4)*exp((-(xtest-x(5)).^2)./(2.*x(6).^2))) + x(7);
98
axis([0 imc 0 (max(ydata)*1.1)])
99
xlabel('Location On Image [Pixels]')
100
ylabel('Pixel Intensity Value')
101
title('Pixel Intensity Value Fit vs. Location On Image')
103
plot(xtest,ytest,'r')
106
%Write results to matrix
107
results_prof(i+1,1) = x(2);
108
results_prof(i+1,2) = x(5);
109
results_prof(1,1) = results_prof(2,1);
110
results_prof(1,2) = results_prof(2,2);
112
validx(:,i)=[x(2) x(5)];
113
validy(:,i)=[y_mark y_mark];
116
amp_guess1 = x(1); mu1_guess = x(2); sig1_guess = x(3); amp_guess2 = x(4); mu2_guess = x(5); sig2_guess = x(6); back_guess = x(7);
123
saveas(k,'peak_fit.fig')
125
%Save locations of two peaks for all images and save integration width
126
save raw_peak_results.dat results_prof -ascii -tabs
127
save int_width_y_mark.dat int_width y_mark -ascii -tabs
128
save validx_line_profile.dat validx -ascii -tabs
129
save validy_line_profile.dat validy -ascii -tabs
131
line_visual(filenamelist,results_prof,[int_width; y_mark]);
b'\\ No newline at end of file'