www.pudn.com > detect.rar > detect1.m, change:2009-05-25,size:6469b


function varargout = detect1(varargin) 
% DETECT1 M-file for detect1.fig 
%      DETECT1, by itself, creates a new DETECT1 or raises the existing 
%      singleton*. 
% 
%      H = DETECT1 returns the handle to a new DETECT1 or the handle to 
%      the existing singleton*. 
% 
%      DETECT1('CALLBACK',hObject,eventData,handles,...) calls the local 
%      function named CALLBACK in DETECT1.M with the given input arguments. 
% 
%      DETECT1('Property','Value',...) creates a new DETECT1 or raises the 
%      existing singleton*.  Starting from the left, property value pairs are 
%      applied to the GUI before detect1_OpeningFunction gets called.  An 
%      unrecognized property name or invalid value makes property application 
%      stop.  All inputs are passed to detect1_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 
 
% Copyright 2002-2003 The MathWorks, Inc. 
 
% Edit the above text to modify the response to help detect1 
 
% Last Modified by GUIDE v2.5 22-May-2009 13:09:15 
 
% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',       mfilename, ... 
                   'gui_Singleton',  gui_Singleton, ... 
                   'gui_OpeningFcn', @detect1_OpeningFcn, ... 
                   'gui_OutputFcn',  @detect1_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 detect1 is made visible. 
function detect1_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 detect1 (see VARARGIN) 
 
% Choose default command line output for detect1 
handles.output = hObject; 
 
% Update handles structure 
guidata(hObject, handles); 
 
% UIWAIT makes detect1 wait for user response (see UIRESUME) 
% uiwait(handles.figure1); 
 
 
% --- Outputs from this function are returned to the command line. 
function varargout = detect1_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 during object creation, after setting all properties. 
function axes1_CreateFcn(hObject, eventdata, handles) 
% hObject    handle to axes1 (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    empty - handles not created until after all CreateFcns called 
 
% Hint: place code in OpeningFcn to populate axes1 
% --- Executes on button press in pushbutton3. 
function pushbutton3_Callback(hObject, eventdata, handles) 
% hObject    handle to pushbutton3 (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
global im 
 
[filename,pathname]=uigetfile({'*.jpg';'*.bmp''*.gif'},'选择图片'); 
str=[pathname filename]; 
 
im=imread(str); 
 
 
axes(handles.axes1); 
 
imshow(im) 
  
 
% --- 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) 
  
 
 
 
 
 
 
% --- Executes on button press in pushbutton4. 
function pushbutton4_Callback(hObject, eventdata, handles) 
% hObject    handle to pushbutton4 (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
 
close 
 
 
 
% -------------------------------------------------------------------- 
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles) 
% hObject    handle to uipanel1 (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
global im 
str1=get(hObject,'string'); 
hold on 
axes(handles.axes1) 
switch str1 
    case '原图' 
        imshow(im); 
    case '直方图' 
        A=rgb2gray(im); 
        figure,imhist(A); 
    case '亮度曲面' 
  
         YUV=rgb2ycbcr(im); 
    [m,n,L]=size(YUV); 
    Z=reshape(YUV(:,:,1),m,n); 
    X=1:30:n; 
    Y=1:30:m; 
    [L1,t1]=size(X); 
    [L2,t2]=size(Y); 
    for s=0:(t1-1) 
    Z0(:,(s+1))=Z(:,(30*s+1)); 
    end 
    for s=0:(t2-1) 
    Z1((s+1),:)=Z0((30*s+1),:); 
    end 
    figure,surfc(X,Y,double(Z1)) 
    colormap hsv 
 
    case '高光检测' 
      YUV=rgb2ycbcr(im); 
    [m n L]=size(YUV); 
    for s=1:m 
         for t=1:n 
            if YUV(s,t,1)>170 && YUV(s,t,1)<235 
            im(s,t,1)=0; 
         im(s,t,2)=255; 
         im(s,t,3)=0; 
 
end 
end 
 end 
 
  
imshow(im)   
end 
 
 
 
 
% -------------------------------------------------------------------- 
function file_1_Callback(hObject, eventdata, handles) 
% hObject    handle to file_1 (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
 
 
 
 
% -------------------------------------------------------------------- 
function open_1_Callback(hObject, eventdata, handles) 
% hObject    handle to open_1 (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
pushbutton3_Callback(hObject, eventdata, handles) 
 
% -------------------------------------------------------------------- 
function close_2_Callback(hObject, eventdata, handles) 
% hObject    handle to close_2 (see GCBO) 
% eventdata  reserved - to be defined in a future version of MATLAB 
% handles    structure with handles and user data (see GUIDATA) 
 
close(gcf)