第 11 章 基于小波技术进行图像融合--MATLAB人工智能深度学习模块

在这里插入图片描述
matlab实现基于小波技术进行图像融合–人工智能深度学习模块
该案例相对简单。实现程序
% MAINFORM MATLAB code for MainForm.fig
% MAINFORM, by itself, creates a new MAINFORM or raises the existing
% singleton*.
%
% H = MAINFORM returns the handle to a new MAINFORM or the handle to
% the existing singleton*.
%
% MAINFORM(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in MAINFORM.M with the given input arguments.
%
% MAINFORM(‘Property’,‘Value’,…) creates a new MAINFORM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before MainForm_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to MainForm_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
函数文件
MainForm.m

function varargout = MainForm(varargin)
% MAINFORM MATLAB code for MainForm.fig
%      MAINFORM, by itself, creates a new MAINFORM or raises the existing
%      singleton*.
%
%      H = MAINFORM returns the handle to a new MAINFORM or the handle to
%      the existing singleton*.
%
%      MAINFORM('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAINFORM.M with the given input arguments.
%
%      MAINFORM('Property','Value',...) creates a new MAINFORM or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before MainForm_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to MainForm_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 MainForm


% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @MainForm_OpeningFcn, ...
                   'gui_OutputFcn',  @MainForm_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 MainForm is made visible.
function MainForm_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 MainForm (see VARARGIN)

% Choose default command line output for MainForm
handles.output = hObject;
clc; 
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', '');

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes MainForm wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = MainForm_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;


% --- 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)
clc; 
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', '');
handles.file1 = [];
handles.file2 = [];
handles.result = [];
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif', 'All Image Files';...
          '*.*', 'All Files' }, '选择图像1', ...
          fullfile(pwd, 'images\\实验图像1\\a.tif'));
if isequal(filename, 0)
    return;
end
handles.file1 = fullfile(pathname, filename);
guidata(hObject, handles);
Img1 = imread(fullfile(pathname, filename));
axes(handles.axes1); 
imshow(Img1, []);


% --- 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)
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif', 'All Image Files';...
          '*.*', 'All Files' }, '选择图像2', ...
          fullfile(pwd, 'images\\实验图像1\\b.tif'));
if isequal(filename, 0)
    return;
end
handles.file2 = fullfile(pathname, filename);
guidata(hObject, handles);
Img2 = imread(fullfile(pathname, filename));
axes(handles.axes2);
imshow(Img2, []);

% --- 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.file1)
    msgbox('请载入图像1!', '提示信息', 'modal');
    return;
end
if isempty(handles.file2)
    msgbox('请载入图像2!', '提示信息', 'modal');
    return;
end
[imA, map1] = imread(handles.file1);
[imB, map2] = imread(handles.file2);
M1 = double(imA) / 256;
M2 = double(imB) / 256;
zt = 2;
wtype = 'haar';
[c0, s0] = Wave_Decompose(M1, zt, wtype);
[c1, s1] = Wave_Decompose(M2, zt, wtype);
Coef_Fusion = Fuse_Process(c0, c1, s0, s1);
Y = Wave_Reconstruct(Coef_Fusion, s0, wtype);
handles.result = im2uint8(mat2gray(Y));
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.result)
    msgbox('请进行填充处理!', '提示信息', 'modal');
    return;
end
axes(handles.axes3); 
imshow(handles.result, []);

子函数
function Y = Wave_Reconstruct(Coef_Fusion, s, wtype)

if nargin < 3
wtype = ‘haar’;
end

Y = waverec2(Coef_Fusion, s, wtype);

子函数
function [c, s] = Wave_Decompose(M, zt, wtype)

if nargin < 3
wtype = ‘haar’;
end
if nargin < 2
zt = 2;
end

[c, s] = wavedec2(M, zt, wtype);

函数处理

function Coef_Fusion = Fuse_Process(c0, c1, s0, s1)

KK = size(c1);
Coef_Fusion = zeros(1, KK(2));
Coef_Fusion(1:s1(1,1)*s1(1,2)) = (c0(1:s1(1,1)*s1(1,2))+c1(1:s1(1,1)*s1(1,2)))/2; 
MM1 = c0(s1(1,1)*s1(1,2)+1:KK(2));
MM2 = c1(s1(1,1)*s1(1,2)+1:KK(2));
mm = (abs(MM1)) > (abs(MM2));
Y  = (mm.*MM1) + ((~mm).*MM2);
Coef_Fusion(s1(1,1)*s1(1,2)+1:KK(2)) = Y;

GUI初始界面
在这里插入图片描述
在这里插入图片描述
本文全套源码下载–>传送门

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海宝7号

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值