⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter3.m

📁 这是里面是岗萨雷斯(matlab)的第三章代码。
💻 M
字号:
function varargout = chapter3(varargin)% CHAPTER3 M-file for chapter3.fig%      CHAPTER3, by itself, creates a new CHAPTER3 or raises the existing%      singleton*.%%      H = CHAPTER3 returns the handle to a new CHAPTER3 or the handle to%      the existing singleton*.%%      CHAPTER3('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in CHAPTER3.M with the given input arguments.%%      CHAPTER3('Property','Value',...) creates a new CHAPTER3 or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before chapter3_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to chapter3_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 chapter3% Last Modified by GUIDE v2.5 09-Apr-2009 14:14:24% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @chapter3_OpeningFcn, ...                   'gui_OutputFcn',  @chapter3_OutputFcn, ...                   'gui_LayoutFcn',  [] , ...                   'gui_Callback',   []);if nargin && ischar(varargin{1})    gui_State.gui_Callback = str2func(varargin{1});endif 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 chapter3 is made visible.function chapter3_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 chapter3 (see VARARGIN)% Choose default command line output for chapter3handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes chapter3 wait for user response (see UIRESUME)% uiwait(handles.figure_chapter3);axes(handles.axes1);imshow(imread('logo.jpg'));% --- Outputs from this function are returned to the command line.function varargout = chapter3_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 structurevarargout{1} = handles.output;% --- Executes on button press in pbtn_open.function pbtn_open_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_open (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)[filename, pathname] = uigetfile('*.bmp;*.jpg;*.jpeg;*.tiff;*.gif;', 'Pick an image file');if isequal(filename,0) || isequal(pathname,0)    return;else    filepath=fullfile(pathname, filename);endaxes(handles.axes4);imshow(imread(filepath),[]);% --- Executes on button press in pbtn_save.function pbtn_save_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_save (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)[filename, pathname] = uiputfile({'*.jpg';'*.bmp';'.jpeg';'.tiff';'.gif'}, 'Pick an image');if isequal(filename,0) || isequal(pathname,0)    return;else   filepath=fullfile(pathname, filename);endimwrite(getimage(handles.axes4),filepath);% --- Executes on button press in pbtn_imadjust.function pbtn_imadjust_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_imadjust (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)prompt={'Enter the range of the input image:[low_in,high_in]',...                'Enter the range of the output image:[low_out,high_out]',...                'Enter the gamma:'};name='Input for the imadjust';numlines=1;defaultanswer={'[0.3 0.5]','[0.1 0.8]','1'};answer=inputdlg(prompt,name,numlines,defaultanswer);in=eval(answer{1});out=eval(answer{2});gamma=eval(answer{3});f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endout_image=imadjust(f,in,out,gamma);axes(handles.axes4);imshow(out_image,[]);% --- Executes on button press in pbtn_imcomplement.function pbtn_imcomplement_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_imcomplement (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)out=imcomplement(getimage(handles.axes4));axes(handles.axes4);imshow(out,[]);% --- Executes on button press in pbtn_log.function pbtn_log_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_log (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)prompt={'Enter the const variable c:'};answer=inputdlg(prompt,'Arguments',1,{'1'});c=eval(answer{1});f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endout=c*(log(1+double(f)));axes(handles.axes4);imshow(out,[]);% --- Executes on button press in pbtn_stretch.function pbtn_stretch_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_stretch (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)prompt={'m:(default is the mean value of the image)','E:(defalut is 4.0)'};name='Arguments';numlines=1;defaultanswer={'0','4.0'};answer=inputdlg(prompt,name,numlines,defaultanswer);f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endm=eval(answer{1});if(m==0)    m=mean2(f);endE=eval(answer{2});out=1./(1+(m./(f+eps)).^E);axes(handles.axes4);imshow(out,[]);% --- Executes on button press in pbtn_hist.function pbtn_hist_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_hist (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endh=imhist(f);axes(handles.axes4);h1=h(1:10:256);horz=1:10:256;bar(horz,h1);% --- Executes on button press in pbtn_histeq.function pbtn_histeq_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_histeq (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endg=histeq(f,256);axes(handles.axes4);imshow(g,[]);% --- Executes on button press in pbtn_ext.function pbtn_ext_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_ext (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)close(handles.figure_chapter3);% --- Executes on button press in pbtn_histmatch.function pbtn_histmatch_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_histmatch (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)prompt={'m1:(default is 0.15)','sig1:(default is 0.05)','m2:(default is 0.75)',...    'sig2:(default is 0.05)','A1:(default is 1)','A2:(default is 0.07)','K:(default is 0.002)'};name='Arguments';numlines=1;defaultanswer={'0.15','0.05','0.75','0.05','1','0.07','0.002'};answer=inputdlg(prompt,name,numlines,defaultanswer);m1=eval(answer{1});sig1=eval(answer{2});m2=eval(answer{3});sig2=eval(answer{4});A1=eval(answer{5});A2=eval(answer{6});K=eval(answer{7});p=twomodegauss(m1,sig1,m2,sig2,A1,A2,K);f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endg=histeq(f,p);axes(handles.axes4);imshow(g,[]);% --- Executes on button press in pbtn_imfilter.function pbtn_imfilter_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_imfilter (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)prompt={'Filter:','Filtering mode:(''corr'',''conv'')','Boundary options:(''replicate'',''sysmetric'',''circular'',or a value)',...    'Size options:(''full'',''same'')'};name='Arguments';numlines=1;defaultanswer={'ones(3)','corr','replicate','same'};answer=inputdlg(prompt,name,numlines,defaultanswer);w=eval(answer{1});filter_mode=answer{2};boundary_option=answer{3};size_option=answer{4};f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endg=imfilter(f,w,filter_mode,boundary_option,size_option);axes(handles.axes4);imshow(g,[]);% --- Executes on button press in pbtn_colfilt.function pbtn_colfilt_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_colfilt (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)prompt={'Demensions of the filter area:','Block type:(distinct,sliding)',...    'the handle of the function:'};name='Arguments';numlines=1;defaultanswer={'[3,2]','sliding','gmean'};answer=inputdlg(prompt,name,numlines,defaultanswer);dim=eval(answer{1});arg1=answer{2};arg2=str2func(answer{3});f=getimage(handles.axes4);if(length(size(f))==3)    f=rgb2gray(f);endf=double(f);f=padarray(f,dim,'replicate');g=colfilt(f,dim,arg1,arg2);axes(handles.axes4);imshow(g,[]);% --- Executes on button press in pbtn_medianfilter.function pbtn_medianfilter_Callback(hObject, eventdata, handles)% hObject    handle to pbtn_medianfilter (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)prompt={'Padding options:(zeros,symmetric,indexed)'};name='Arguments';numlines=1;defaultanswer={'symmetric'};answer=inputdlg(prompt,name,numlines,defaultanswer);option=answer{1};f=getimage(handles.axes4);if length(size(f))==3,    f=rgb2gray(f);endf=medfilt2(f,option);axes(handles.axes4);imshow(f,[]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -