简单数字图像处理系统.docx
《简单数字图像处理系统.docx》由会员分享,可在线阅读,更多相关《简单数字图像处理系统.docx(13页珍藏版)》请在冰豆网上搜索。
![简单数字图像处理系统.docx](https://file1.bdocx.com/fileroot1/2023-2/2/c16103aa-1dde-4f94-9778-5af7aef6556e/c16103aa-1dde-4f94-9778-5af7aef6556e1.gif)
简单数字图像处理系统
数字图像课程设计简单数字图像处理系统
functionvarargout=untitled(varargin)
%Begininitializationcode-DONOTEDIT
gui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',@untitled_OpeningFcn,...
'gui_OutputFcn',@untitled_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
%---Executesjustbeforeuntitledismadevisible.
functionuntitled_OpeningFcn(hObject,eventdata,handles,varargin)%界面初始化函数
setappdata(handles.figure1,'I',0);
%Thisfunctionhasnooutputargs,seeOutputFcn.
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%varargincommandlineargumentstountitled(seeVARARGIN)
%Choosedefaultcommandlineoutputforuntitled
handles.output=hObject;
%Updatehandlesstructure
guidata(hObject,handles);
%UIWAITmakesuntitledwaitforuserresponse(seeUIRESUME)
%uiwait(handles.figure1);
%---Outputsfromthisfunctionarereturnedtothecommandline.
functionvarargout=untitled_OutputFcn(hObject,eventdata,handles)%界面输出函数
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=handles.output;
%--------------------------------------------------------------------
functionm_file_Callback(hObject,eventdata,handles)
%hObjecthandletom_file(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionmy_file_open_Callback(hObject,eventdata,handles)
globalI;
[FileName,PathName]=uigetfile('*.bmp;*.jpg;*.tiff;*.gif');%弹出对话框得到打开的路径
I=imread(strcat(PathName,FileName));%打开得到的路径下的文件
imshow(I)
setappdata(handles.figure1,'I',I);
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionmy_file_save_Callback(hObject,eventdata,handles)
globalI;%这个是要保存的东西,一般是global的
[FileName,PathName]=uiputfile('*.bmp;*.jpg;*.tiff;*.gif');%弹出对话框的到保存的路径
imwrite(I,strcat(PathName,FileName));%存储到该路径下
%uigetfileOpenstandarddialogboxforretrievingfiles
%saveas(figure_handle,filename,fileformat)
%saveas(gcf,'picname','jpg')
%ifisequal(filename,0)||isequal(pathname,0)
%return;%如果点了取消
%else
%fpath=fullfile(pathname,filename);%获取全路径的另一种方法
%end
%I=getappdata(handles.figure1,'I');
%imwrite(I,fpath);%保存图片
%--------------------------------------------------------------------
functionmy_file_exit_Callback(hObject,eventdata,handles)
close(handles.figure1);%退出
%hObjecthandletomy_file_exit(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionmy_file_print_Callback(hObject,eventdata,handles)
%hObjecthandletomy_file_print(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)C:
\Users\swj\Documents\MATLAB\untitled.fig
%--------------------------------------------------------------------
functionm_image_Callback(hObject,eventdata,handles)
%hObjecthandletom_image(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionm_image_2bw_Callback(hObject,eventdata,handles)
%hObjecthandletom_image_2bw(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionm_image_tongji_Callback(hObject,eventdata,handles)%图像直方图的统计与绘制直方图反应灰度值与像素个数的关系
%[FileName,PathName]=uigetfile('*.bmp;*.jpg;*.tiff;*.gif');%弹出对话框得到打开的路径
%I=imread(strcat(PathName,FileName));%打开得到的路径下的文件
globalI;
A=rgb2gray(I);%将真彩色图像转换为灰度图像
%figure('Name','显示灰度图像')
subplot(2,2,1);imshow(I);title('原图');
%imshow(A);
[J,I]=histeq(A);
%imshow(J);
subplot(2,2,2);imhist(A,64);%提取图像中的直方图信息
title('直方图的统计');
%BW=bwperim(A,8);
%figure('name','周长')
%imshow(BW);
%--------------------------------------------------------------------
functionm_image_mianji_Callback(hObject,eventdata,handles)
globalI;
BW=bwperim(im2bw(I));%显示二值化后的图像
Area=bwarea(BW)
[labeled,numobjects]=bwlabel(BW,8);
BW=regionprops(labeled,'basic')
BW=BW.Area;
set(handles.mj,'String',strcat('区域面积=',num2str(BW)));
%--------------------------------------------------------------------
functionm_image_zhouchang_Callback(hObject,eventdata,handles)
%hObjecthandletom_image_zhouchang(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionjuli_Callback(hObject,eventdata,handles)
%hObjecthandletojuli(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionm_change_Callback(hObject,eventdata,handles)
%hObjecthandletom_change(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionm_change_ft_Callback(hObject,eventdata,handles)%普通傅里叶变换与逆变换
globalI;%傅里叶变换是将时域信号分解为不同频率的正弦和/余弦和的形式
subplot(2,2,1);%其通过在时域和频域来回切换图像
imshow(I);title('原图');
f=rgb2gray(I);
A=fftshift(fft2(f));
%figure;
subplot(2,2,2);
imshow(log(abs(A)),[8,10]);title('傅里叶变换图像');
%--------------------------------------------------------------------
functionm_change_fft_Callback(hObject,eventdata,handles)%快速普通傅里叶变换与逆变换
globalI;
subplot(2,2,1),imshow(I);title('原图');
f=rgb2gray(I);
%subplot(2,2,2),imshow(f);
F=fft2(f);%二维傅里叶变换
FS=fftshift(F);
S=log(1+abs(FS));%频谱
subplot(2,2,3);imshow(S,[]);title('快速傅里叶变换图像');
fr=real(ifft2(ifftshift(FS)));%二维傅里叶逆变换
ret=im2uint8(mat2gray(fr));
subplot(2,2,4),imshow(ret);title('快速傅里叶逆变换图像');
%--------------------------------------------------------------------
functionm_change_DCT_Callback(hObject,eventdata,handles)%离散余弦变换
globalI;
subplot(2,2,1),imshow(I);title('原图');
A=rgb2gray(I);%将其转为灰度
B=dct2(A);%==二维dct变换,即离散余弦变换
subplot(2,2,2),imshow(B);title('离散余弦变换图像')
%--------------------------------------------------------------------
functionm_change_xiaobo_Callback(hObject,eventdata,handles)%小波变换
globalI;%定义图片数据存储的全局变量
subplot(2,2,1);imshow(I);title('原始图像');
A=rgb2gray(I);
subplot(2,2,2);imshow(A);title('黑白图像');
[m,n]=wavedec2(A,3,'bior3.7');%多尺度二维小波分解
B=appcoef2(m,n,'bior3.7',2);%将低频取出进行二层的小波变换
subplot(2,2,3);imshow(B);title('二维离散小波变换2层');
C=appcoef2(m,n,'bior3.7',3);%将低频取出进行二层的小波变换
subplot(2,2,4);imshow(C);title('二维离散小波变换3层');
functionm_division_Callback(hObject,eventdata,handles)
%hObjecthandletom_division(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionm_division_line_Callback(hObject,eventdata,handles)%图像分割点线
globalI;
A=rgb2gray(I);%将彩色图转化成灰度图
B=immultiply(A,1.5);
subplot(2,2,1);imshow(I);title('原图');
subplot(2,2,2);imshow(B);title('点分割图片');
%--------------------------------------------------------------------
functionm_division_edge_Callback(hObject,eventdata,handles)%图像边缘检测提取图像高频分量
globalI;%定义图片数据存储的全局变量
A=rgb2gray(I);%图片用的是灰度图像
%[x,y]=size(A);
%BW=edge(A);
BW1=edge(A,'Canny',0.4,0.5)%edge调用Canny为检测算子判别阈值为0.5
BW2=edge(A,'log',0.4,0.5);%做阈值为0.07的高斯—拉普拉斯(Log)算法把
subplot(2,2,1),imshow(A);title('原图');
subplot(2,2,3),imshow(BW1);title('Canny算子边缘检测图像阀值0.5');
subplot(2,2,4),imshow(BW2);title('拉普拉斯算子边缘检测图像阀值0.5');
%--------------------------------------------------------------------
functionm_zengqiang_Callback(hObject,eventdata,handles)
%hObjecthandletom_zengqiang(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%--------------------------------------------------------------------
functionm_zengqiang_zhongzhi_Callback(hOguidebject,eventdata,handles)%中值滤波使图像在某一部分的频率信息通过,其他过低或过高都抑制
globalI;%滤除噪声滤除噪声保持图像边缘
J=rgb2gray(I);%将真彩色图像转换为灰度图像
A=medfilt2(J);%对躁声进行中值滤波
subplot(2,2,1);imshow(I);title('原图');
subplot(2,2,2);imshow(A);title('中值滤波后图像');
%--------------------------------------------------------------------
functionm_zengqiang_ditong_Callback(hObject,eventdata,handles)%低通滤波让图像使高频分量抑制,低频分量通过
globalI;%定义图片数据存储的全局变量
A=rgb2gray(I);%将真彩色图像转换为灰度图像
subplot(2,2,1);imshow(I);title('原图');
s=fftshift(fft2(A));
[a,b]=size(s);
a0=round(a/2);
b0=round(b/2);
d=10;
fori=1:
a
forj=1:
b
distance=sqrt((i-a