医学图像处理_医学图像处理案例(十七)——基于小波变换和自适应脉冲耦合神经网络的图像融合...

本文介绍了使用小波变换和自适应脉冲耦合神经网络(PCNN)对多模态医学图像进行融合的方法。首先阐述了小波变换的基本原理,包括图像的分解和重建过程,接着提出了两种融合规则。然后回顾了PCNN模型在图像处理中的应用。文章提供了Python代码示例,展示如何实现低频部分采用平均值法,高频部分采用自适应PCNN最大值法的融合策略。最后展示了融合结果。
摘要由CSDN通过智能技术生成
今天将介绍使用小波变换和自适应脉冲耦合神经网络来对多模态图像进行融合。 1、小波变换融合回顾 小波变换融合算法基本思想: 首先对源图像进行小波变换,然后按照一定规则对变换系数进行合并; 最后对合并后的系数进行小波逆变换得到融合图像。 1.1、小波分解原理简介 e085cae4b3e08eda96c114fac2604a08.png LL: 水平低频,垂直低频 LH: 水平低频,垂直高频 HL: 水平高频,垂直低频 HH: 水平高频,垂直高频 其中,L表示低频,H表示高频,下标1、2表示一级或二级分解。 在每一分解层上,图像均被分解为LL,LH,HH和HL四个频带,下一层的分解仅对低频分量LL进行分解。 这四个子图像中的每一个都是由原图与一个小波基函数的内积后,再经过在x和y方向都进行2倍的间隔采样而生成的,这是正变换,也就是图像的分解; 逆变换,也就是图像的重建,是通过图像的增频采样和卷积来实现的。 1.2、融合规则 规则一: 系数绝对值较大法 该融合规则适合高频成分比较丰富,亮度、对比度比较高的源图像,否则在融合图像中只保留一幅源图像的特征,其他的特征被覆盖。 小波变换的实际作用是对信号解相关,并将信号的全部信息集中到一部分具有大幅值的小波系数中。 这些大的小波系数含有的能量远比小系数含有的能量大,从而在信号的重构中,大的系数比小的系数更重要。 规则二: 加权平均法 权重系数可调,适用范围广,可消除部分噪声,源图像信息损失较少,但会造成图像对比度的下降,需要增强图像灰度。 2、脉冲耦合神经网络(PCNN)回顾 PCNN模型用于处理二维图像时,可以用数学离散形式来描述,如下公式所示。 40ee602919b2b905aa4112978d4bca59.png 其中Sij为外部信号,αL和αθ分别是线性连通输入Lij和动态临界值θij的衰减定值,VL和Vθ分别是连通倍数系数和临界值倍数系数,Wijkl是线性连通输入Lij的加权系数,βij为连接强度,决定了线性连通输入Lij对内部参数Uij的贡献。 3、基于小波变换和自适应脉冲耦合神经网络的图像融合代码实现 我将分享python版本代码来融合红外和可见光图像,融合策略是低频图像采用平均值法,高频图像采用自适应PCNN最大值法,PCNN参数设置: 链接系数为5,链接参数为图像拉普拉斯能量和,计算公式如下所示,迭代次数为200。 941d2ca6e03a11d5f22781bbbb77d98d.png python版本中需要用到PyWavelets库,可以使用下面命令来安装。
pip install PyWavelets
python版本代码 :
import pywtimport cv2import numpy as npimport mathfrom scipy import signaldef pcnn(img, link=5, beta=0.1, iteration=200):    """    PCNN generate fire maps image    :param img:source image    :param link:pcnn link parm    :param beta:pcnn link coefficient    :param iteration:pcnn iteration number    :return:fire maps image    """    m, n = np.shape(img)[0], np.shape(img)[1]    alpha_L = 1    alpha_Theta = 0.2    vL = 1.0    vTheta = 20    center_x = round(link / 2)    center_y = round(link / 2)    W = np.zeros((link, link))    for i in range(link):        for j in range(link):            if i == center_x and j == center_y:                W[i, j] = 0            else:                W[i, j] = 1. / math.sqrt(pow(i - center_x, 2) + pow(j - center_y, 2))    imgf = img.astype(np.float)    F = abs(imgf)    L = np.zeros((m, n))    Y = np.zeros((m, n))    Theta = np.zeros((m, n))    img_pcnn = np.zeros((m, n))    for i in range(iteration):        K = signal.convolve2d(Y, W, mode='same')        L = math.exp(-alpha_L) * L + vL * K        Theta = math.exp(-alpha_Theta) * Theta + vTheta * Y        U = np.multiply(F, 1 + np.multiply(beta, L))        Y = U > Theta        Yf = Y.astype(np.float)        img_pcnn = img_pcnn + Yf    return img_pcnn# This function does the coefficient fusing according to the fusion methoddef fuseCoeff(cooef1, cooef2, method):    if (method == 'mean'):        cooef = (cooef1 + cooef2) / 2    elif (method == 'min'):        cooef = np.minimum(cooef1, cooef2)    elif (method == 'max'):        cooef = np.maximum(cooef1, cooef2)    elif (method == 'pcnn'):        pcnn1 = pcnn(cooef1, 5, 0.1, 200)        pcnn2 = pcnn(cooef2, 5, 0.1, 200)        pcnn_cooef = np.maximum(pcnn1, pcnn2)        cooef1[pcnn1 != pcnn_cooef] = 0        cooef2[pcnn2 != pcnn_cooef] = 0        cooef = cooef1 + cooef2    elif (method == 'auto_pcnn'):        W = [[-1, -4, -1], [-4, 20, -4], [-1, -4, -1]]        K1 = signal.convolve2d(cooef1, W, mode='same')        K2 = signal.convolve2d(cooef2, W, mode='same')        beta1 = np.sum(np.multiply(K1, K1))        beta2 = np.sum(np.multiply(K2, K2))        pcnn1 = pcnn(cooef1, 5, beta1, 200)        pcnn2 = pcnn(cooef2, 5, beta2, 200)        pcnn_cooef = np.maximum(pcnn1, pcnn2)        cooef1[pcnn1 != pcnn_cooef] = 0        cooef2[pcnn2 != pcnn_cooef] = 0        cooef = cooef1 + cooef2    return cooef# ParamsFUSION_METHOD = 'mean'  # Can be 'min' || 'max || anything you choose according theoryFUSION_METHOD1 = 'auto_pcnn'# Read the two imageI1 = cv2.imread('IR1.png', 0)I2 = cv2.imread('VIS1.png', 0)# First: Do wavelet transform on each imagewavelet = 'db2'cooef1 = pywt.wavedec2(I1[:, :], wavelet, level=1)cooef2 = pywt.wavedec2(I2[:, :], wavelet, level=1)# Second: for each level in both image do the fusion according to the desire optionfusedCooef = []for i in range(len(cooef1)):    # The first values in each decomposition is the apprximation values of the top level    if (i == 0):        fusedCooef.append(fuseCoeff(cooef1[0], cooef2[0], FUSION_METHOD))    else:        # For the rest of the levels we have tupels with 3 coeeficents        c1 = fuseCoeff(cooef1[i][0], cooef2[i][0], FUSION_METHOD1)        c2 = fuseCoeff(cooef1[i][1], cooef2[i][1], FUSION_METHOD1)        c3 = fuseCoeff(cooef1[i][2], cooef2[i][2], FUSION_METHOD1)        fusedCooef.append((c1, c2, c3))# Third: After we fused the cooefficent we nned to transfor back to get the imagefusedImage = pywt.waverec2(fusedCooef, wavelet)# Forth: normmalize values to be in uint8fusedImage1 = np.multiply(np.divide(fusedImage - np.min(fusedImage), (np.max(fusedImage) - np.min(fusedImage))), 255)fusedImage1 = fusedImage1.astype(np.uint8)# Fith: Show imagecv2.imwrite("win.bmp", fusedImage1)
4、融合结果 下图是红外图像和可见光图像。 03dbdde3f3960be15c32b6cec5a15fa5.png 6be580664af7261bb3f345ab597a71a8.png 小波变换自适应脉冲耦合神经网络融合结果 0cf781401cafdb930e354e50cbd7ff69.png 如果碰到任何问题,随时留言,我会尽量去回答的。
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值