当前位置 : 主页 > 编程语言 > python >

【图像融合】基于小波变换实现CT图像融合(融合指标)含Matlab源码

来源:互联网 收集:自由互联 发布时间:2022-06-15
1 简介 图像融合是对数字图像的预处理,使图像整体或局部特征能有效地改善。本文基于对图像融合理论的理解,分析了小波变换在图像融合中的应用。在此基础上,利用MATLAB对不同融合系


 1 简介

图像融合是对数字图像的预处理,使图像整体或局部特征能有效地改善。本文基于对图像融合理论的理解,分析了小波变换在图像融合中的应用。在此基础上,利用MATLAB对不同融合系数的图像以及不同增强系数的图像进行融合等,并对其结果进行分析与比较,表明采用方法的合理性。

2 部分代码

function varargout = fusegui(varargin)
% FUSEGUI MATLAB code for fusegui.fig
% FUSEGUI, by itself, creates a new FUSEGUI or raises the existing
% singleton*.
%
% H = FUSEGUI returns the handle to a new FUSEGUI or the handle to
% the existing singleton*.
%
% FUSEGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FUSEGUI.M with the given input arguments.
%
% FUSEGUI('Property','Value',...) creates a new FUSEGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before fusegui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to fusegui_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 fusegui
% Last Modified by GUIDE v2.5 21-Apr-2013 12:54:34
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @fusegui_OpeningFcn, ...
'gui_OutputFcn', @fusegui_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 fusegui is made visible.
function fusegui_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 fusegui (see VARARGIN)
% Choose default command line output for fusegui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes fusegui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = fusegui_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)
global X;
global map1;
%选择图片路径
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.gif';'.png'},'选择图片');
%合成路径+文件名
str=[pathname filename];
%读取图片
[X,map1]=imread(str);
ax1=subplot(221);
set(ax1,'position',[.05 .47 .2 .4]);
imshow(X,map1);
setappdata(handles.pushbutton1,'ax1',ax1);
% --- 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)
global Y;
global map2;
%选择图片路径
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.gif';'.png'},'选择图片');
%合成路径+文件名
str=[pathname filename];
%读取图片
[Y,map2]=imread(str); %读取图像文件,map是颜色表矩阵省略?
ax2=subplot(222);
set(ax2,'position',[.36 .47 .2 .4]);
imshow(Y,map2);
setappdata(handles.pushbutton1,'ax2',ax2);
% --- 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)
ax3=subplot(224);
set(ax3,'position',[.68 .47 .2 .4]);
global ultimate;
imshow(ultimate);
setappdata(handles.pushbutton1,'ax3',ax3);
% --- 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)
global ultimate;
[filename pathname]=uiputfile({'*.jpg';'*.bmp';'*.gif';'.png'},'图像另存为');
imwrite(ultimate,[pathname,filename]);
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
val=get(hObject,'value');
global wavelet;
global X Y ;
global ultimate;
switch val
case 3 %低频取均值,高频局域方差最大
if ndims(X)==3
else
[m,n]=size(X);
zz=zeros(m,n,3);
zz(:,:,1)=X;
zz(:,:,2)=X;
zz(:,:,3)=X;
X=zz;
end
if ndims(Y)==3
else
[m,n]=size(Y);
zzz=zeros(m,n,3);
zzz(:,:,1)=Y;
zzz(:,:,2)=Y;
zzz(:,:,3)=Y;
Y=zzz;
end
X=double(X);
Xr=X(:,:,1);
Xg=X(:,:,2);
Xb=X(:,:,3);
[aA1,aH1,aV1,aD1]=dwt2(Xr,wavelet);
[aA2,aH2,aV2,aD2]=dwt2(Xg,wavelet);
[aA3,aH3,aV3,aD3]=dwt2(Xb,wavelet);
Y=double(Y);
Yr=Y(:,:,1);
Yg=Y(:,:,2);
Yb=Y(:,:,3);
[bA1,bH1,bV1,bD1]=dwt2(Yr,wavelet);
[bA2,bH2,bV2,bD2]=dwt2(Yg,wavelet);
[bA3,bH3,bV3,bD3]=dwt2(Yb,wavelet);
newA1=zeros(size(aA1));
newA2=zeros(size(aA2));
newA3=zeros(size(aA3));
newH1=zeros(size(aH1));
newV1=zeros(size(aV1));
newD1=zeros(size(aD1));
newH2=zeros(size(aH2));
newV2=zeros(size(aV2));
newD2=zeros(size(aD2));
newH3=zeros(size(aH3));
newV3=zeros(size(aV3));
newD3=zeros(size(aD3));
%低频融合规则
[m,n]=size(aA1);
for i=1:m
for j=1:n
newA1(i,j)=(aA1(i,j)+bA1(i,j))/2;
end;
end;
for i=1:m
for j=1:n
newA2(i,j)=(aA2(i,j)+bA2(i,j))/2;
end;
end;
for i=1:m
for j=1:n
newA3(i,j)=(aA3(i,j)+bA3(i,j))/2;
end;
end;

3 仿真结果

【图像融合】基于小波变换实现CT图像融合(融合指标)含Matlab源码_图像融合

【图像融合】基于小波变换实现CT图像融合(融合指标)含Matlab源码_选择图片_02

4 参考文献

[1]柏春岚, 刘豪. 基于小波变换的图像融合及其MATLAB实现[J]. 科技广场, 2014.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。



网友评论