• PUDN用户
    了解作者
  • matlab
    开发工具
  • 5KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 5
    下载次数
  • 2009-11-21 02:25
    上传日期
gui with button that apply arithmetic operation on image
gui.rar
  • gui1.fig
    3.1KB
  • gui1.m
    7.9KB
内容介绍
function varargout = gui1(varargin) % GUI1 M-file for gui1.fig % GUI1, by itself, creates a new GUI1 or raises the existing % singleton*. % % H = GUI1 returns the handle to a new GUI1 or the handle to % the existing singleton*. % % GUI1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUI1.M with the given input arguments. % % GUI1('Property','Value',...) creates a new GUI1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before gui1_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to gui1_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 gui1 % Last Modified by GUIDE v2.5 24-Oct-2009 04:01:17 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @gui1_OpeningFcn, ... 'gui_OutputFcn', @gui1_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 gui1 is made visible. function gui1_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 gui1 (see VARARGIN) % Choose default command line output for gui1 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes gui1 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = gui1_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 pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) global image; filter={'*.jpg;*.tif;*.png;*.gif','All Image Files'}; [name,path] = uigetfile(filter,'Select The Picture That You Want Edit'); image=[path,name]; global attrs; figure; h=imshow(image); attrs=imattributes(h); set(handles.pushbutton2,'Enable', 'on') set(handles.pushbutton4,'Enable', 'on') set(handles.slider,'Enable', 'on') set(handles.agroup,'Visible', 'on') % 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) % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) global image; global attrs; sv = get(handles.slider,'Value'); br=get(handles.brightness,'value'); si=get(handles.size,'value'); co=get(handles.contrast,'value'); ga=get(handles.gamma,'value'); ro=get(handles.rotate,'value'); type=1; if(strcmp(attrs(4,2), 'indexed')) [x, map]=imread(image); type=2; else x=imread(image); type=1; end if(br==1) %!brightness if(type == 1) z=imadd(x,sv); figure; imshow(z); else rgb=ind2rgb(x,map); sv=sv/255; z=imadd(rgb,sv); figure; imshow(z); end end if(si==1) %resizing if(sv>=0) sv=sv/30; else sv=sv*-1; sv=1-(sv/255); end if(type == 1) z=imresize(x,sv); figure; imshow(z); else [z,map]=imresize(x,map,sv); figure; imshow(z,map); end end if(co == 1) %contrast if(type ==2) x=ind2rgb(x,map); end if(sv<0) if(sv<=-125) sv=-124; end z=imadjust(x,[],[sv/-255,1-(sv/-255)]); else if(sv>=125) sv=124; end z=imadjust(x,[sv/255,1-(sv/255)],[]); end figure; imshow(z); end if(ga==1) if(sv<=0) sv=1+(-sv/255); i else sv=1-(sv/255); end if(type == 2) x=ind2rgb(x,map); end z=imadjust(x,[],[0,1],sv); figure; imshow(z); end if(ro==1) if(type == 2) x=ind2rgb(x,map); z=imrotate(x,sv); figure; imshow(z); else z=imrotate(x,sv); figure; imshow(z); end end % 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 slider movement. function slider_Callback(hObject, eventdata, handles) % hObject handle to slider (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 % 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) function slider_CreateFcn(hObject, eventdata, handles) % hObject handle to slider4 (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 % --- Executes on slider movement. function slider4_Callback(hObject, eventdata, handles) % hObject handle to slider4 (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 slider4_CreateFcn(hObject, eventdata, handles) % hObject handle to slider4 (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 % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) global image; global attrs; if(strcmp(attrs(4,2), 'indexed')) [x, map]=im2double(imread(image)); type=2; figure;imhist(x,map); else x=im2double(imread(image)); type=1; figure;imhist(x); end % eventdata reserved - to be defined in a future
评论
    相关推荐