第 12 章 基于块匹配的全景图像拼接–Matlab深度学习实战图像处理应用GUI实现
效果如图所示


完整案例


主函数文件
Gui_Main.m文件

function varargout = Gui_Main(varargin)
% GUI_MAIN MATLAB code for Gui_Main.fig
%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
%      singleton*.
%
%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
%      the existing singleton*.
%
%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_MAIN.M with the given input arguments.
%
%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Gui_Main_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help Gui_Main% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...'gui_OutputFcn',  @Gui_Main_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before Gui_Main is made visible.
function Gui_Main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Gui_Main (see VARARGIN)% Choose default command line output for Gui_Main
clc; warning off all;
axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);handles.output = hObject;
handles.file = [];
handles.MStitch = [];
handles.grayResult = [];
handles.RGBResult = [];
handles.grayListResult = [];
handles.RGBListResult = [];% Update handles structure
guidata(hObject, handles);% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = Gui_Main_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Get default command line output from handles structure
varargout{1} = handles.output;% --------------------------------------------------------------------
function uipushtool1_ClickedCallback(hObject, eventdata, handles)
% hObject    handle to uipushtool1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...'*.*','All Files' }, '保存结果', ...'Result\result_gui.jpg');
if isempty(filename)return;
end
file = fullfile(pathname, filename);
f = getframe(gcf);
f = frame2im(f);
imwrite(f, file);
msgbox('保存GUI结果图像成功!', '提示信息', 'modal');% --------------------------------------------------------------------
function uipushtool2_ClickedCallback(hObject, eventdata, handles)
% hObject    handle to uipushtool2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);handles.file = [];
handles.MStitch = [];
handles.grayResult = [];
handles.RGBResult = [];
handles.grayListResult = [];
handles.RGBListResult = [];[filename, pathname, filterindex] = uigetfile({'*.jpg;*.tif;*.png;*.gif;*.bmp','All Image Files';...'*.*','All Files' }, '选择待处理图像', ...'.\\images\\', 'MultiSelect', 'on');
if ~isa(filename, 'cell') && isequal(filename, 0)return;
endfile = File_Process(filename, pathname);
if length(file) < 2msgbox('请选择至少两幅图像!', '提示信息', 'modal');return;
end
Img1 = imread(file{1});
Img2 = ImageList(file);
axes(handles.axes1);
imshow(Img1); title('图像序列1', 'FontWeight', 'Bold');
axes(handles.axes2);
imshow(Img2); title('图像序列2', 'FontWeight', 'Bold');handles.Img1 = Img1;
handles.Img2 = Img2;
handles.file = file;
guidata(hObject, handles);% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);handles.file = [];
handles.MStitch = [];
handles.grayResult = [];
handles.RGBResult = [];dname = uigetdir('.\\images\\风景图像', '请选择待处理图像文件夹:');
if dname == 0return;
end
df = ls(dname);
if length(df) > 2for i = 1 : size(df, 1)if strfind(df(i, :), '.db');df(i, :) = [];break;endendif length(df) > 2filename = fullfile(dname, df(end, :));pathname = [dname '\'];elsemsgbox('请选择至少两幅图像!', '提示信息', 'modal');return;end
elsemsgbox('请选择至少两幅图像!', '提示信息', 'modal');return;
end
file = File_Process(filename, pathname);
if length(file) < 2msgbox('请选择至少两幅图像!', '提示信息', 'modal');return;
end
Img1 = imread(file{1});
Img2 = ImageList(file);
axes(handles.axes1);
imshow(Img1); title('图像序列1', 'FontWeight', 'Bold');
axes(handles.axes2);
imshow(Img2); title('图像序列2', 'FontWeight', 'Bold');handles.Img1 = Img1;
handles.Img2 = Img2;
handles.file = file;
guidata(hObject, handles);% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.
function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% --- Executes on mouse press over axes background.
function axes2_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to axes2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% --- Executes on mouse press over axes background.
function axes3_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to axes3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% --- Executes on mouse press over axes background.
function axes4_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to axes4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)if isempty(handles.file)msgbox('请先载入图像!', '提示信息', 'modal');return;
end
if isempty(handles.MStitch)msgbox('请先进行图像匹配!', '提示信息', 'modal');return;
end
if ~isempty(handles.grayResult)msgbox('灰度拼接图像已完成!', '提示信息', 'modal');return;
end
if length(handles.file)[MStitch, result] = GrayMain_Process(handles.MStitch, ...handles.W_box, handles.H_box, handles.bdown);
end
grayResult = im2uint8(mat2gray(result));
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
imshow(grayResult, []);
title('灰度图像拼接结果', 'FontWeight', 'Bold');handles.grayResult = grayResult;
guidata(hObject, handles);msgbox('灰度拼接图像完成!', '提示信息', 'modal');% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)if isempty(handles.file)msgbox('请先载入图像!', '提示信息', 'modal');return;
end
if isempty(handles.MStitch)msgbox('请先进行图像匹配!', '提示信息', 'modal');return;
end
if ~isempty(handles.RGBResult)msgbox('彩色拼接图像已完成!', '提示信息', 'modal');return;
endif length(handles.file)[MStitch, result] = RGBMain_Process(handles.MStitch, ...handles.W_box, handles.H_box, handles.bdown);
end
RGBResult = im2uint8(mat2gray(result));
axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
imshow(RGBResult, []);
title('彩色图像拼接结果', 'FontWeight', 'Bold');handles.RGBResult = RGBResult;
guidata(hObject, handles);msgbox('彩色拼接图像完成!', '提示信息', 'modal');% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)if isempty(handles.grayResult) && isempty(handles.RGBResult)msgbox('请先拼接处理图像!', '提示信息', 'modal');return;
endif ~isempty(handles.grayResult)figure(1); imshow(handles.grayResult, []);title('灰度图像拼接结果', 'FontWeight', 'Bold');
end
if ~isempty(handles.RGBResult)figure(2); imshow(handles.RGBResult, []);title('彩色图像拼接结果', 'FontWeight', 'Bold');
end
if ~isempty(handles.grayListResult)figure(3); imshow(handles.grayListResult, []);title('序列灰度图像拼接结果', 'FontWeight', 'Bold');
end
if ~isempty(handles.RGBListResult)figure(4); imshow(handles.RGBListResult, []);title('序列彩色图像拼接结果', 'FontWeight', 'Bold');
end% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)if isempty(handles.grayResult) && isempty(handles.RGBResult)msgbox('请先拼接处理图像!', '提示信息', 'modal');return;
end
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...'*.*','All Files' }, '保存结果', ...'Result\result.jpg');
if isempty(filename)return;
end
[pathstr, name, ext] = fileparts(filename);if ~isempty(handles.grayResult)file = fullfile(pathname, [name, '_gray', ext]);imwrite(handles.grayResult, file);
end
if ~isempty(handles.RGBResult)file = fullfile(pathname, [name, '_rgb', ext]);imwrite(handles.RGBResult, file);
end
if ~isempty(handles.grayListResult)file = fullfile(pathname, [name, '_grayList', ext]);imwrite(handles.grayListResult, file);
end
if ~isempty(handles.RGBListResult)file = fullfile(pathname, [name, '_rgbList', ext]);imwrite(handles.RGBListResult, file);
endmsgbox('保存拼接图像成功!', '提示信息', 'modal');% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)if isempty(handles.file)msgbox('请先载入图像!', '提示信息', 'modal');return;
end
if ~isempty(handles.MStitch)msgbox('图像匹配已完成!', '提示信息', 'modal');return;
endfile = handles.file;
im1 = imread(file{1});
MStitch.imrgb1 = double(im1);
im1 = rgb2gray(im1);
MStitch.im1 = double(im1);
[Pheight, Pwidth] = size(im1);
MStitch.Pwidth = Pwidth;
MStitch.Pheight = Pheight;
MStitch.W_min = round(0.60*Pwidth);
MStitch.W_max = round(0.83*Pwidth);
MStitch.H_min = round(0.98*Pheight);
MStitch.minval = 255;
im2 = imread(file{2});
MStitch.imrgb2 = double(im2);
im2 = rgb2gray(im2);
im2 = double(im2);
MStitch.im2 = double(im2);
[W_box, H_box, bdown, MStitch] = Fun_Match(im2, MStitch);
msgbox('图像匹配完成!', '提示信息', 'modal');
handles.W_box = W_box;
handles.H_box = H_box;
handles.bdown = bdown;
handles.MStitch = MStitch;
guidata(hObject, handles);% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
choice = questdlg('您确定要退出图像拼接系统?', ...'退出选项', ...'退出', '取消', '取消');
switch choicecase '退出'close all;case '取消'return;
end% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)if isempty(handles.file)msgbox('请先载入图像!', '提示信息', 'modal');return;
end
if ~isempty(handles.grayListResult)msgbox('序列灰度图像拼接已完成!', '提示信息', 'modal');return;
endif length(handles.file) == 2if ~isempty(handles.grayResult)msgbox('灰度拼接图像已完成!', '提示信息', 'modal');return;endif isempty(handles.MStitch)msgbox('请先进行图像匹配!', '提示信息', 'modal');return;end[MStitch, result] = GrayMain_Process(handles.MStitch, ...handles.W_box, handles.H_box, handles.bdown);grayResult = im2uint8(mat2gray(result));axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);imshow(grayResult, []);title('灰度图像拼接结果', 'FontWeight', 'Bold');handles.grayResult = grayResult;guidata(hObject, handles);msgbox('灰度拼接图像完成!', '提示信息', 'modal');
else[MStitch, result] = GrayListMain_Process(handles.file);grayListResult = im2uint8(mat2gray(result));axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);imshow(grayListResult, []);title('序列灰度图像拼接结果', 'FontWeight', 'Bold');handles.grayListResult = grayListResult;guidata(hObject, handles);msgbox('序列灰度拼接图像完成!', '提示信息', 'modal');
end% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if isempty(handles.file)msgbox('请先载入图像!', '提示信息', 'modal');return;
end
if ~isempty(handles.RGBListResult)msgbox('序列彩色图像拼接已完成!', '提示信息', 'modal');return;
endif length(handles.file) == 2if ~isempty(handles.RGBResult)msgbox('彩色拼接图像已完成!', '提示信息', 'modal');return;endif isempty(handles.MStitch)msgbox('请先进行图像匹配!', '提示信息', 'modal');return;end[MStitch, result] = RGBMain_Process(handles.MStitch, ...handles.W_box, handles.H_box, handles.bdown);RGBResult = im2uint8(mat2gray(result));axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);imshow(RGBResult, []);title('彩色图像拼接结果', 'FontWeight', 'Bold');handles.grayResult = grayResult;guidata(hObject, handles);msgbox('彩色拼接图像完成!', '提示信息', 'modal');
else[MStitch, result] = RGBListMain_Process(handles.file);RGBListResult = im2uint8(mat2gray(result));axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);imshow(RGBListResult, []);title('序列彩色图像拼接结果', 'FontWeight', 'Bold');handles.RGBListResult = RGBListResult;guidata(hObject, handles);msgbox('序列彩色拼接图像完成!', '提示信息', 'modal');
end


全景图像拼接效果如图

本文配套源码及实现案例–下载–>传送门

第 12 章 基于块匹配的全景图像拼接--Matlab深度学习实战图像处理应用相关推荐

  1. 【第 13 章 基于霍夫曼图像压缩重建--Matlab深度学习实战图像处理应用】

    基于霍夫曼图像压缩重建 部分参考来源: https://blog.csdn.net/qq_59747472/article/details/121890265 为了节省空间,在对数据进行编码时,可以对 ...

  2. 第 09 章 基于特征匹配的英文印刷字符识别 MATLAB深度学习实战案例

    基于特征匹配的英文印刷字符识别 MATLAB深度学习实战 话不多讲,直接开撸代码 MainForm函数 function MainForm global bw; global bl; global b ...

  3. 【第 07 章 基于主成分分析的人脸二维码识别MATLAB深度学习实战案例】

    基于主成分分析的人脸二维码识别MATLAB深度学习实战案例 人脸库 全套文件资料目录下载链接–>传送门 本文全文源码下载[链接–>传送门] 如下分析: 主文件 function varar ...

  4. 第 24 章 基于 Simulink 进行图像和视频处理--matlab深度学习实战整理

    Simulink是美国Mathworks公司推出的MATLAB中的一种可视化仿真工具.Simulink是一个模块图环境,用于多域仿真以及基于模型的设计.它支持系统设计.仿真.自动代码生成以及嵌入式系统 ...

  5. 第 21 章 路面裂缝检测识别系统设计--matlab深度学习实战

    在汽车智能技术.汽车新能源技术.汽车电子这个群雄逐鹿的赛道.智能驾驶技术的要求也在不断的提升. 智能车辆教学平台.智能网联教学平台.汽车电子教学设备.在环仿真系统,目前主流的系统有很多,常用的基础部分 ...

  6. 【控制】《多无人机协同控制技术》周伟老师-第12章-基于 Multi-Agent 的多无人机协同控制仿真平台的设计与实现

    第11章 回到目录 无 第12章-基于 Multi-Agent 的多无人机协同控制仿真平台的设计与实现 12.1 多无人机协同控制视景仿真系统设计 12.1.1 多无人机协同控制视景仿真系统功能描述 ...

  7. 基于人脸的常见表情识别(1)——深度学习基础知识

    基于人脸的常见表情识别(1)--深度学习基础知识 神经网络 1. 感知机 2. 多层感知机与反向传播 卷积神经网络 1. 全连接神经网络的2大缺陷 2. 卷积神经网络的崛起 卷积神经网络的基本网络层 ...

  8. 《Web安全之深度学习实战》笔记:第十三章 DGA域名识别

    本小节是讲解DGA域名的识别,在<web安全之机器学习入门>中,曾经通过多节来讲解DGA域名,相关笔记如下: <Web安全之机器学习入门>笔记:第七章 7.6朴素贝叶斯检测DG ...

  9. 《深度学习实战》第1章 深度学习的发展介绍

    参考书籍<深度学习实战>杨云.杜飞著 第1章 深度学习的发展介绍 介绍 python是一种非常简单易学的解释性语言.由于强大的开源库支持(numpy,scipy,matplotlib),其 ...

最新文章

  1. linux rpm找不到命令_linux环境下 python环境import找不到自定义的模块
  2. Vim替换小技巧(兼浅谈Vim哲学)
  3. c++加载python模块,但是PyImport_ImportModule老返回NULL
  4. tomcat怎么平滑更新项目_tomcat_deploy 平滑启动脚本
  5. Oracle 12C CDB、PDB常用管理命令
  6. 【转】医学影像调窗技术!!!!
  7. 自加一运算_C语言i++、++i混合运算老手未必全掌握,看了你就明白了
  8. 【OpenCV入门教程之一】 OpenCV 2.4.8 +VS2010的开发环境配置
  9. DNS 服务器 4013警告信息的解决
  10. HDU ACM 2647 Reward (topology----拓扑排序)
  11. bboss v5.5.3 发布,Elasticsearch Rest Client
  12. 善用佳软:高效能人士的软件应用之道
  13. win7眼睛保护色设置方法
  14. 短视频直播app源码——软件系统开发方案
  15. 文字转语音怎么做?分享三种配音方法,真人语音很逼真
  16. DAY15:尚学堂高琪JAVA(129~131)队列,Enumeration和Hashtable
  17. synchronized和Lock的异同
  18. 电影《不夜城》的主题曲:金城武、山本未来主演
  19. 搭建asp会议签到系统:第一章 账密登录
  20. 成功的那些事儿--绪言

热门文章

  1. 使用Android Studio 查找并删除无用的资源文件(包括drawable里面)
  2. 权限系统--前后端分离
  3. 云压广告怎么彻底删除_彻底删除微信记录有哪些方法,听听专业人士怎么说!...
  4. 一家微型计算机公司的需求方程,微观经济学答案 全
  5. PXI 429总线卡 航空总线卡 底板板+功能子卡结构 底板原理图+PCB 子卡原理图+PCB
  6. 知识补给站:处理器微架构
  7. l1正则化matlab工具箱,正则化matlab工具包
  8. ntp时间同步会导致mysql关闭吗?_NTP时间同步
  9. AM2302+STM32驱动程序
  10. 音视频处理三剑客之 AEC:回声产生原因及回声消除原理