编程语言
首页 > 编程语言> > 【Matlab图像融合】小波变换CTI与MRI图像融合【含源码 782期】

【Matlab图像融合】小波变换CTI与MRI图像融合【含源码 782期】

作者:互联网

一、简介

1974年,法国工程师J.Morlet首先提出小波变换的概念,1986年著名数学家Y.Meyer偶然构造出一个真正的小波基,并与S.Mallat合作建立了构造小波基的多尺度分析之后,小波分析才开始蓬勃发展起来。小波分析的应用领域十分广泛,在数学方面,它已用于数值分析、构造快速数值方法、曲线曲面构造、微分方程求解、控制论等。在信号分析方面的滤波、去噪声、压缩、传递等。在图像处理方面的图像压缩、分类、识别与诊断,去噪声等。本章将着重阐述小波在图像中的应用分析。
1 小波变换原理
小波分析是一个比较难的分支,用户采用小波变换,可以实现图像压缩,振动信号的分解与重构等,因此在实际工程上应用较广泛。小波分析与Fourier变换相比,小波变换是空间域和频率域的局部变换,因而能有效地从信号中提取信息。小波变换通过伸缩和平移等基本运算,实现对信号的多尺度分解与重构,从而很大程度上解决了Fourier变换带来的很多难题。
小波分析作一个新的数学分支,它是泛函分析、Fourier分析、数值分析的完美结晶;小波分析也是一种“时间—尺度”分析和多分辨分析的新技术,它在信号分析、语音合成、图像压缩与识别、大气与海洋波分析等方面的研究,都有广泛的应用。
(1)小波分析用于信号与图像压缩。小波压缩的特点是压缩比高,压缩速度快,压缩后能保持信号与图像的特征不变,且在传递中能够抗干扰。基于小波分析的压缩方法很多,具体有小波压缩,小波包压缩,小波变换向量压缩等。
(2)小波也可以用于信号的滤波去噪、信号的时频分析、信噪分离与提取弱信号、求分形指数、信号的识别与诊断以及多尺度边缘检测等。
(3)小波分析在工程技术等方面的应用概括的包括计算机视觉、曲线设计、湍流、远程宇宙的研究与生物医学方面。
2 多尺度分析
在这里插入图片描述
3 图像的分解和量化
在这里插入图片描述
4 图像压缩编码
在这里插入图片描述
5 图像编码评价
在这里插入图片描述

二、源代码

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

% Last Modified by GUIDE v2.5 14-Dec-2017 19:28:26

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

% Choose default command line output for main
handles.output = hObject;
handles.imfusion1=[];
handles.imfusion2=[];
axis(handles.axes1,'off');
axis(handles.axes2,'off');
axis(handles.axes3,'off')
movegui(handles.figure1,'center');
% Update handles structure
guidata(hObject, handles);
uiwait(handles.figure1);

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


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


% --- 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)
img =handles.imfusion1;
% img = rgb2gray(img);
% img = img(20:160,140:280);
nn=10;
img=imresize(img,[58*nn 77*nn]);


img2 =handles.imfusion2;
% img2 = rgb2gray(img2);
% img2 = img2(20:160,140:280);
img2=imresize(img2,[58*nn 77*nn]);
[RcA1,RcH1,RcV1,RcD1] = dwt2(img,'sym4');%LL1,HL1,LH1,HH1
[VcA1,VcH1,VcV1,VcD1] = dwt2(img2,'sym4');%LL1,HL1,LH1,HH1
[RcA2,RcH2,RcV2,RcD2] = dwt2(RcA1,'sym4');%LL1,HL1,LH1,HH1
[VcA2,VcH2,VcV2,VcD2] = dwt2(VcA1,'sym4');%LL1,HL1,LH1,HH1
%%%%%% 2级小波融合
%%%%%% 策略1:  低频平均;高频模值较大者
[M1,N1,P1] = size(RcA1);
[M2,N2,P2] = size(RcA2);
%%%%%%1级
cA10 = (RcA1 + VcA1)*0.5;
for i=1:M1
    for j=1:N1
        for k=1:3
        if abs(RcH1(i,j,k)) > abs(VcH1(i,j,k))
              cH10(i,j,k) = RcH1(i,j,k);      
        else
              cH10(i,j,k) = VcH1(i,j,k); 
        end
        if abs(RcV1(i,j,k)) > abs(VcV1(i,j,k))
              cV10(i,j,k) = RcV1(i,j,k);      
        else
              cV10(i,j,k) = VcV1(i,j,k); 
        end
        if abs(RcD1(i,j,k)) > abs(VcD1(i,j,k))
              cD10(i,j,k) = RcD1(i,j,k);      
        else
              cD10(i,j,k) = VcD1(i,j,k); 
        end        
        end
    end
end
%%%%%%%2级
cA20 = (RcA2 + VcA2)*0.5;
for i=1:M2
    for j=1:N2
        for k=1:3
        if abs(RcH2(i,j,k)) > abs(VcH2(i,j,k))
              cH20(i,j,k) = RcH2(i,j,k);      
        else
              cH20(i,j,k) = VcH2(i,j,k); 
        end
        if abs(RcV2(i,j,k)) > abs(VcV2(i,j,k))
              cV20(i,j,k) = RcV2(i,j,k);      
        else
              cV20(i,j,k) = VcV2(i,j,k); 
        end
        if abs(RcD2(i,j,k)) > abs(VcD2(i,j,k))
              cD20(i,j,k) = RcD2(i,j,k);      
        else
              cD20(i,j,k) = VcD2(i,j,k); 
        end        
        end
    end
end
%%%%%%反变换
img_fuse2 = idwt2(cA20,cH20,cV20,cD20,'sym4');%LL1,HL1,LH1,HH1
img_fuse2 = img_fuse2(1:M1,1:N1,1:3);
img_fuse0 = idwt2(img_fuse2,cH10,cV10,cD10,'sym4');
for k=1:3
%     a=max(max(img_fuse0(:,:,k)));
%     b=min(min(img_fuse0(:,:,k)));
%     img_fuse0(:,:,k)=1/(b-a)*img_fuse0(:,:,k)-(1/(b-a)*a);
a=max(max(img_fuse0(:,:,k)));
 img_fuse0(:,:,k)= img_fuse0(:,:,k)./a;
end
axes(handles.axes3);
imshow(img_fuse0);
guidata(hObject, handles);

三、运行结果

在这里插入图片描述

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.

五、获取代码方式

打开球球,扫码CSDN二维码
在这里插入图片描述

标签:end,abs,img,gui,融合,handles,源码,图像,main
来源: https://blog.csdn.net/MLB_Q1564658423/article/details/122155423