functionvarargout=jiemian(varargin)%返回从函数jiemian.m中得到的参数中变量的数目;传递一个参数中变量的数目给函数jiemian.m。%JIEMIANApplicationM-fileforjiemian.fig%FIG=JIEMIANlaunchjiemianGUI.%JIEMIAN('callback_name',...)invokethenamedcallback.%LastModifiedbyshijiaweiv2.524-May-201402:45:18ifnargin==0%LAUNCHGUI%nargin显示输入变量fig=openfig(mfilename,'reuse');%打开包含在FIG文件filename.fig中的图形,确保它是可见的并且完全定位在屏幕上。%Generateastructureofhandlestopasstocallbacks,andstoreit.handles=guihandles(fig);%返回一个结构,它包含图像中对象的句柄guidata(fig,handles);%将变量handles存储到fig文件中ifnargout0%如果输出变量大于0varargout{1}=fig;%返回figendelseifischar(varargin{1})%INVOKENAMEDSUBFUNCTIONORCALLBACK%如果varargin{1}是一个字符数组则返回逻辑真(1),否则返回逻辑假(0)。tryif(nargout)%显示用户提供的输出变量的个数[varargout{1:nargout}]=feval(varargin{:});%FEVALswitchyard%varargout传递参数中的变量数目elsefeval(varargin{:});%FEVALswitchyard%**feval函数的求值endcatch%如果出错开始执行catch块disp(lasterr);%%%%lasterr函数查询出错原因。如果函数lasterr的运行结果为一个空串,则表明组命令1被成功执行了%%%%disp显示矩阵和文字内容endend%|ABOUTCALLBACKS:%|GUIDEautomaticallyappendssubfunctionprototypestothisfile,and%|setsobjects'callbackpropertiestocallthemthroughtheFEVAL%|switchyardabove.Thiscommentdescribesthatmechanism.%|%|Eachcallbacksubfunctiondeclarationhasthefollowingform:%|SUBFUNCTION_NAME(H,EVENTDATA,HANDLES,VARARGIN)%|%|Thesubfunctionnameiscomposedusingtheobject'sTagandthe%|callbacktypeseparatedby'_',e.g.'slider2_Callback',%|'figure1_CloseRequestFcn','axis1_ButtondownFcn'.%|%|Histhecallbackobject'shandle(obtainedusingGCBO).%|%|EVENTDATAisempty,butreservedforfutureuse.%|%|HANDLESisastructurecontaininghandlesofcomponentsinGUIusing%|tagsasfieldnames,e.g.handles.figure1,handles.slider2.This%|structureiscreatedatGUIstartupusingGUIHANDLESandstoredin%|thefigure'sapplicationdatausingGUIDATA.Acopyofthestructure%|ispassedtoeachcallback.Youcanstoreadditionalinformationin%|thisstructureatGUIstartup,andyoucanchangethestructure%|duringcallbacks.Callguidata(h,handles)afterchangingyour%|copytoreplacethestoredoriginalsothatsubsequentcallbackssee%|theupdates.Typehelpguihandlesandhelpguidataformore%|information.%|%|VARARGINcontainsanyextraargumentsyouhavepassedtothe%|callback.Specifytheextraargumentsbyeditingthecallback%|propertyintheinspector.Bydefault,GUIDEsetsthepropertyto:%|MFILENAME('SUBFUNCTION_NAME',gcbo,[],guidata(gcbo))%|Addanyextraargumentsafterthelastargument,beforethefinal%|closingparenthesis.%--------------------------------------------------------------------functionvarargout=LoadPush_Callback(h,eventdata,handles,varargin)%回调函数%返回从函数()中得到的参数中变量的数目。globalim_originalim_noisedim_filtered%global:定义全局变量%原始图像,噪声图像,去噪图像[filename,pathname]=uigetfile('*.bmp;*.pgm;*.tif;*.jpg;*.*','Loadinputimage');%读取文件ifisequal(filename,0)|isequal(pathname,0)%确定数组是否数值相等,如果输入数组具有相同的维数、相同的类型并且具有相同的内容则返回逻辑真(1),否则返回逻辑假(0)。disp('Userpressedcancel')%disp:显示elsedisp(['Userselected',fullfile(pathname,filename)])%显示用户选项,显示路径名称和文件文件endim_original=imread(filename);%从图形文件中读取图像。set(handles.Or_image,'HandleVisibility','OFF');%handles:句柄axes[坐标]的句柄不可见%注释掉影响不大set(handles.Out_image,'HandleVisibility','OFF');%注释掉影响不大%set(handles.Denoised_image,'HandleVisibility','OFF');set(handles.Or_image,'HandleVisibility','ON');%注释掉影响不大axes(handles.Or_image);%设置现有轴handles.Or_image为当前轴。imshow(im_original);%显示原始图像colormap(gray(256));%将当前的颜色图设置为256灰度axisequal;%让图像的大小与框架吻合axistight;%同上axisoff;%把数轴关掉set(handles.Or_image,'HandleVisibility','OFF');%axeshandles:句柄不可见set(handles.Or_image,'XTickLabel','','YTickLabel','');%xtick是刻度(小竖线);xticklabel刻度值(竖线下面的数值)。%--------------------------------------------------------------------functionvarargout=popupmenu1_Callback(h,eventdata,handles,varargin)%【AddNoise】下拉菜单%--------------------------------------------------------------------functionvarargout=popupmenu3_Callback(h,eventdata,handles,varargin)%【Method】下拉菜单%--------------------------------------------------------------------functionvarargout=ApplyPush_Callback(h,eventdata,handles,varargin)%【apply】按钮globalim_originalim_noisedim_filtered%定义全局变量imnoise_type=get(handles.popupmenu1,'Value');%selectednoisetypeswitchimnoise_type%切换噪声类型case{1}%加入噪声im_noised=gaussian_bai(im_original);%加入高斯白噪声case{2}im_noised=salt(uint8(im_original));%加入椒盐噪声case{3}im_noised=speckle(uint8(im_original));%加入乘性噪声case{4}im_noised=poisson(im_original);%加入泊松噪声endmethod_number=get(handles.popupmenu3,'Value');%selectedfiltermethodswitchmethod_numbercase{1}im_filtered=meanfilter(im_noised);%执行二维的均值滤波case{2}im_filtered=medfilter3(im_noised);%执行二维的中值滤波case{3}im_filtered=medfilter5(im_noised);%执行5*5窗口二维的中值滤波case{4}im_filtered=medfilter7(im_noised);%执行7*7窗口二维的中值滤波case{5}im_filtered=wienerfilter(im_noised);%执行二维的维纳滤波case{6}im_filtered=Waveletthreshold(im_noised);%执行小波去噪case{7}im_filtered=adpmedian(im_noised);%执行自适应中值滤波endset(handles.noised_image,'HandleVisibility','ON');%axes[坐标]的句柄可见axes(handles.noised_image);%设置现有轴handles.noised_image为当前轴。imagesc(im_noised);%函数imagesc将图像数据进行缩放,以使之介于当前色图的全区间上并且显示图像colormap(gray(256));%设定和获取当前的颜色图。axisequal;%让图像的大小与框架吻合axistight;%同上axisoff;%把数轴关掉set(handles.noised_image,'HandleVisibility','OFF')%a