资源描述:
《直方图均衡含GUI.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、DigitalImageProcessingHistogramEqualizationwithGUImoduleAuthor:Andonghui_20090802310067Thehistogramequalizationcode:%对一幅图像进行直方图均衡化A=rgb2gray(picture);%图像的预处理,读入彩色图像将其灰度化[m,n]=size(A);B=zeros(size(A));l=m*n;r=zeros(1,256);y=zeros(1,256);A=double(A);fori=1:mforj=1:nr(A(i,j)+1)
2、=r(A(i,j)+1)+1;endendr=r./l;%得到原图像各灰度级所占的比例fork=1:256forj=1:ky(k)=y(k)+r(j);endend%直方图累加fork=1:256y(k)=floor(255*y(k)+0.5);%确定映射关系endfori=1:mforj=1:nB(i,j)=y(A(i,j)+1);endendA=uint8(A);%转换为无符号整数B=uint8(B);imshow(B);%显示均衡化后的图像TheGUIFunctioninterface:Function:Transformtheimage
3、intograyandaddGaussiannoiseFunctin:showthehistogramoftheoriginalgrayimageFunction:showtheresultofusinghistogramequalizationFunction:showthehistogramoftheprocessedimageThewholecode(GUI):functionvarargout=c(varargin)%Copyright2012Andonghui%CM-fileforc.fig%C,byitself,createsane
4、wCorraisestheexisting%singleton*.%H=CreturnsthehandletoanewCorthehandleto%theexistingsingleton*.%C('CALLBACK',hObject,eventData,handles,...)callsthelocal%functionnamedCALLBACKinC.Mwiththegiveninputarguments.%C('Property','Value',...)createsanewCorraisesthe%existingsingleton*
5、.Startingfromtheleft,propertyvaluepairsare%appliedtotheGUIbeforec_OpeningFunctiongetscalled.An%unrecognizedpropertynameorinvalidvaluemakespropertyapplication%stop.Allinputsarepassedtoc_OpeningFcnviavarargin.%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone%instanceto
6、run(singleton)".%Seealso:GUIDE,GUIDATA,GUIHANDLES%Edittheabovetexttomodifytheresponsetohelpc%LastModifiedbyGUIDEv2.529-Mar-201212:10:00%Begininitializationcode-DONOTEDITgui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn'
7、,@c_OpeningFcn,...'gui_OutputFcn',@c_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});e
8、nd%Endinitializationcode-DONOTEDIT%---Executesjustbeforecismadevisible.func