📄 digitizeit.m
字号:
'*.*', 'All Files (*.*)'}, ...
'Pick an image file');
a = imread([filename]);
image(a);
handles = guidata(gcbo);
handles.imgfilename = filename;
guidata(gcbo,handles);
% --- Executes on button press in btnLine.
function btnLine_Callback(hObject, eventdata, handles)
% hObject handle to btnLine (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% get the data points for all lines
% after digitization of one line, press return key to advance to next line
handles = guidata(gcbo);
linename = handles.linename;
[xLine,yLine]=ginput;
XLine=[ones(size(xLine)) xLine]*handles.CX;
YLine=[ones(size(yLine)) yLine]*handles.CY;
DATA=[XLine YLine];
save([handles.imgfilename linename '.txt'],'DATA','-ascii');
figure(1);
hold on;
plot(XLine,YLine,'bo-');
% --- Executes on button press in btnDone.
function btnDone_Callback(hObject, eventdata, handles)
% hObject handle to btnDone (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(gcbf);
% --- Executes on button press in btnx.
function btnX_Callback(hObject, eventdata, handles)
% hObject handle to btnx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% get the structure in the subfunction
handles = guidata(gcbo);
h = findobj(gcbf,'Tag','xreps');
naxes = eval(get(h,'String'));
h = findobj(gcbf,'Tag','xdata');
xdatav = get(h,'String');
mstring = ['[' xdatav ']' ];
xp = eval(mstring);
xl = length(xp);
X = []; % all Ys put into one vector
XX = []; % all Ys put into a matrix
% get the data points in X axis for several times
for i=1:naxes
[x,Y]=ginput(xl);
X = [X;x];
XX = [XX x];
end
% pool the data points from three repetition together
A=[ones(size(X)) X];
% linear regression model for Y axis
xps = repmat(xp,1,naxes);
CX=A\xps';
% calculate the earror value
xm = mean(XX,2); % mean for each data point
for i=1:size(XX,2), XX(:,i)=XX(:,i)-xm;, end
xx = reshape(XX,1,size(XX,1)*size(XX,2));
xse = std(xx)
xse = CX(2) * xse
Hxpxsd = findobj(gcbf,'Tag','xpxsd');
set(Hxpxsd,'String',sprintf('%6.4f',xse));
xse = CX(2) * xse
Hxdatasd = findobj(gcbf,'Tag','xdatasd');
set(Hxdatasd,'String',sprintf('%6.4f',xse));
handles.CX = CX;
% save the changes to the structure
guidata(gcbo,handles);
% --- Executes on button press in btny.
function btnY_Callback(hObject, eventdata, handles)
% hObject handle to btny (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(gcbo);
h = findobj(gcbf,'Tag','yreps');
naxes = eval(get(h,'String'));
h = findobj(gcbf,'Tag','ydata');
ydatav = get(h,'String');
mstring = ['[' ydatav ']' ];
yp = eval(mstring);
yl = length(yp);
Y = []; % all Ys put into one vector
YY = []; % all Ys put into a matrix
% get the data points in Y axis for several times
for i=1:naxes
[X,y]=ginput(yl);
Y = [Y;y];
YY = [YY y];
end
% pool the data points from three repetition together
A=[ones(size(Y)) Y];
% linear regression model for Y axis
yps = repmat(yp,1,naxes);
CY=A\yps';
% calculate the earror value
ym = mean(YY,2); % mean for each data point
for i=1:size(YY,2), YY(:,i)=YY(:,i)-ym;, end
yy = reshape(YY,1,size(YY,1)*size(YY,2));
yse = std(yy)
Hypxsd = findobj(gcbf,'Tag','ypxsd');
set(Hypxsd,'String',sprintf('%6.4f',yse));
yse = CY(2) * yse
Hydatasd = findobj(gcbf,'Tag','ydatasd');
set(Hydatasd,'String',sprintf('%6.4f',yse));
handles.CY = CY;
% save the changes to the structure
guidata(gcbo,handles);
% --- Executes during object creation, after setting all properties.function xpxsd_CreateFcn(hObject, eventdata, handles)% hObject handle to xpxsd (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes during object creation, after setting all properties.function xdatasd_CreateFcn(hObject, eventdata, handles)% hObject handle to xdatasd (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes during object creation, after setting all properties.function ypxsd_CreateFcn(hObject, eventdata, handles)% hObject handle to ypxsd (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes during object creation, after setting all properties.function ydatasd_CreateFcn(hObject, eventdata, handles)% hObject handle to ydatasd (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes during object creation, after setting all properties.function linedata_CreateFcn(hObject, eventdata, handles)% hObject handle to linedata (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction linename_Callback(hObject, eventdata, handles)% hObject handle to linename (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of linename as text% str2double(get(hObject,'String')) returns contents of linename as a doublehandles = guidata(gcbo);
handles.linename = get(gcbo,'String');
guidata(gcbo,handles);
% --- Executes on button press in perptest.function perptest_Callback(hObject, eventdata, handles)% hObject handle to perptest (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[x0,y0]=ginput(1); % original
[x1,y1]=ginput(1); % a point in X axis
[x2,y2]=ginput(1); % a point in Y axis
costheta = ((x1-x0)*(x2-x0) + (y1-y0)*(y2-y0)) / sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)) / sqrt((x2-x0)*(x2-x0) + (y2-y0)*(y2-y0));
theta = acos(costheta) * 180 / pi;
h = findobj(gcbf,'Tag','origin');
set(h,'String',['OR=(' sprintf('%6.0f',x0) ',' sprintf('%6.0f',y0) ')']);
h = findobj(gcbf,'Tag','XAPoint');
set(h,'String',['XP=(' sprintf('%6.0f',x1) ',' sprintf('%6.0f',y1) ')']);
h = findobj(gcbf,'Tag','YAPoint');
set(h,'String',['YP=(' sprintf('%6.0f',x2) ',' sprintf('%6.0f',y2) ')']);
h = findobj(gcbf,'Tag','Theta');
set(h,'String',sprintf('Theta=%4.1f',theta));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -