function varargout = task(varargin)
% TASK M-file for task.fig
% TASK, by itself, creates a new TASK or raises the existing
% singleton*.
%
% H = TASK returns the handle to a new TASK or the handle to
% the existing singleton*.
%
% TASK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TASK.M with the given input arguments.
%
% TASK('Property','Value',...) creates a new TASK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before task_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to task_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 task
% Last Modified by GUIDE v2.5 23-May-2012 21:23:00
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @task_OpeningFcn, ...
'gui_OutputFcn', @task_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 task is made visible.
function task_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 task (see VARARGIN)
% Choose default command line output for task
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes task wait for user response (see UIRESUME)
% uiwait(handles.main);
% --- Outputs from this function are returned to the command line.
function varargout = task_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 open_vedio.
function open_vedio_Callback(hObject, eventdata, handles)
obj = videoinput('winvideo',1);
setappdata(handles.main,'video_obj',obj);
preview(obj);
% hObject handle to open_vedio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in open_vedio.
function open_vedio_Callback(hObject, eventdata, handles)
% hObject handle to open_vedio (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in picture.
function picture_Callback(hObject, eventdata, handles)
obj=getappdata(handles.main,'video_obj');
frame = getsnapshot(obj);
f11 = ycbcr2rgb(frame);
setappdata(handles.main,'img',f11);
imshow(f11);
% hObject handle to picture (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in gray.
function gray_Callback(hObject, eventdata, handles)
img1=getappdata(handles.axes1,'img');
gray_img1=rgb2gray(img1);
setappdata(handles.axes1,'img',gray_img1);
axes(handles.axes1)
imshow(gray_img1);
img2=getappdata(handles.axes2,'img');
gray_img2=rgb2gray(img2);
setappdata(handles.axes2,'img',gray_img2);
axes(handles.axes2)
imshow(gray_img2);
% hObject handle to gray (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in open1.
function open1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile( ...
{'*.bmp;*.jpg;*.png;*.jpeg', 'Image Files (*.bmp, *.jpg, *.png, *.jpeg)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick an image');
if isequal(filename,0) || isequal(pathname,0),
return;
end
fpath=[pathname filename];
img_src1=imread(fpath);
axes(handles.axes1)
imshow(img_src1);
axis image;
setappdata(handles.axes1,'img',img_src1);
% hObject handle to open1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
val=get(hObject,'Value');
set(handles.level_txt,'String',num2str(val));
img=getappdata(handles.main,'img');
c=im2bw(img,val);
imshow(c);
setappdata(handles.main,'img_bw',c);
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in edge.
function edge_Callback(hObject, eventdata, handles)
I1=getappdata(handles.axes1,'img_bw');
BW1=im2bw(I1);
BW_canny1=edge(BW1,'canny');
axes(handles.axes1)
imshow(BW_canny1);
I2=getappdata(handles.axes2,'img_bw');
BW2=im2bw(I2);
BW_canny2=edge(BW2,'canny');
axes(handles.axes2)
imshow(BW_canny2);
% hObject handle to edge (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
val=get(hObject,'Value');
img1=getappdata(handles.axes1,'img');
c1=im2bw(img1,val);
axes(handles.axes1)
imshow(c1);
setappdata(handles.axes1,'img_bw',c1);
val=get(hObject,'Value');
img2=getappdata(handles.axes2,'img');
c2=im2bw(img2,val);
axes(handles.axes2)
imshow(c2);
setappdata(handles.axes2,'img_bw',c2);
% hObject handle to slider1 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
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
% --- 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 && isequa
评论1