图像处理操作界面文档格式.docx
《图像处理操作界面文档格式.docx》由会员分享,可在线阅读,更多相关《图像处理操作界面文档格式.docx(36页珍藏版)》请在冰豆网上搜索。
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{:
%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);
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=handles.output;
%javaFrame=get(gcf,'
JavaFrame'
);
%set(javaFrame,'
Maximized'
1);
%--------------------------------------------------------------------
functionUntitled_1_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_1(seeGCBO)
functionUntitled_5_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_5(seeGCBO)
functionUntitled_15_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_15(seeGCBO)
functionUntitled_25_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_25(seeGCBO)
functionGradientimage_Callback(hObject,eventdata,handles)
%hObjecthandletoGradientimage(seeGCBO)
globalim
axes(handles.axes1);
clareset;
axes(handles.axes2);
axes(handles.axes3);
axes(handles.axes4);
P=im;
d=size(P);
if(d(3)>
1)
P=rgb2gray(P);
imshow(P);
title('
灰度图像'
P=double(P);
[Px,Py]=gradient(P);
G=sqrt(Px.*Px+Py.*Py);
P=G;
P=uint8(P);
梯度图像1'
tou=input('
inputthresholdtou='
bh=input('
inputaconstantintensitynearertowhitebh='
P1=P;
k=find(G>
=tou);
P1(k)=bh;
imshow(P1);
梯度图像2'
bl=input('
inputaconstantintensitynearertoblackbl='
P2=P;
h=find(G>
P2(h)=bh;
l=find(G<
tou);
P2(l)=bl;
imshow(P2);
梯度图像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
P3=uint8(P3);
imshow(P3);
梯度图像4'
functionUntitled_27_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_27(seeGCBO)
functionUntitled_16_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_16(seeGCBO)
functionUntitled_21_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_21(seeGCBO)
functionUntitled_6_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_6(seeGCBO)
functionUntitled_12_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_12(seeGCBO)
functionUntitled_2_Callback(hObject,eventdata,handles)
%hObjecthandletoUntitled_2(seeGCBO)
globalS
[filename,pathname]=uigetfile({'
*.jpg'
;
'
*.bmp'
*.gif'
*.tif'
*.png'
*jpeg'
},'
选择图片'
ifisequal(filename,0)
disp('
Userselectedcanceled'
str=[pathnamefilename];
%globalS%设置一个全局变量S,保存初始图像路径,以便之后的还原操作
S=str;
im=imread(str);
imshow(im);
原图像'
handles.img=im;
guidata(hObject,handles);
functionsave_Callback(hObject,eventdata,handles)
%hObjecthandletosave(seeGCBO)
newfig1=figure;
new_h1=copyobj(handles.axes1,newfig1);
set(new_h1,'
Units'
default'
Position'
hp=getframe(new_h1);
[filename1,pathname1]=uiputfile({'
Bitmap(*.bmp)'
...
JPEG(*.jpg)'
GIF(*.gif)'
*.*'
'
AllFiles(*.*)'
},...
SavePicture1'
Picture1_1'
iffilename1==0
close(newfig1);
return
imwrite(hp.cdata,fullfile(pathname1,filename1));
functionquit_Callback(hObject,eventdata,handles)
%hObjecthandletoquit(seeGCBO)
clc;
closeall;
close(gcf);
clear;
functionlinearTran_Callback(hObject,eventdata,handles)
%hObjecthandletolinearTran(seeGCBO)
[mn]=size(P);
g=zeros(m,n);
%B=input('
inputthestorageofeachpixel:
B=8;
bmin=min(min(P));
bmax=max(max(P));
m
n
g(i,j)=(2.^B-1)*(P(i,j)-bmin)/(bmax-bmin);
g=uint8(g);
imshow(g);
经线性变换后的图像'
functionlimitlintran_Callback(hObject,eventdata,handles)
%hObjecthandletolimitlintran(seeGCBO)
%handlesstructurewithhandlesanduserdata(seeGUID