www.gusucode.com > 有关图像的RGB三色的合成、分离,还用到了Matlab中得gui界面的设置 > 有关图像的RGB三色的合成、分离,还用到了Matlab中得gui界面的设置/rgb1.m
function varargout = rgb1(varargin) % RGB1 M-file for rgb1.fig % RGB1, by itself, creates a new RGB1 or raises the existing % singleton*. % % H = RGB1 returns the handle to a new RGB1 or the handle to % the existing singleton*. % % RGB1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in RGB1.M with the given input arguments. % % RGB1('Property','Value',...) creates a new RGB1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before rgb1_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to rgb1_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 rgb1 % Last Modified by GUIDE v2.5 17-Dec-2008 10:31:18 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @rgb1_OpeningFcn, ... 'gui_OutputFcn', @rgb1_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 rgb1 is made visible. function rgb1_OpeningFcn(hObject, eventdata, handles, varargin) A=imread('aa.jpg'); axes(handles.axes1); imshow(A); % 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 rgb1 (see VARARGIN) % Choose default command line output for rgb1 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes rgb1 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = rgb1_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 selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) global A; val=get(hObject,'value'); if(val==1) A=imread('aa.jpg'); elseif(val==2) A=imread('a.jpg'); elseif(val==3) A=imread('b.jpg'); end axes(handles.axes1); imshow(A); % 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 = get(hObject,'String') returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1 % --- 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 set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) global A; val1=get(handles.radiobutton1,'Value'); val2=get(handles.radiobutton2,'Value'); val3=get(handles.radiobutton3,'Value'); if val1 B(:,:,1)=A(:,:,1); B(:,:,2:3)=0; end if val2 B(:,:,2)=A(:,:,2); B(:,:,1)=0; B(:,:,3)=0; end if val3 B(:,:,3)=A(:,:,3); B(:,:,1:2)=0; end axes(handles.axes3); imshow(B); % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)