基于Matlab小波变换图像分割融合算法研究

        图像融合技术就是指利用特定的算法将两幅或多幅待融合图像综合成一幅新的图
像,这幅新的融合图像包含了每一幅待融合图像的重要信息,是所有待融合图像的集合,
其清晰度更加提高、图像描述更加全面、数据信息更加可靠、能够满足的要求更加多样。
图像融合技术作为多源信息融合的一个非常重要分支,近年来受到全世界范围内大量研
究人员的广泛关注,随着对其研究的不断深入,图像融合技术已经大量的应用在遥感探
测、医学影像、交通管理、信息监测、军事科技等领域。鉴于图像融合技术的巨大应用
价值和研究意义,很有必要对其进行深入研究。在未来,相信图像融合技术还会有更大
的发展。
        小波变换作为一种发展迅速、研究热门的处理技术,具有多分辨率分析的特点,已
经广泛的应用到信号处理、图像分析、计算机应用和工程技术等领域。将小波变换运用
到图像融合领域,是对图像融合领域一次重要的发展,也是近些年来的研究热点。
本文主要研究了基于小波变换的图像融合算法,首先介绍了图像融合的目的及意
义,近年来的国内外研究现状和未来发展趋势;其次介绍了图像融合的基本理论,包括
融合步骤、融合层次、基于空间域和变换域的融合算法,以及针对融合图像的主、客观
质量评价方法等内容;然后介绍了小波变换的基本理论,包括傅里叶变换、几种小波变
换、图像的小波分解与重构、多分辨率分析、几种常见的小波基、 Mallat 快速算法等内
容;最后讨论了小波基、图像小波分解层数的选择,图像经小波分解后产生的高、低频
部分的融合规则的选择,并在已有研究人员的基础上,组合改进了基于小波变换的图像
融合算法,通过 MATLAB 软件平台进行仿真实验,对融合图像进行主、客观质量分析,
对比已有常见的图像融合算法,验证了该改进算法的优越性。
  •  代码实现
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Image_Fusion_OpeningFcn, ...
                   'gui_OutputFcn',  @Image_Fusion_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 Image_Fusion is made visible.
function Image_Fusion_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 Image_Fusion (see VARARGIN)

% Choose default command line output for Image_Fusion
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Image_Fusion_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)
[filename1,PathName1] = uigetfile({'*.BMP';'*.bmp';'*.tif';'*.jpg';'*.png'},
  'D:\Users\Documents\MATLAB\multi-focus');
X1 = [PathName1 filename1];
if PathName1 ~=0
    OriginImage1 = imread(X1);
    handles.OrginImage1=OriginImage1;
    guidata(hObject,handles);
    axes(handles.axes1);
    imshow(OriginImage1);
end

% --- 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)
[filename2,PathName2] = uigetfile({'*.BMP';'*.bmp';'*.tif';'*.jpg';'*.png'},
  'D:\Users\Documents\MATLAB\multi-focus');
X2 = [PathName2 filename2];
if PathName2 ~=0
    OriginImage2 = imread(X2);
    handles.OrginImage2=OriginImage2;
    guidata(hObject,handles);
    axes(handles.axes2);
    imshow(OriginImage2);
end

% --- 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)

%图像融合
OriginImage1=handles.OrginImage1;
OriginImage2=handles.OrginImage2;
Image1=double(OriginImage1)/256;
Image2=double(OriginImage2)/256;
[c1,s1]=wavedec2(Image1,2,'sym3'); %将X1进行2维分解,并使用sym4小波进行变换
[c2,s2]=wavedec2(Image2,2,'sym3');
c=0.5*(c1+c2); %计算系数平均值
s=0.5*(s1+s2);
X=waverec2(c,s,'sym3'); %进行小波重构
handles.X=X;
guidata(hObject,handles);
axes(handles.axes3);
imshow(X);




%空间频率
RF=0;
CF=0;
for fi=1:C-1
    for fj=1:R-1
        RF=RF+(X(fi,fj)-X(fi,fj+1)).^2;
    end
end
RF=sqrt(RF/(C*R));
for fi=1:C-1
    for fj=1:R-1
        CF=CF+(X(fi,fj)-X(fi+1,fj)).^2;
    end
end
CF=sqrt(CF/(C*R));
SF=sqrt(RF+CF);
set(handles.edit3,'String',num2str(SF));


%图像清晰度
n=C*R;
m=1;
for i=1:(C-1)
    for j=1:(R-1)
        x=X(i,j)-X(i,j+1);
        y=X(i,j)-X(i+1,j);
        z(m,1)=sqrt((x.^2+y.^2)/2);
        m=m+1;
    end
end
G=sum(z)/n;                                  
set(handles.edit4,'String',num2str(G));


%互信息
s1=size(size(X));
if s1(2)==3 %判断是灰度图像还是RGB彩色图像
    a=rgb2gray(OriginImage1);
    a=double(a);
    b=rgb2gray(OriginImage2);
    b=double(b);
else
    a=double(OriginImage1);
    b=double(OriginImage2);
end
[Ma,Na] = size(a);
[Mb,Nb] = size(b);
M=min(Ma,Mb);
N=min(Na,Nb);

%初始化直方图数组
hab = zeros(256,256);
ha = zeros(1,256);
hb = zeros(1,256);

%归一化
if max(max(a))~=min(min(a))
    a = (a-min(min(a)))./(max(max(a))-min(min(a)));
else
    a = zeros(M,N);
end

if max(max(b))-min(min(b))
    b = (b-min(min(b)))./(max(max(b))-min(min(b)));
else
    b = zeros(M,N);
end

a = double(int16(a*255))+1;
b = double(int16(b*255))+1;

%统计直方图
for i=1:M
    for j=1:N
       indexx =  a(i,j);
       indexy = b(i,j) ;
       hab(indexx,indexy) = hab(indexx,indexy)+1; %联合直方图
       ha(indexx) = ha(indexx)+1; %a图直方图
       hb(indexy) = hb(indexy)+1; %b图直方图
   end
end



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit 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



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit 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

详细代码等资料,请扣扣:134-170-3358;

猜你喜欢

转载自blog.csdn.net/Jiangtagong/article/details/123685796