matlab 图像处理算法集合原创GUI.docx

上传人:b****6 文档编号:3903542 上传时间:2022-11-26 格式:DOCX 页数:36 大小:86.39KB
下载 相关 举报
matlab 图像处理算法集合原创GUI.docx_第1页
第1页 / 共36页
matlab 图像处理算法集合原创GUI.docx_第2页
第2页 / 共36页
matlab 图像处理算法集合原创GUI.docx_第3页
第3页 / 共36页
matlab 图像处理算法集合原创GUI.docx_第4页
第4页 / 共36页
matlab 图像处理算法集合原创GUI.docx_第5页
第5页 / 共36页
点击查看更多>>
下载资源
资源描述

matlab 图像处理算法集合原创GUI.docx

《matlab 图像处理算法集合原创GUI.docx》由会员分享,可在线阅读,更多相关《matlab 图像处理算法集合原创GUI.docx(36页珍藏版)》请在冰豆网上搜索。

matlab 图像处理算法集合原创GUI.docx

matlab图像处理算法集合原创GUI

通过点击菜单实现各种功能

functionvarargout=imageprocessinggui(varargin)

%IMAGEPROCESSINGGUIM-fileforimageprocessinggui.fig

%IMAGEPROCESSINGGUI,byitself,createsanewIMAGEPROCESSINGGUIorraisestheexisting

%singleton*.

%

%H=IMAGEPROCESSINGGUIreturnsthehandletoanewIMAGEPROCESSINGGUIorthehandleto

%theexistingsingleton*.

%

%IMAGEPROCESSINGGUI('CALLBACK',hObject,eventData,handles,...)callsthelocal

%functionnamedCALLBACKinIMAGEPROCESSINGGUI.Mwiththegiveninputarguments.

%

%IMAGEPROCESSINGGUI('Property','Value',...)createsanewIMAGEPROCESSINGGUIorraisesthe

%existingsingleton*.Startingfromtheleft,propertyvaluepairsare

%appliedtotheGUIbeforeimageprocessinggui_OpeningFcngetscalled.An

%unrecognizedpropertynameorinvalidvaluemakespropertyapplication

%stop.Allinputsarepassedtoimageprocessinggui_OpeningFcnviavarargin.

%

%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone

%instancetorun(singleton)".

%

%Seealso:

GUIDE,GUIDATA,GUIHANDLES

%Edittheabovetexttomodifytheresponsetohelpimageprocessinggui

%LastModifiedbyGUIDEv2.521-May-201220:

51:

04

%Begininitializationcode-DONOTEDIT

gui_Singleton=1;

gui_State=struct('gui_Name',mfilename,...

'gui_Singleton',gui_Singleton,...

'gui_OpeningFcn',@imageprocessinggui_OpeningFcn,...

'gui_OutputFcn',@imageprocessinggui_OutputFcn,...

'gui_LayoutFcn',[],...

'gui_Callback',[]);

ifnargin&&ischar(varargin{1})

gui_State.gui_Callback=str2func(varargin{1});

end

ifnargout

[varargout{1:

nargout}]=gui_mainfcn(gui_State,varargin{:

});

else

gui_mainfcn(gui_State,varargin{:

});

end

%Endinitializationcode-DONOTEDIT

%---Executesjustbeforeimageprocessingguiismadevisible.

functionimageprocessinggui_OpeningFcn(hObject,eventdata,handles,varargin)

%Thisfunctionhasnooutputargs,seeOutputFcn.

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%varargincommandlineargumentstoimageprocessinggui(seeVARARGIN)

%Choosedefaultcommandlineoutputforimageprocessinggui

handles.output=hObject;

%Updatehandlesstructure

guidata(hObject,handles);

%UIWAITmakesimageprocessingguiwaitforuserresponse(seeUIRESUME)

%uiwait(handles.figure1);

%---Outputsfromthisfunctionarereturnedtothecommandline.

functionvarargout=imageprocessinggui_OutputFcn(hObject,eventdata,handles)

%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);

%hObjecthandletofigure

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%Getdefaultcommandlineoutputfromhandlesstructure

varargout{1}=handles.output;

%javaFrame=get(gcf,'JavaFrame');

%set(javaFrame,'Maximized',1);

%--------------------------------------------------------------------

functionUntitled_1_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_1(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_5_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_5(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_15_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_15(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_25_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_25(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionGradientimage_Callback(hObject,eventdata,handles)

%hObjecthandletoGradientimage(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

globalim

axes(handles.axes1);

clareset;

axes(handles.axes2);

clareset;

axes(handles.axes3);

clareset;

axes(handles.axes4);

clareset;

P=im;

d=size(P);

if(d(3)>1)

P=rgb2gray(P);

end

axes(handles.axes1);

imshow(P);

title('灰度图像');

P=double(P);

[Px,Py]=gradient(P);

G=sqrt(Px.*Px+Py.*Py);

P=G;

P=uint8(P);

axes(handles.axes1);

imshow(P);

title('梯度图像1');

tou=input('inputthresholdtou=');

bh=input('inputaconstantintensitynearertowhitebh=');

P1=P;

k=find(G>=tou);

P1(k)=bh;

axes(handles.axes2);

imshow(P1);

title('梯度图像2');

bl=input('inputaconstantintensitynearertoblackbl=');

P2=P;

h=find(G>=tou);

P2(h)=bh;

l=find(G

P2(l)=bl;

axes(handles.axes3);

imshow(P2);

title('梯度图像3');

P3=zeros(d

(1),d

(2));

fori=1:

d

(1)

forj=1:

d

(2)

if(G(i,j)>=tou)

P3(i,j)=bh;

else

P3(i,j)=bl;

end

end

end

P3=uint8(P3);

axes(handles.axes4);

imshow(P3);

title('梯度图像4');

%--------------------------------------------------------------------

functionUntitled_27_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_27(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_16_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_16(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_21_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_21(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_6_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_6(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_12_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_12(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

%--------------------------------------------------------------------

functionUntitled_2_Callback(hObject,eventdata,handles)

%hObjecthandletoUntitled_2(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

globalS

globalim

axes(handles.axes1);

clareset;

axes(handles.axes2);

clareset;

axes(handles.axes3);

clareset;

axes(handles.axes4);

clareset;

[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.gif';'*.tif';'*.png';'*jpeg'},'选择图片');

ifisequal(filename,0)

disp('Userselectedcanceled');

else

str=[pathnamefilename];

%globalS%设置一个全局变量S,保存初始图像路径,以便之后的还原操作

S=str;

im=imread(str);

axes(handles.axes1);

imshow(im);

title('原图像');

handles.img=im;

guidata(hObject,handles);

end

%--------------------------------------------------------------------

functionsave_Callback(hObject,eventdata,handles)

%hObjecthandletosave(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

newfig1=figure;

new_h1=copyobj(handles.axes1,newfig1);

set(new_h1,'Units','default','Position','default');

hp=getframe(new_h1);

[filename1,pathname1]=uiputfile({'*.bmp','Bitmap(*.bmp)';...

'*.jpg','JPEG(*.jpg)';...

'*.gif','GIF(*.gif)';...

'*.*','AllFiles(*.*)'},...

'SavePicture1','Picture1_1');

iffilename1==0

close(newfig1);

return

else

imwrite(hp.cdata,fullfile(pathname1,filename1));

close(newfig1);

end

%--------------------------------------------------------------------

functionquit_Callback(hObject,eventdata,handles)

%hObjecthandletoquit(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

clc;

closeall;

close(gcf);

clear;

%--------------------------------------------------------------------

functionlinearTran_Callback(hObject,eventdata,handles)

%hObjecthandletolinearTran(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

globalim

axes(handles.axes1);

clareset;

axes(handles.axes2);

clareset;

axes(handles.axes3);

clareset;

axes(handles.axes4);

clareset;

P=im;

d=size(P);

if(d(3)>1)

P=rgb2gray(P);

end

axes(handles.axes1);

imshow(P);

title('灰度图像');

P=double(P);

[mn]=size(P);

g=zeros(m,n);

%B=input('inputthestorageofeachpixel:

');

B=8;

bmin=min(min(P));

bmax=max(max(P));

fori=1:

m

forj=1:

n

g(i,j)=(2.^B-1)*(P(i,j)-bmin)/(bmax-bmin);

end

end

g=uint8(g);

axes(handles.axes2);

imshow(g);

title('经线性变换后的图像');

%--------------------------------------------------------------------

functionlimitlintran_Callback(hObject,eventdata,handles)

%hObjecthandletolimitlintran(seeGCBO)

%eventdatareserved-tobedefinedinafutureversionofMATLAB

%handlesstructurewithhandlesanduserdata(seeGUIDATA)

globalim

axes(han

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1