1 内容介绍

基于matlab模拟光栅条纹投影生成

2 部分代码

function varargout = Main(varargin)

% MAIN MATLAB code for Main.fig

%      MAIN, by itself, creates a new MAIN or raises the existing

%      singleton*.

%

%      H = MAIN returns the handle to a new MAIN or the handle to

%      the existing singleton*.

%

%      MAIN('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in MAIN.M with the given input arguments.

%

%      MAIN('Property','Value',...) creates a new MAIN or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before Main_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to Main_OpeningFcn via varargin.

%

%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one

%      instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES


% Edit the above text to modify the response to help Main


% Last Modified by GUIDE v2.5 09-Sep-2022 22:18:16


% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @Main_OpeningFcn, ...

                   'gui_OutputFcn',  @Main_OutputFcn, ...

                   'gui_LayoutFcn',  [] , ...

                   'gui_Callback',   []);

if nargin && ischar(varargin{1})

    gui_State.gui_Callback = str2func(varargin{1});

end


if nargout

    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

    gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT



% --- Executes just before Main is made visible.

function Main_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% varargin   command line arguments to Main (see VARARGIN)


% Choose default command line output for Main

handles.output = hObject;


% Update handles structure

guidata(hObject, handles);


% UIWAIT makes Main wait for user response (see UIRESUME)

% uiwait(handles.figure1);



% --- Outputs from this function are returned to the command line.

function varargout = Main_OutputFcn(hObject, eventdata, handles) 

% varargout  cell array for returning output args (see VARARGOUT);

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)


% Get default command line output from handles structure

varargout{1} = handles.output;



% --- Executes on button press in radiobutton1.

function radiobutton1_Callback(hObject, eventdata, handles)

% hObject    handle to radiobutton1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)


% Hint: get(hObject,'Value') returns toggle state of radiobutton1

guidata(hObject,handles);

val=get(handles.radiobutton1,'Value');

if val

    set(handles.edit4,'Enable','on');

    set(handles.popupmenu3,'Enable','on');

end


% --- Executes on button press in radiobutton2.

function radiobutton2_Callback(hObject, eventdata, handles)

% hObject    handle to radiobutton2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)


% Hint: get(hObject,'Value') returns toggle state of radiobutton2

guidata(hObject,handles);

val=get(handles.radiobutton2,'Value');

if val

    set(handles.edit4,'Enable','off');

    set(handles.popupmenu3,'Enable','off');

end




% --- Executes on selection change in popupmenu1.

function popupmenu1_Callback(hObject, eventdata, handles)

% hObject    handle to popupmenu1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)


% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array

%        contents{get(hObject,'Value')} returns selected item from popupmenu1

guidata(hObject,handles);

val=get(hObject,'Value');

switch val

    case 1

        set(handles.edit3,'Enable','off');

    case 2

        set(handles.edit3,'Enable','off');

    case 3

        set(handles.edit3,'Enable','on');

end

        

        

        


% --- Executes during object creation, after setting all properties.

function popupmenu1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to popupmenu1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called


% Hint: popupmenu controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

end




function edit1_Callback(hObject, eventdata, handles)

% hObject    handle to edit1 (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 edit1 as text

%        str2double(get(hObject,'String')) returns contents of edit1 as a double

str=get(hObject,'String');

set(handles.edit6,'String',str);


% --- Executes during object creation, after setting all properties.

function edit1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

end




function edit2_Callback(hObject, eventdata, handles)

% hObject    handle to edit2 (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 edit2 as text

%        str2double(get(hObject,'String')) returns contents of edit2 as a 

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject    handle to pushbutton2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

A = exist('D:\Matlab.R2014b\work\code\tiaowen123.m','file');

if A>0

    disp('FTP源码生成失败!已存在同名文件');

    open tiaowen123.m

else

    copyfile('D:\Matlab.R2014b\work\profilometry3d\tiaowen123.m',...

        'D:\Matlab.R2014b\work\code\tiaowen123.m');

    open tiaowen123.m

end



function edit6_Callback(hObject, eventdata, handles)

% hObject    handle to edit6 (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 edit6 as text

%        str2double(get(hObject,'String')) returns contents of edit6 as a double



% --- Executes during object creation, after setting all properties.

function edit6_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit6 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

    set(hObject,'BackgroundColor','white');

end

3 运行结果

【光学】基于matlab模拟光栅条纹投影生成_2d

【光学】基于matlab模拟光栅条纹投影生成_ide_02

4 参考文献

[1]戴美玲, 杨福俊, 杜晓磊,等. 基于单幅彩色正弦光栅投影的三维形貌测量[J]. 光学学报, 2011, 31(7):5.

[2]樊强, 姜涛, 习俊通,等. 光学三维测量中结构光栅投影系统的开发[J]. 光电工程, 2005, 32(10):4.

部分理论引用网络文献,若有侵权联系博主删除。