1 Star 0 Fork 0

lwjxp / Digital_Image_Processing_MatlabGUI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Digital_Image_Processing.m 7.19 KB
一键复制 编辑 原始数据 按行查看 历史
子愚 提交于 2015-05-25 12:52 . ## - Edion 0.6 ##
function varargout = Digital_Image_Processing(varargin)
% DIGITAL_IMAGE_PROCESSING MATLAB code for Digital_Image_Processing.fig
%
%
%
% Edit the above text to modify the response to help Digital_Image_Processing
% Last Modified by GUIDE v2.5 25-May-2015 12:07:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Digital_Image_Processing_OpeningFcn, ...
'gui_OutputFcn', @Digital_Image_Processing_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Digital_Image_Processing is made visible.
function Digital_Image_Processing_OpeningFcn(hObject, ~, handles, varargin)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
global Old_FilePath;
global Old_SavePath;
global OriginPath;
OriginPath=pwd;
Old_FilePath=pwd;
Old_SavePath=pwd;
global Original_Image;
Original_Image=[];
global Current_Image;
Current_Image=[];
global RGB_Flag;
RGB_Flag=[];
set(handles.InfoText,'string','准备就绪');
% UIWAIT makes Digital_Image_Processing wait for user response (see UIRESUME)
% --- Outputs from this function are returned to the command line.
function varargout = Digital_Image_Processing_OutputFcn(~, ~, handles)
varargout{1} = handles.output;
% 图标,打开文件
function Open_File_ClickedCallback(~, ~, handles)
global Old_FilePath;
global OriginPath;
global Original_Image;
global Current_Image;
global RGB_Flag;
Original_Image=cell(1,1);
if isempty(Old_FilePath)
Old_FilePath=OriginPath;
end
cd(Old_FilePath);
[file_shortname, file_path] = uigetfile( {'*.bmp;*.cur;*.gif;*.hdf;*.ico;*.jpeg;*.jpg;*.pbm;*.pcx;*.pgm;*.png;*.ppm;*.ras;*.tiff;*.xwd', '所有图像文件(*.bmp,*.cur,*.gif,*.hdf,*.ico,*.jpeg,*.jpg,*.pbm,*.pcx,*.pgm,*.png,*.ppm,*.ras,*.tiff,*.xwd)'; '*.*', 'All Files (*.*)'}, '选择图像文件');
cd(OriginPath);
if(file_shortname==0)
errordlg('错误');
else
file_fullname=strcat(file_path,file_shortname);
Old_FilePath=file_path;
Old_FilePath(end)=[];
end
temp=imread(file_fullname);
temp=im2double(temp);
temp_flag=size(size(temp));
RGB_Flag=temp_flag(2);
Current_Image=temp;
Original_Image{1, 1}=temp;
figure('NumberTitle', 'off', 'Name', '原始图像','Tag','OrignalImage_Fig');
imshow(Original_Image{1, 1});
set(handles.InfoText,'string',strcat('已打开图片:',file_fullname));
% 图标,保存图片
function Save_Figure_ClickedCallback(~, ~,handles)
global Old_FilePath;
global OriginPath;
global Current_Image;
cd(Old_FilePath);
[save_file_shortname, save_file_path] = uiputfile({'*.bmp','*.bmp';'*.cur','*.cur';'*.gif','*.gif';'*.hdf','*.hdf';'*.ico','*.ico';'*.jpeg','*.jpeg';'*.jpg','*.jpg';'*.png','*.png'; '*.*', 'All Files (*.*)'}, '选择图像文件');
cd(OriginPath);
if save_file_path~=0
save_file_fullname= [save_file_path save_file_shortname];
save_Image = uint8(255*Current_Image);
imwrite(save_Image,save_file_fullname);
set(handles.InfoText,'string',strcat('已保存图片:',save_file_fullname));
else
errordlg('错误');
return
end
% 目录,打开文件
function Menu_Open_File_Callback(~, ~, handles)
global Old_FilePath;
global OriginPath;
global Original_Image;
global Current_Image;
global RGB_Flag;
Original_Image=cell(1,1);
if isempty(Old_FilePath)
Old_FilePath=OriginPath;
end
cd(Old_FilePath);
[file_shortname, file_path] = uigetfile( {'*.bmp;*.cur;*.gif;*.hdf;*.ico;*.jpeg;*.jpg;*.pbm;*.pcx;*.pgm;*.png;*.ppm;*.ras;*.tiff;*.xwd', '所有图像文件(*.bmp,*.cur,*.gif,*.hdf,*.ico,*.jpeg,*.jpg,*.pbm,*.pcx,*.pgm,*.png,*.ppm,*.ras,*.tiff,*.xwd)'; '*.*', 'All Files (*.*)'}, '选择图像文件');
cd(OriginPath);
if(file_shortname==0)
errordlg('错误');
else
file_fullname=strcat(file_path,file_shortname);
Old_FilePath=file_path;
Old_FilePath(end)=[];
end
temp=imread(file_fullname);
temp=im2double(temp);
temp_flag=size(size(temp));
RGB_Flag=temp_flag(2);
Current_Image=temp;
Original_Image{1, 1}=temp;
figure('NumberTitle', 'off', 'Name', '原始图像','Tag','OrignalImage_Fig');
imshow(Original_Image{1, 1});
set(handles.InfoText,'string',strcat('已打开图片:',file_fullname));
% 目录,保存图片
function Menu_Save_File_Callback(~, ~, handles)
global Old_FilePath;
global OriginPath;
global Current_Image;
cd(Old_FilePath);
[save_file_shortname, save_file_path] = uiputfile({'*.bmp','*.bmp';'*.cur','*.cur';'*.gif','*.gif';'*.hdf','*.hdf';'*.ico','*.ico';'*.jpeg','*.jpeg';'*.jpg','*.jpg';'*.png','*.png'; '*.*', 'All Files (*.*)'}, '选择图像文件');
cd(OriginPath);
if save_file_path~=0
save_file_fullname= [save_file_path save_file_shortname];
save_Image = uint8(255*Current_Image);
imwrite(save_Image,save_file_fullname);
set(handles.InfoText,'string',strcat('已保存图片:',save_file_fullname));
else
errordlg('错误');
return
end
% 灰度变换
function Menu_GrayTrans_Callback(~, ~, ~)
GrayTrans();
% 对比度拉伸
function Menu_StretchTrans_Callback(~, ~, ~)
StretchTrans();
% 对数变换
function Menu_LogTrans_Callback(~, ~, ~)
LogTrans();
% 显示直方图
function Menu_Show_Histogram_Callback(~, ~, ~)
global Original_Image;
global Current_Image;
global RGB_Flag;
Saved_Num=size(Original_Image,2);
if isempty(Current_Image)
Current_Image=Original_Image{1,Saved_Num};
end
if RGB_Flag==3
temp_Img= rgb2gray(Current_Image);
figure('NumberTitle', 'off', 'Name', 'RGB转灰度图像','Tag','RGB2Gray_Fig');
imshow(temp_Img);
else
temp_Img=Current_Image;
end
h=imhist(temp_Img,256);
horz=linspace(0,255,256);
figure('NumberTitle', 'off', 'Name', '直方图','Tag','Hist_Fig');
plot(horz,h');
% 直方图均衡化
function Menu_Hist_Equal_Callback(~, ~, ~)
global Original_Image;
global Current_Image;
global Treated_Image;
global RGB_Flag;
Saved_Num=size(Original_Image,2);
if isempty(Current_Image)
Current_Image=Original_Image{1,Saved_Num};
end
if RGB_Flag==3
temp_Img= rgb2gray(Current_Image);
else
temp_Img=Current_Image;
end
Treated_Image=histeq(temp_Img,256);
figure('NumberTitle', 'off', 'Name', '直方图均衡化','Tag','HistEq_Fig');
imshow(Treated_Image);
h=imhist(Treated_Image,256);
horz=linspace(0,255,256);
figure('NumberTitle', 'off', 'Name', '直方图均衡化的直方图','Tag','Hist_Fig');
plot(horz,h');
% 对比度受限的自适应直方图均衡化
function Menu_ContrastLimited_Adaptive_HistEqual_Callback(~, ~, ~)
ContrastLimited_Adaptive_HistEqual();
% 阈值分割
function Menu_Threshold_Segment_Callback(~, ~, ~)
Threshold_Segment();
% 边缘提取
function Meun_Contour_Extraction_Callback(~, ~, ~)
Contour_Extraction();
% 形态学方法
function Menu_Morphology_Method_Callback(~, ~, ~)
Morphology_Method();
% 边缘检测
function Edge_Detection_Callback(~, ~, ~)
Edge_Detection();
% 使用imfliter函数进行线性空间滤波
function Menu_Imfilter_Callback(hObject, eventdata, handles)
Imfliter_Function();
% 预定义的空间滤波工具箱
function Menu_Prepared_Filters_Callback(hObject, eventdata, handles)
Prepared_Filters();
% Ordfilt函数实现的非线性滤波
function Menu_Ordfilt_Callback(hObject, eventdata, handles)
Ordfilt_Function();
Matlab
1
https://gitee.com/lwjxp/Digital_Image_Processing_MatlabGUI.git
git@gitee.com:lwjxp/Digital_Image_Processing_MatlabGUI.git
lwjxp
Digital_Image_Processing_MatlabGUI
Digital_Image_Processing_MatlabGUI
master

搜索帮助