Print

发布时间: 2018-10-16
摘要点击次数:
全文下载次数:
DOI: 10.11834/jig.170650
2018 | Volume 23 | Number 10




    图像处理和编码    




  <<上一篇 




  下一篇>> 





结构张量的改进Criminisi修复
expand article info 何雨亭1, 唐向宏1,2, 张越1, 杨瑞1
1. 杭州电子科技大学通信工程学院, 杭州 310018;
2. 杭州电子科技大学信息工程学院, 杭州 310018

摘要

目的 针对传统基于样本块的图像修复算法中仅利用图像的梯度信息和颜色信息来修复破损区域时,容易产生错误填充块的问题,本文在Criminisi算法的基础上,利用结构张量特性,提出了一种改进的基于结构张量的彩色图像修复算法。方法 首先利用结构张量的特征值定义新的数据项,以确保图像的结构信息能够更加准确地传播;然后利用该数据项构成新的优先权函数,使得图像的填充顺序更加精准;最后利用结构张量的平均相干性来自适应选择样本块大小,以克服结构不连续和错误延伸的缺点;同时在匹配准则中,利用结构张量特征值来增加约束条件,以减少错误匹配率。结果 实验结果表明,改进算法的修复效果较理想,在主观视觉上有明显的提升,其修复结果的峰值信噪比(PSNR)和结构相似度(SSIM)都有所提高;与传统Criminisi算法相比,其峰值信噪比提高了1~3 dB。结论 本文算法利用结构张量的特性实现了对不同结构特征的彩色破损图像的修复,对复杂的线性结构和纹理区域都有较理想的修复,有效地保持了图像边缘结构的平滑性,而且对大物体的移除和文字去除也有较好的修复效果。

关键词

彩色图像修复; 结构张量; 自适应样本块大小; 匹配准则; 平均相干性

Improved Criminisi algorithm based on structure tensor
expand article info He Yuting1, Tang Xianghong1,2, Zhang Yue1, Yang Rui1
1. School of Communication Engineering, Hangzhou Dianzi University, Hangzhou 310018, China;
2. School of Information Engineering, Hangzhou Dianzi University, Hangzhou 310018, China

Abstract

Objective The rapid development of multimedia information technology has led to images that have become the main carrier of information in people's lives.People communicate information through various means, such as voice, images, text, and video.Consequently, digital image inpainting technology has gradually attracted increasing attention, and its application fields are extensive.Digital image inpainting refers to the process of repairing or rebuilding missing information in damaged images by using a specific image inpainting algorithm, such that the observer cannot easily detect that the image has been repaired or damaged.Image inpainting technology has been used in many research areas, such as the restoration of old photos, the removal of image text, and the preservation of cultural relics.The traditional exemplar-based image inpainting algorithm only uses gradient information and the color information of the image to repair damaged areas, which can easily generate incorrect filling patches.In addition, the definition of the priority function is unreasonable, and thus causes the wrong filling order during inpainting, which affects the overall restoration effect.To solve these problems, an improved color image inpainting algorithm that is based on structure tensor is presented in this paper. Method Structure tensor is often used to analyze the local geometry of an image, which not only contains the intensity information of the local region, but also the main directions of the neighborhood gradient of a pixel and the degree of coherence of these directions.Its two eigenvalues can distinguish the edge, texture, and flat areas of an image.First, the proposed algorithm uses the structure tensor to define the data items to ensure that the structure information of the image can be transmitted accurately, and then uses the data items to form a new priority function for a more precise filling order.Second, different sizes of sample patches can be used to search for the best matching patch because an image has different structural features in different regions.Therefore, the size of the sample patch is adaptively selected according to the average coherence of the structure tensor.In other words, when the average coherence of the patch to be repaired is large, this patch is at the edge of the image and a small sample patch should be used; when the average coherence is small, it is in the flat region of the image and a large sample patch should be used.In this manner, when repairing complex damaged images, the continuity of the edge structure can be maintained; the flat area of the image can be effectively repaired.Finally, the traditional inpainting algorithm only uses the color information of the image to find the best matching patch, which renders the matching patch sub optimal.In this study, the eigenvalues of the structure tensor are added to the matching criteria to reduce the false matching rate. Result Experimental results show that the improved algorithm is more effective in subjective vision than the other related algorithms.Moreover, the improved algorithm can achieve good results for different types of damaged images and effectively maintain the smoothness of the edge structure of the image.Compared with the traditional Criminisi algorithm, the power signal-to-noise ratio of the result has improved by approximately 1~3 dB and enhanced structure similarity.In addition, the proposed algorithm has a higher running time than other algorithms because in the inpainting process, the proposed algorithm uses the adaptive sample patch size to search for the best matching patch, and when analyzing the local structural features of the image, it needs to calculate the coherence factor of the pixels.These steps consequently increase the running time and reduce the efficiency of image inpainting. Conclusion When the traditional algorithm repairs the strong damaged area of the edge, the structural integrity and the good visual effect of the image are difficult to balance.In this study, we use the structure tensor of the color image to analyze the structure and texture area of the image.This paper discusses a color image inpainting algorithm based on the structure tensor.The proposed algorithm first uses the eigenvalue of the structure tensor instead of the isophote line in the traditional algorithm to improve the data items, which can spread the structure information of the image more accurately.Then, the average coherence factor of the structure tensor is used to analyze the texture and structural features of the image to repair the different image structural features.Finally, the matching rate used to select the best matching patch is improved with the addition of the constraint of the structural tensor to the traditional matching criteria.The proposed algorithm can obtain a better visual effect for damaged images with different structural features.The proposed algorithm can also effectively maintain the structural integrity of the image, and the complex texture area does not exhibit a wrong filled patch.Moreover, the large object and text removals by the proposed algorithm also have a good restoration effect.Compared with related Criminisi algorithms, the proposed algorithm has a better repair effect on complex linear structure and texture regions and effectively improves the overall quality of image restoration.

Key words

color image restoration; structure tensor; adaptive patch size; matching criterion; the average coherence

0 引言

数字图像修复技术是图像处理和计算机视觉领域中的一个重要研究内容。图像修复是利用图像中未破损的信息对图像中信息完全丢失的区域进行自动修补的过程,其目的是恢复图像破损区域的信息,并使观察者不易察觉图像曾被修复过。图像修复的应用领域越来越广泛,主要在文物保护、多余目标物体移除、影视制作、虚拟现实等方面有着重要的应用价值。

近年来,有很多学者提出了不同的图像修复算法,主要分为3类:1)基于变分偏微分方程的图像修复;2)基于纹理合成的图像修复;3)混合方法。Bertalmio等人[1]首次提出了基于偏微分方程的图像修复技术,该方法通过对待修补区域的边界进行不同方向的扩散将未破损区域的信息扩散到待修补区域的内部来对图像进行修复。该算法仅对照片中的细小划痕等小尺度破损具有较好的修复效果。Chan等人[2]提出了TV(total variation)修复算法,并在此基础上提出了一些改进算法[3-4]。随后,Criminisi等人[5]提出了基于样本块的图像修复算法,其利用待修补区域的边界信息计算待修复块的优先级,然后在图像未破损区域中寻找与待修复块最匹配的样本块来填充破损区域。该算法对大面积的破损区域具有较好的修复效果,但是修复时间较长,大大降低了算法的修复效率。因此,针对Criminisi算法的一些不足,学者提出了不同的改进方法[6-9]。文献[10]首先根据图像的颜色或者纹理特征对破损图像进行分块,生成一个区域图,以便对给定目标块的搜索区域做进一步的限定,提高整体的搜索效率。文献[11]通过引入调节因子来重新定义置信度项,得到新的优先权函数,确保待修复块信息的正确填充;并利用图像的颜色信息和梯度信息的相互结合来寻找最佳匹配块,该算法对结构简单的破损图像修复效果较好,对于背景结构复杂的图像则会出现结构不连续的现象。文献[12]利用图像的边缘结构特征和纹理特征引入差别因子,以改进优先权函数来提高算法填充顺序的准确性,并改进了传统算法的搜索方式,来提高算法的修复效率。文献[13]针对传统方法的时间复杂度较高及错误累积等缺点,通过引入结构张量来构建局部结构度量函数,以此来优化优先权函数,并且提出了一种新的匹配准则。该算法对图像的强边缘结构进行修复时有较好的保持,而在修复弱边缘结构时出现了结构断裂的现象。文献[14]通过结合图像的结构张量和梯度来更加准确地区分图像的显著结构,并定义新的优先级函数来使得图像的结构部分优先修复,该算法在修复复杂结构时,其效果不理想,而且运行时间也很长。文献[15]利用调节因子来决定每个块的优先权,并在匹配条件中加入归一化互相关函数(NCC)来衡量目标块和源块之间的相似性。该算法对简单的结构区域有较好的修复,但在修复纹理区域时,容易产生错误填充块。文献[16]提出了基于结构的图像修复算法,主要利用结构张量场来表示和分析图像的结构层,首先修复破损图像的结构层,然后利用修复后的结构层来约束后续图像的修复过程,该算法对图像的线性结构有较的保持。

然而上述改进算法在修复结构复杂的破损图像时,仍会出现结构不连续的现象,分析其原因,一是块的优先级函数影响待修复块的修复顺序;二是在寻找最佳匹配块时,只利用了图像像素点的颜色信息,而没有充分利用图像的局部特性,同时样本块大小采用固定形式。针对这些不足,本文基于结构张量理论,充分利用彩色图像的结构张量特征,在优先权函数、匹配准则中引入结构张量,以及采用自适应大小的样本块,提高彩色图像的修复效果。

1 Criminisi算法的改进

Criminisi算法是一种趋于等照度线的图像采样过程[5]$\mathit{\boldsymbol{ \boldsymbol{\varOmega} }}$为图像的待修复区域,${\bf{ \pmb{\mathsf{ δ}} }}{\mathit{\boldsymbol{ \boldsymbol{\varOmega} }}}$为填充边缘,$\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}$为已知区域,${\mathit{\boldsymbol{\psi }}_p}$是以像素$p$${\bf{ \pmb{\mathsf{ δ}} }}{\mathit{\boldsymbol{ \boldsymbol{\varOmega} }}}$为中心的大小为9×9像素的待修复像素块,如图 1所示。这样彩色破损图像的修复主要包含以下3个步骤[5]

图 1 Criminisi算法示意图
Fig. 1 Criminisi algorithm diagram

1) 计算待修复块的优先权,具体公式为

$ P\left( p \right) = C\left( p \right) \cdot D\left( p \right) $ (1)

式中,$C(p)$$D(p)$分别称为置信度项和数据项,分别定义为

$ C\left( p \right) = \sum\limits_{q \in {\mathit{\boldsymbol{\psi }}_p} \cap \mathit{\boldsymbol{ \boldsymbol{\varPhi} }}} {C\left( q \right)/\left| {{\mathit{\boldsymbol{\psi }}_p}} \right|} $ (2)

$ D\left( p \right) = \left| {\nabla {\bf{I}}_p^ \bot \cdot {\mathit{\boldsymbol{n}}_p}} \right|/\alpha $ (3)

式中,$p$为填充边缘${\bf{ \pmb{\mathsf{ δ}} }}{\mathit{\boldsymbol{ \boldsymbol{\varOmega} }}}$上的像素点,$\left| {{\mathit{\boldsymbol{\psi }}_p}} \right|$为待修复块${{\mathit{\boldsymbol{\psi }}_p}}$的面积,$α$为归一化因子,${\mathit{\boldsymbol{n}}_p}$$p$点的法向量,$\nabla {\bf{I}}_p^ \bot $代表$p$点的等照度线向量。初始化时$C(p)$的值为$C(p)$=0, $\forall p \in \mathit{\boldsymbol{ \boldsymbol{\varOmega} }}$$C(p)$=1, $\forall p \in \mathit{\boldsymbol{ \boldsymbol{\varPhi} }}$

2) 搜索最佳匹配块并填充。找到具有最高优先级的待修复块${\mathit{\boldsymbol{\psi }}_{\hat p}}$后,在已知区域中搜索${\mathit{\boldsymbol{\psi }}_{\hat p}}$的最佳匹配块${\mathit{\boldsymbol{\psi }}_q}$,使其${\mathit{\boldsymbol{\psi }}_{\hat p}}$${\mathit{\boldsymbol{\psi }}_q}$的颜色差值的平方和(SSD)最小,匹配准则为

$ {\mathit{\boldsymbol{\psi }}_{\hat q}} = \arg \mathop {\min }\limits_{{\mathit{\boldsymbol{\psi }}_q} \in \mathit{\boldsymbol{ \boldsymbol{\varPhi} }}} d\left( {{\mathit{\boldsymbol{\psi }}_{\hat p}},{\mathit{\boldsymbol{\psi }}_q}} \right) $ (4)

式中,$d$(${\mathit{\boldsymbol{\psi }}_{\hat p}}$, ${\mathit{\boldsymbol{\psi }}_q}$)表示待修复块${{\psi }_{\hat p}}$和最佳匹配块${\mathit{\boldsymbol{\psi }}_q}$中对应已知像素点的颜色差值的平方和。

$ d\left( {{\mathit{\boldsymbol{\psi }}_{\hat p}},{\mathit{\boldsymbol{\psi }}_q}} \right) = \sum\limits_{i = 1}^m {\sum\limits_{j = 1}^n {{{\left( {{p_{ij}} - {q_{ij}}} \right)}^2}} } $ (5)

式中,$m$, $n$分别为待修复块${\mathit{\boldsymbol{\psi }}_{\hat p}}$的长和宽,${p_{ij}}$${q_{ij}}$分别为待修复块和最佳匹配块中已知的像素值。

3) 更新置信度。具体公式为

$ C\left( p \right) = C\left( {\hat p} \right),p \in {\mathit{\boldsymbol{\psi }}_{\hat p}} \cap \mathit{\boldsymbol{ \boldsymbol{\varOmega} }} $ (6)

式中,${\hat p}$是具有最高优先权的像素点,$p$是待修复块${\mathit{\boldsymbol{\psi }}_{\hat p}}$的破损像素点。

重复步骤1)—3),直至待修复区域的像素全部被填充。

1.1 彩色图像的结构张量

结构张量通常被用来分析图像的局部几何结构[17],它不仅包含了局部区域的强度信息,同时也包含了特定像素邻域梯度的主要方向和这些方向的相干程度。

设彩色图像$\mathit{\boldsymbol{I}}$的梯度为[5]

$ \nabla {\mathit{\boldsymbol{I}}_i} = {\left[ {{I_{xi}},{I_{yi}}} \right]^{\rm{T}}} $ (7)

式中,i=1, 2, 3分别代表彩色图像的R、G、B分量;$\nabla {\mathit{\boldsymbol{I}}_i}$代表彩色图像的每个通道的梯度,${I_{xi}}$, ${I_{yi}}$分别为$x$, $y$方向的偏导数,${I_{xi}} = \partial {\mathit{\boldsymbol{I}}_i}/\partial x, {I_{yi}} = \partial {\mathit{\boldsymbol{I}}_i}/\partial y$

则彩色图像的结构张量${\mathit{\boldsymbol{J}}_\rho }$定义为[17]

$ \mathit{\boldsymbol{J}} = \sum\limits_{i = 1}^n {\nabla {\mathit{\boldsymbol{I}}_i}\nabla \mathit{\boldsymbol{I}}_i^{\rm{T}}} = \left[ {\begin{array}{*{20}{c}} \begin{array}{l} I_x^2\\ {I_x}{I_y} \end{array}&\begin{array}{l} {I_x}{I_y}\\ I_y^2 \end{array} \end{array}} \right] $ (8)

$ \begin{array}{*{20}{c}} {{\mathit{\boldsymbol{J}}_\rho } = \left[ {\begin{array}{*{20}{c}} {{j_{11}}}&{{j_{12}}}\\ {{j_{21}}}&{{j_{22}}} \end{array}} \right] = {\mathit{\boldsymbol{G}}_\rho } * \mathit{\boldsymbol{J}} = }\\ {\left[ {\begin{array}{*{20}{c}} \begin{array}{l} {G_\rho } * I_x^2\\ {G_\rho } * {I_x}{I_y} \end{array}&\begin{array}{l} {G_\rho } * {I_x}{I_y}\\ {G_\rho } * I_y^2 \end{array} \end{array}} \right]} \end{array} $ (9)

式中,${G_\rho }$是均值为0、方差为$ρ$的2维高斯函数[18],即${G_\rho } = \frac{1}{{2{\rm{ \mathit{ π} }}{\rho ^2}}}{\rm{exp}}\left({-\frac{{{x^2} + {y^2}}}{{2{\rho ^2}}}} \right)$。由于矩阵${\mathit{\boldsymbol{J}}_\rho }$是对称且半正定的2维矩阵,因此有两个非负特征值,其大小分别为

$ {\lambda _{1,2}} = \frac{1}{2}\left( {{j_{11}} + {j_{22}} \pm \sqrt {{{\left( {{j_{11}} - {j_{22}}} \right)}^2} + 4j_{12}^2} } \right) $ (10)

${\lambda _1}$${\lambda _2}$分别代表结构张量在像素点处的最大和最小特征值,表明了图像局部边缘的强度[18]。当${\lambda _1}$${\lambda _2}$两特征值都相对较小时,意味着在像素点邻域内灰度值变化较小,即像素点位于平坦区域;当${\lambda _1}$较大而${\lambda _2}$较小时,则表明在一个主要方向上,灰度值有很强的变化,该像素点处在图像的边缘区域;当两个特征值都较大时,则灰度值在相应的特征向量所指定的方向上存在很强的变化,像素点处在图像的角点区域。因此,根据特征值${\lambda _1}$${\lambda _2}$的特点,本文从以下几个方面对Criminisi算法进行改进。

1.2 优先权函数的改进

由于结构张量可以准确估计图像的边缘方向和该方向上的变化强度,其特征值之间的大小能够区分图像的边缘区域、纹理区域和平坦区域。因此,将结构张量特征值引入到数据项中,即

$ D\left( p \right) = 1 - \exp \left[ { - {{\left( {{\lambda _1} - {\lambda _2}} \right)}^2}} \right] $ (11)

从式(11)中可以看出,当像素点$p$处在结构边缘时,${\lambda _1}$-${\lambda _2}$>>0,则$D(p)$≈1;当$p$处在平坦区域时,${\lambda _1}$-${\lambda _2}$≈0,则$D(p)$≈0;当$p$处在纹理区域时,${\lambda _1}$${\lambda _2}$>0,则0 < $D(p)$ < 1。这样,数据项$D(p)$能更加精准地反映图像结构特征。

在传统算法中,由于优先权函数$P(p)$是利用置信度项与数据项的乘积来确定(如式(1)所示),但当数据项或置信度项在某点处为零时,其优先权也随着为零,从而影响图像的填充顺序,产生错误的修复结果。为此,本文则采用改进的数据项与置信度项的线性加权和,重新定义优先权函数,即

$ P\left( p \right) = \alpha \cdot C\left( p \right) + \beta \cdot D\left( p \right) $ (12)

式中,$α$$β$为置信度项和数据项的权重,且$α$+$β$=1。为使图像的结构部分优先修复,应使数据项的权重大于置信度项的权重,即$α$ < $β$

图 2分别给出了采用不同优先权函数对破损彩色图像Lena的修复效果图。从图 2对比可以看出,改进的优先权函数使得填充顺序更加准确,图像的纹理部分及结构部分都得到了较好的修复。

图 2 使用不同优先权函数的修复结果对比图
Fig. 2 Comparison of repair results using different priority functions((a) original image; (b) image to be inpainted; (c) Criminisi algorithm; (d) reference [13] algorithm; (e) ours)

1.3 样本块大小的自适应选择

在Criminisi算法中,通常采用固定的样本块大小进行寻找最佳匹配块,而没有考虑图像的局部结构特征,从而导致在修复结构比较复杂的区域时,会出现部分结构不连续或延伸现象。为此,本文利用结构张量特征值的大小,将图像划分为边缘区域、纹理区域和平坦区域,并在不同区域,采用不同大小的样本块进行最佳匹配块的搜索。首先,参照文献[18]定义一个以像素点$p$为中心的待修复块${{\mathit{\boldsymbol{\psi }}_p}}$的平均相干因子$av{e_{moa}}$,其大小为

$ av{e_{moa}} = {\left( {\frac{{{{\bar \lambda }_1} - {{\bar \lambda }_2}}}{{{{\bar \lambda }_1} + {{\bar \lambda }_2}}}} \right)^2} $ (13)

式中,${{\bar \lambda }_1}$${{\bar \lambda }_2}$为待修复块${{\mathit{\boldsymbol{\psi }}_p}}$中已知像素点的结构张量的平均特征值。表 1分别给出了图 3中各像素块的平均相干性$av{e_{moa}}$大小。在图 3中标出的像素块大小为9×9像素,其中像素块1、2、3、4、5处在边缘区域,像素块6、7、8、9处在纹理区域,像素块10、11、12处在平滑区域。从表 1中可以看出,像素块处在边缘区域时,$av{e_{moa}}$的值在0.90以上;当处在平滑区域时,$av{e_{moa}}$的值在0.70以下;而处在纹理区域时,$av{e_{moa}}$的值在0.80左右。因此,图像像素块的平均相干因子$av{e_{moa}}$的大小,能够较准确地区分图像的平滑区域、纹理区域和边缘区域。

表 1 各个像素块的平均相干性值
Table 1 Average coherence values of each pixel patch

下载CSV
图像 边缘区域 纹理区域 平滑区域
1 2 3 4 5 6 7 8 9 10 11 12
Lena 0.987 0 0.934 5 0.971 4 0.904 0 0.746 1 0.855 8 0.853 1 0.558 2 0.870 4 0.600 5 0.625 2 0.540 5
Baboon 0.905 3 0.937 1 0.934 7 0.839 7 0.919 3 0.785 6 0.867 2 0.728 4 0.807 0 0.681 4 0.672 9 0.696 1
Barb 0.945 4 0.917 6 0.971 4 0.950 7 0.966 8 0.822 3 0.995 2 0.877 4 0.974 8 0.602 8 0.685 9 0.663 3
Pepper 0.935 1 0.925 7 0.956 7 0.905 2 0.960 9 0.869 3 0.850 1 0.834 1 0.826 4 0.459 2 0.501 3 0.565 0
图 3 像素块位于图像结构的不同区域
Fig. 3 Pixel patches are located in different regions of the image structure ((a) Lena; (b) Baboon; (c) Barb; (d) Peppers)

为了在修复结构复杂的破损图像时,既可以对图像的平坦区域进行很好的修复,也可以保持边缘结构的连续性。因此,本文利用$av{e_{moa}}$的变化来自适应地选择样本块大小,其选择原则是,当待修复块的平均相干性较大时,则处于图像的边缘区域,应采用较小的样本块;当其平均相干性较小时,则处在图像的平坦区域,应采用较大的样本块。即样本块大小$size(p)$

$ size\left( p \right) = \left\{ {\begin{array}{*{20}{c}} \begin{array}{l} 11 \times 11\;像素\\ 9 \times 9\;像素\\ 7 \times 7\;像素\\ 5 \times 5\;像素 \end{array}&\begin{array}{l} \left| {av{e_{moa}}} \right| \le 0.7\\ 0.7 < \left| {av{e_{moa}}} \right| < 0.8\\ 0.8 \le \left| {av{e_{moa}}} \right| < 0.9\\ \left| {av{e_{moa}}} \right| \ge 0.9 \end{array} \end{array}} \right. $ (14)

图 4分别给出了采用不同样本块大小时,对Lena破损图像(图 2(b))修复结果的对比图。通过对比得出,采用自适应样本块大小较好地克服了固定大小的样本块容易在结构处产生错误延伸的现象。

图 4 采用不同样本块大小的修复结果图
Fig. 4 Repair results of using different sample patch size ((a) size of 11×11;(b) size of 9×9;(c) size of 7×7; (d) size of 5×5;(e) size of 3×3;(f) adaptively select sample patch)

1.4 匹配准则改进

为了能更准确地找到最佳匹配块,避免Criminisi算法只根据待修复块和已知区域中样本块的像素颜色值来判断最佳匹配块的不足,本文结合结构张量特征值的特性,在式(5)的基础上,利用像素的结构张量相干因子${moa}$,将匹配准则重新定义为

$ \begin{array}{*{20}{c}} {d\left( {{\mathit{\boldsymbol{\psi }}_{\hat p}},{\mathit{\boldsymbol{\psi }}_q}} \right) = \sum\limits_{i = 1}^m {\sum\limits_{j = 1}^n {\left[ {{{\left( {{p_{ij}} - {q_{ij}}} \right)}^2} + } \right.} } }\\ {\left. {10 \times {{\left( {mo{a_{ij}} - mo{{a'}_{ij}}} \right)}^2}} \right]} \end{array} $ (15)

式中,$moa = {\left({\frac{{{\lambda _1}-{\lambda _2}}}{{{\lambda _1} + {\lambda _2}}}} \right)^2}$为像素的结构张量相干因子;$mo{a_{ij}}$$moa{'_{ij}}$分别为待修复块和匹配块中已知像素点的结构张量的相干因子。

综上所述,本文算法的流程如图 5所示,具体实现步骤如下:

图 5 本文算法的流程图
Fig. 5 The flow chart of the algorithm

1) 确定彩色图像待修复区域的边界;

2) 根据式(12),计算边界上像素点的优先权,并找出具有最大优先权的待修复块${\mathit{\boldsymbol{\psi }}_{\hat p}}$

3) 根据式(14),自适应确定待修复块${\mathit{\boldsymbol{\psi }}_{\hat p}}$的最佳大小;

4) 根据式(15),分别在R、G、B的已知区域中寻找最佳匹配块;

5) 将最佳匹配块分别复制到R、G、B分量的待修复块中;

6) 根据式(6)更新置信度项;

7) 重复步骤1)— 6),直到破损区域中的像素被填充完。

2 实验结果及分析

为了验证改进算法的有效性,在3.30 GHz处理器、2 GB内存的计算机上,利用Matlab R2011软件进行了仿真实验。下面给出参数为$ρ$=0.4、$α$=0.4、$β$=0.6的实验仿真结果,同时也给出了本文算法与Criminisi算法[5]、文献[13]算法(LLZ)、文献[14]算法(SYM)和文献[15]算法(WLP)的对比结果,彩色图像的修复效果采用峰值信噪比(PSNR)、结构相似度(SSIM)[19]及运行时间来进行客观评判。其中两幅图像$\mathit{\boldsymbol{X}}$$\mathit{\boldsymbol{Y}}$的结构相似度定义为[19]

$ S = \frac{{\left( {2{u_X}{u_Y} + {c_1}} \right)\left( {2{\delta _{XY}} + {c_2}} \right)}}{{\left( {u_X^2 + u_Y^2 + {c_1}} \right)\left( {\delta _X^2 + \delta _Y^2 + {c_2}} \right)}} $ (16)

式中,${u_X}$${u_Y}$分别为图像$\mathit{\boldsymbol{X}}$$\mathit{\boldsymbol{Y}}$的均值,${\delta _X}$${\delta _Y}$为其方差,${\delta _{XY}}$$X$$Y$的协方差,${c_1}$=6.502 5,${c_2}$=58.522 5。

图 6分别给出了Criminisi算法[5]、文献[13]算法、文献[14]算法、文献[15]算法和本文算法对Lena彩色破损图像的修复结果。为了比较方便,并对修复结果作了局部放大。从图 6中看出,Criminisi算法的修复结果产生了一些额外的填充块,并在曲线结构处(如肩膀部位)未能保持结构的连续性;文献[13]和文献[14]算法对图像的纹理部分修复较好,但对曲线结构的修复不理想,出现了断裂或延伸现象;文献[15]算法对图像的结构边缘有较好的保持,但在纹理区域出现了模糊现象;从图 6(g)中可以看出,本文算法对不同的破损区域都有较好的修复结果。

图 6 Lena破损图像的修复结果图
Fig. 6 Repair results of Lena damaged image((a) original image; (b) image to be inpainted; (c) Criminisi algorithm; (d) reference [13]; (e) reference [14]; (f) reference [15]; (g) ours)

图 7是5种算法对纹理比较丰富的Baboon彩色破损图像的修复结果。从图 7中看出,Criminisi算法[5]和文献[14]算法在修复图像的边缘(如左脸颊部位)时产生了明显的结构延伸现象,并在纹理区域填充了错误的匹配块;文献[13]和文献[15]算法在修复图中的鼻子时,其结果不太符合人眼的视觉特性。而本文算法对线性结构和纹理区域都有较好的保持,克服了Criminisi算法所存在的不足,同时也说明,在寻找最佳匹配块时,采用自适应大小的样本块能对复杂结构有较好的修复。

图 7 Baboon破损图像的修复结果
Fig. 7 Repair results of Baboon damaged image((a) original image; (b) image to be inpainted; (c) Criminisi algorithm; (d) reference [13]; (e) reference [14]; (f) reference [15]; (g) ours)

图 8是对结构和纹理都比较复杂的Barb彩色划痕图像进行修复的结果。从图 8(c) (d) (e) (f)可以看出,4种算法都对图像的纹理部分修复较好,但Criminisi算法[5]和文献[13]算法在胳膊与膝盖的交界处等结构边缘出现了明显的错误延伸现象;本文算法对纯纹理和强边缘区域修复的较好,而在纹理和边缘的交界处(如图中手腕处)仍有一点延伸现象。

图 8 Barb破损图像的修复结果
Fig. 8 Repair results of Barb damaged image((a) original image; (b) image to be inpainted; (c) Criminisi algorithm; (d) reference [13]; (e) reference [14]; (f) reference [15]; (g) ours)

图 9是对结构相对简单的Peppers彩色破损图像的修复结果。从图 9(c) (e) (f)中可以看出,Criminisi算法[5]、文献[14]和文献[15]算法在修复平坦区域的过程中产生了错误的填充块;文献[13]算法在修复弱边缘结构时出现了结构断裂的现象,如图 9(d)所示,而本文算法在整体结构修复效果较好。

图 9 Peppers破损图像的修复结果
Fig. 9 Repair results of Peppers damaged image((a) original image; (b) image to be inpainted; (c) Criminisi algorithm; (d) reference [13]; (e) reference [14]; (f) reference [15]; (g) ours)

在对比实验中,也对物体移出进行了仿真实验。图 10是对大物体移除的修复结果图。从图 10(c) (d) (e) (f) 中看出,Criminisi算法[5]、文献[13]、文献[14]和文献[15]算法在修复大面积的破损区域时容易产生错误的匹配块,导致修复效果不佳;而本文算法克服了上述缺点,使得破损边界与周围区域没有产生块效应。

图 10 Cow物体移除修复结果图
Fig. 10 Repair results of Cow object removal((a) original image; (b) image to be inpainted; (c) Criminisi algorithm; (d) reference [13]; (e) reference [14]; (f) reference [15]; (g) ours)

图 11是对彩色图像window文字去除的修复结果对比。从图 11(d)中看出,文献[13]在部分结构和纹理处产生了错误的延伸;而Criminisi算法[5]、文献[14]和文献[15]算法在图像的边缘结构处出现了明显的断裂,但对平滑部分都有较理想的修复效果,如图 11(c) (e) (f)所示;而本文算法对图像的平滑区域和边缘结构的修复结果则较为理想。

图 11 Window文字去除修复结果
Fig. 11 Repair results of Window text removal((a) original image; (b) image to be inpainted; (c) Criminisi algorithm; (d) reference [13]; (e) reference [14]; (f) reference [15]; (g) ours)

图 12分别给出了Criminisi算法[5]、文献[15]算法和本文算法对破损线条的修复过程,其中图 12(c) 图 (d) (e)是3个算法的最终修复结果,图 12(f) (g) (h)为各算法修复过程的中间部分结果(图中修复效果,从左至右按修复步数增加排列)。从图 12(c) (d) (e)中可以看出,Criminisi算法和文献[15]算法的修复效果不佳,出现了明显的断裂现象;而本文算法在修复线性结构时,较好地保持了图像边缘的连续性,其修复结果也符合人眼视觉特性;通过对比图 12(f) (g) (h)可以得出,对破损区域块进行修复时,其正确的填充顺序对整个修复结果至关重要。

图 12 不同算法的修复过程
Fig. 12 The inpainting process of different algorithms ((a) original image; (b) image to be inpainted; (c) Criminisi; (d) reference [15]; (e) our method; (f) step 5、10、20、30、40 of Criminisi algorithm; (g) step 5、10、17、22、25 of reference [15]; (h)step 10、20、30、45、60 of ours)

表 2表 3分别给出了各算法的峰值信噪比(PSNR)、结构相似度(SSIM)及运行时间。从表中可以看出,相比于Criminisi算法[5]、文献[13]算法、文献[14]算法和文献[15]算法,本文算法的PSNR值相对提高了1~3 dB,SSIM也得到改善;但从运行时间来看,本文算法高于其他4种算法,这是因为在修复过程中,采用自适应样本块大小来搜索最佳匹配块以及像素相干因子的计算,都会增加一定的运行时间,从而降低了图像的修复效率。

表 2 各修复算法的PSNR和SSIM对比
Table 2 PSNR and SSIM of different inpainting algorithms

下载CSV
待修复彩色图像(尺寸/像素) (PSNR/dB)/ SSIM
Criminisi算法 文献[13]算法 文献[14]算法 文献[15]算法 本文算法
Lena (512×512) 36.953 3 / 0.970 7 37.227 4 / 0.971 9 37.160 0 / 0.971 8 37.319 2 / 0.972 0 38.819 8 / 0.972 6
Baboon (512×512) 32.275 6 / 0.969 3 32.467 2 / 0.969 2 33.325 1 / 0.970 5 33.607 5 / 0.970 6 34.989 2 / 0.971 9
Barb (671×531) 39.302 2 / 0.973 2 39.359 2 / 0.973 2 39.998 6 / 0.974 0 40.334 4 / 0.974 2 40.755 2 / 0.974 5
Peppers (512×512) 33.794 7 / 0.953 3 34.723 2 / 0.955 3 34.732 7 / 0.955 1 35.345 8 / 0.956 1 36.578 8 / 0.957 5
Cow(512×384) - - - - -
Window(512×384) 31.719 0 / 0.948 3 31.578 5 / 0.948 5 31.538 7 / 0.948 9 32.063 5 / 0.950 0 32.187 4 / 0.950 6
注:Cow为物体移除实验,其PSNR值没有意义,故未进行实验。

表 3 各修复算法的运行时间对比
Table 3 Running time of different inpainting algorithms

下载CSV
待修复彩色图像(尺寸/像素) 运行时间/ s
Criminisi算法 文献[13]算法 文献[14]算法 文献[15]算法 本文算法
Lena (512×512) 75.28 45.37 95.07 117.08 277.86
Baboon (512×512) 50.33 30.54 58.32 74.37 175.08
Barb (671×531) 68.89 44.49 83.79 96.32 256.82
Peppers (512×512) 91.68 61.82 130.63 142.49 298.84
Cow(384×512) 139.35 125.11 160.32 180.88 369.92
Window(384×512) 516.13 322.52 672.94 892.19 1 147.11

3 结论

针对传统Criminisi算法的不足,本文充分利用结构张量能够体现图像的局部结构特性这一特点,利用结构张量对优先权函数进行改进,使得修复顺序更加准确;将结构张量作为自适应选择样本块大小的依据,实现不同区域采用不同样本块大小进行修复,以克服结构不连续和纹理错误延伸的缺点;在最佳匹配准则中引进结构张量特征值信息来减少错误匹配率。实验结果表明,相比于传统Criminisi算法,本文算法对复杂的线性结构和纹理区域都有较理想的修复效果,有效地提高了图像的修复质量,其PSNR值相对提高了1~3 dB;并与其他相关算法相比,其PSNR值和SSIM值都有所提高。但是,改进算法仍在一些不足,如在弱纹理、纹理与边缘的交界处修复不理想,以及修复相对耗时,这些将是今后需要进一步研究解决的问题。

参考文献

  • [1] Bertalmio M, Sapiro G, Caselles V, et al.Image inpainting[C]//Proceedings of the 27th Annual Conference on Computer Graphics and Interactive Techniques.New York, USA: ACM, 2000: 417-424.[DOI: 10.1145/344779.344972]
  • [2] Shen J H, Chan T F. Mathematical models for local nontexture inpaintings[J]. SIAM Journal on Applied Mathematics, 2002, 62(3): 1019–1043. [DOI:10.1137/S0036139900368844]
  • [3] Shen J H, Kang S H, Chan T F. Euler's elastica and curvature-based inpainting[J]. SIAM Journal on Applied Mathematics, 2002, 63(2): 564–592. [DOI:10.1137/S0036139901390088]
  • [4] Tsai A, Yezzi A, Willsky A S. Curve evolution implementation of the Mumford-Shah functional for image segmentation, denoising, interpolation, and magnification[J]. IEEE Transactions on Image Processing, 2001, 10(8): 1169–1186. [DOI:10.1109/83.935033]
  • [5] Criminisi A, Perez P, Toyama K. Region filling and object removal by exemplar-based image inpainting[J]. IEEE Transactions on Image Processing, 2004, 13(9): 1200–1212. [DOI:10.1109/TIP.2004.833105]
  • [6] Ren S, Tang X H, Kang J L. Improved Criminisi algorithm with the texture and edge features[J]. Journal of Image and Graphics, 2012, 17(9): 1085–1091. [任澍, 唐向宏, 康佳伦. 利用纹理和边缘特征的Criminisi改进算法[J]. 中国图象图形学报, 2012, 17(9): 1085–1091. ] [DOI:10.11834/jig.20120906]
  • [7] Zhou Y T, Li L, Xia K W. Research on weighted priority of exemplar-based image inpainting[J]. Journal of Electronics (China), 2012, 29(1-2): 166–170. [DOI:10.1007/s11767-012-0843-6]
  • [8] Xu Z B, Sun J. Image inpainting by patch propagation using patch sparsity[J]. IEEE Transactions on Image Processing, 2010, 19(5): 1153–1165. [DOI:10.1109/TIP.2010.2042098]
  • [9] Hou Y T, Peng J Y, Han D C. Research of improved Criminisi image resoration algorithm[J]. Computer Engineering and Applications, 2015, 51(11): 135–138, 144. [侯玉婷, 彭进业, 韩东辰. 改进的Criminisi图像修复算法研究[J]. 计算机工程与应用, 2015, 51(11): 135–138, 144. ] [DOI:10.3778/j.issn.1002-8331.1306-0276]
  • [10] Choi J H, Hahm C H.An exemplar-based image inpainting method with search region prior[C]//Proceedings of the 2nd Global Conference on Consumer Electronics.Tokyo: IEEE, 2013: 68-71.[ DOI:10.1109/GCCE.2013.6664927]
  • [11] Patel K R, Jain L.A novel approach to exemplar based image inpainting[C]//Proceedings of 2016 International Conference on Communication and Signal Processing.Melmaruvathur, India: IEEE, 2016: 0810-0814.[DOI: 10.1109/ICCSP.2016.7754257]
  • [12] Ren S, Tang X H, Kang J L. An image inpainting algorithm combined with texture and edge features[J]. Journal of Computer-Aided Design & Computer Graphics, 2013, 25(11): 1682–1693. [任澍, 唐向宏, 康佳伦. 纹理和边缘特征相结合的图像修复算法[J]. 计算机辅助设计与图形学学报, 2013, 25(11): 1682–1693. ]
  • [13] Liu Y, Liu C J, Zou H L, et al.A novel exemplar-based image inpainting algorithm[C]//Proceedings of International Conference on Intelligent Networking and Collaborative Systems.Taipei, Taiwan, China: IEEE, 2015: 86-90.[DOI: 10.1109/INCoS.2015.15]
  • [14] Siadati S Z, Yaghmaee F, Mahdavi P.A new exemplar-based image inpainting algorithm using image structure tensors[C]//Proceeding of the 24th Iranian Conference on Electrical Engineering.Shiraz, Iran: IEEE, 2016: 995-1001.[DOI: 10.1109/IranianCEE.2016.7585666]
  • [15] Wang J, Lu K, Pan D R, et al. Robust object removal with an exemplar-based image inpainting approach[J]. Neurocomputing, 2014, 123: 150–155. [DOI:10.1016/j.Neucom.2013.06.022]
  • [16] Akl A, Saad E, Yaacoub C.Structure-based image inpainting[C]//Proceedings of 2017 International Conference on Image Processing Theory, TOOLS and Applications.Oulu, Finland: IEEE, 2017.[DOI: 10.1109/IPTA.2016.7820976]
  • [17] Akl A, Yaacoub C, Donias M, et al. Texture synthesis using the structure tensor[J]. IEEE Transactions on Image Processing, 2015, 24(11): 4082–4095. [DOI:10.1109/TIP.2015.2458701]
  • [18] Meur O L, Gautier J, Guillemot C.Examplar-based inpainting based on local geometry[C]//Proceedings of the 18th IEEE International Conference on Image Processing.Brussels, Belgium: IEEE, 2011: 3401-3404.[DOI: 10.1109/ICIP.2011.6116441]
  • [19] Wang Z, Bovik A C, Sheikh H R, et al. Image quality assessment:from error visibility to structural similarity[J]. IEEE Transactions on Image Processing, 2004, 13(4): 600–612. [DOI:10.1109/TIP.2003.819861]