Print

发布时间: 2019-07-16
摘要点击次数:
全文下载次数:
DOI: 10.11834/jig.180567
2019 | Volume 24 | Number 7




    图像处理和编码    




  <<上一篇 




  下一篇>> 





相似匹配块组的稀疏表示图像修复
expand article info 楼幸欣, 唐向宏, 张越
杭州电子科技大学通信工程学院, 杭州 310018

摘要

目的 传统多样本块稀疏表示的图像修复过程中,容易因为匹配样本块的错误,重构出不正确的填充块,致使在边缘部分产生不连贯的现象,然而单样本匹配填充又容易产生明显的伪影,不能保证与周围结构保持连续,以致产生明显的修复痕迹,为此,本文提出一种改进的基于相似匹配块组的稀疏表示方法。方法 首先,采用颜色信息与余弦距离结合的方法定义图像块匹配准则,在目标邻域范围内获得结构变化趋势更相似的匹配块组;然后,在稀疏重构过程中,同时考虑已知信息和估计的未知信息,利用相似块与目标块的匹配程度,对稀疏系数增加不同的权重,以此来增强筛选匹配块的能力,减少纹理模糊现象;最后,根据结构稀疏度自适应地在各结构复杂度不同的区域确定样本块尺寸,减少图像修复过程中的错误传播现象。结果 实验结果表明,本文算法改善了在边缘修复过程中产生断裂或者纹理延伸的现象,不仅在主观视觉有明显的提升,其修复结果的峰值信噪比(PSNR)相较于其他相关稀疏表示修复算法提高了0.53 dB。结论 本文算法实现了对不同结构特征的彩色破损图像的修复,在结构边缘处有理想的修复效果,并且对各种形状的破损也具有良好的修复效果。

关键词

彩色图像修复; 匹配准则; 相似块组; 稀疏约束; 自适应样本块大小

Sparsity image inpainting algorithm based on similar patch group
expand article info Lou Xingxin, Tang Xianghong, Zhang Yue
School of Communication Engineering, Hangzhou Dianzi University, Hangzhou 310018, China

Abstract

Objective In the process of traditional patch-group-based image inpainting, synthetizing the incorrect filling patch is easy, thus causing incoherence at the edge because of incorrect matching patches. However, a traditional exemplar-based image inpainting algorithm only uses a single patch to fill a damaged area, making it prone to generate strong artifacts. It could give rise to strong inpainting trace, which affects a person's visual sense, because of its uncertain consistency with the surrounding structure. To solve these problems, an improved sparsity image inpainting algorithm based on a similar patch group is proposed in this study. Method First, searching for similar patch groups only uses color differences, thus making it easy to match incorrect patches whose structural trend is obviously different from the target patch. The cosine distance is an effective tool for measuring the change in direction between vectors, and it can measure the proximity in the vector direction. Thus, the patch matching criterion is defined by the combination of color information and cosine distance in this study. In this manner, matching patches whose structural trend is similar to the target patch can be obtained, and the error matching rate can be reduced when matching similar patches. Second, in the process of sparse reconstruction, to enhance the capability to filter matched patches and decrease texture blur, we estimate the unknown pixels according to the similar patch group obtained in the first step. Considering that different matching patches have different filling effects on the filling area and to make the whole sparse representation model capable of filtering matching patches, we utilize known and estimated unknown information to calculate the matching degree between every similar patch and the target patch to add different weights on the sparse coefficients. Finally, repairing the detailed structure of the area with a fixed patch size is difficult because an image always has rich and varied information. Structural sparsity is used to reflect structural complexity; thus, the patch size is adaptively decided by structural sparsity in this study. Different from the method that uses a fixed threshold to determine the patch size, the proposed method iteratively calculates structural sparsity and decreases the patch size until the structural complexity of the patch is reduced to the average value, which helps reduce error propagation during image inpainting. Result This study shows several representative color images that are damaged artificially into different shapes for inpainting in Fig. 58. In addition, it compares the repair results for the same image damaged with different kinds of shapes and provides a detailed view of the result in Fig. 9. Experimental results show that the proposed algorithm is more effective in subjective vision than other related algorithms and improves the phenomenon of fracture or texture extension during the process of edge structure repair. Other experimental data are given in Tables 1-2. The results show a significant improvement in subjective vision, and the peak signal-to-noise ratio of the result is improved to approximately 0.53 dB. However, the running time is increased because the method needs to calculate the patch structure sparsity iteratively and adjust the adaptive patch size dynamically. Conclusion This study proposes a weighted sparsity image inpainting method based on a similar patch group. The method combines the features of color information and cosine distance so that trends similar to the target patch can be obtained while searching for similar patch groups. Thus, the method is precise during patch propagation. Moreover, different sparse weights are added according to the degree of similarity; thus, the structural information is preserved as much as possible during the entire process of inpainting, and texture blur is reduced. The combination of the two strategies can improve the efficiency of the image inpainting algorithm. The proposed inpainting algorithm achieves the inpainting of damaged color images with different structural features and shapes. We perform a comparison to prove that the proposed method is more efficient than existing color image inpainting methods. Results show that the improved method in this study has an ideal repair effect on the strong edge structure and multi-structure area, thus effectively improving the image restoration quality. Nevertheless, this method only utilizes the information within a certain range of the image. Therefore, several shortcomings, such as the unsatisfactory repairing result in the case of inconsistent edge structure and the inability to maintain edge curvature, still exist. Thus, our method is unsuitable for all kinds of images. Future research will focus on the recovery of the edge curve and irregular texture breakage.

Key words

color image inpainting; matching criterion; similar patch group; sparse constraint; adaptive patch size

0 引言

图像修复是通过某种算法对图像破损区域进行填补的过程,目前主要的修复算法可分3类:第1类是基于偏微分方程(PDE)的图像修复技术[1],该方法将未破损区域的信息各向异性地扩散到待修复区域的内部来对图像进行修复。这种方式仅对图像中小尺度的破损具有较好的修复效果。第2类是基于样本块的图像修复算法[2],其定义了一种基于等照度线的传播方式,然后在图像未破损区域中搜索与待修复块最匹配的样本块来填充破损区域。该方法对大面积的破损区域具有较好的修复效果,但当匹配了错误的图像块时,极易产生错误延伸。第3类是基于稀疏理论的修复方法[3-10],由于该修复方法不局限于局部信息,采用稀疏重构的方式,在修复过程中不容易产生明显的错误延伸等现象,是一种比较稳健的图像修复算法,因此该方法成为目前图像修复领域研究的热点。

基于稀疏表示的图像修复可分为两大步骤,即训练字典和稀疏重构,其中字典的优劣对整个图像修复过程起着至关重要的作用。文献[3]提出使用K-奇异值分析(K-SVD)算法训练过完备字典,采用字典原子与对应的稀疏系数同时更新的方式加速收敛,但是该方法只能修复面积较小的破损,且计算量仍然很大。Filipovic'等人[4]提出采用快速独立分量分析(FastICA)对大量样本图像训练得出字典,克服了K-SVD稀疏修复算法不能修复粗线条状破损的缺点,但是这种方法对修复图像的类型具有局限性,不能适应不同类型的图像。文献[5]提出将图像内容分为纹理、平滑、边缘3部分,分别用K-SVD算法训练得出对应的字典,再使用正交匹配追踪(OMP)进行稀疏重构,一方面增强了字典的适应性,修复效果得以提高,但是另一方面计算时间也成倍增加。为了减少训练字典带来的时间耗费,文献[6]将图像的已知区域分成尺寸一致的图像块用做字典输入,再对目标块进行稀疏重构,虽然该算法能修复大面积缺损区域,但由于缺乏对稀疏系数的约束,导致筛选字典原子的能力差,填充块与已知区域之间有明显的修复痕迹,只能修复简单的图像。文献[7]利用破损区域的邻域相似块组作为字典输入,并且提出了基于块结构稀疏的传播方法,改善了块传播中纹理延伸的问题,效果要好于传统的基于等照度线的结构传播方法,此外在重构时增加了邻域一致性的约束,对大面积缺损的区域修复效果较好,但是由于缺乏对不同图像块局部特性的考虑,采用大小一致的样本块尺寸,在边缘结构部分容易产生不连贯的情况。在此基础上,文献[8]提出增加双正则项来约束字典原子的选择,但是仅利用已知信息的一致性并不能保证未知信息的相似度,因此可能会产生边缘不连贯、纹理延伸等问题,修复效果有限。文献[9]引入梯度模值信息进行相似块的匹配,但只能在相邻像素的灰度变化上进行衡量,而没有对图像块整体灰度变化趋势进行考虑,从而导致对结构变化明显的区域并不能匹配到视觉上相似的样本块。文献[10]利用邻域范围内图像块与目标块的颜色差异进行统计,根据直方图偏度的大小估计未知像素信息,在一定情况下得到了不错的效果,但是在边缘等局部相似性比较低的区域,仅利用统计信息仍容易产生边缘不连续的情况。

针对以上算法可能造成修复痕迹明显及边缘不连贯的问题,本文采用颜色信息与余弦距离相结合的方式来构建匹配相似块组,用来取代稀疏重构中的字典; 然后,利用图像块与匹配块间的相似度,得到预估计的填充块,再根据预估计的填充块与相似块之间的距离,来调整不同的稀疏系数权重,使重构更加精准; 最后根据块结构稀疏度大小,自适应调整样本块尺寸大小,以提高图像修复的效果。

1 本文算法

与传统的基于样本块的修复算法不同,多个样本块组成的稀疏修复算法的基本思想是,取与目标块灰度差异最小的前$K$个匹配块组成相似块组来代替字典,以克服修复过程中由于样本单一造成明显伪影的现象[7]。因此,多个样本块组成的稀疏修复算法通常由待修复块的优先级的确定、相似匹配块组的构造、稀疏重构填充块等3个步骤组成。

1.1 待修复块优先级的确定

假设${{\boldsymbol{\psi }}_p} \in {{\bf{R}}^{{m^2} \times 1}}$是破损边界上以$p$点为中心、尺寸为$m$、经向量化后的图像块,$\mathit{\boldsymbol{ \boldsymbol{\varOmega} }}$为破损区域,$\mathit{\boldsymbol{N}}(p)$$p$点的邻域范围$M \times M$($M>m$),$\mathit{\boldsymbol{N}}_s(p)$$\mathit{\boldsymbol{N}}(p)$内的已知范围,${\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}$为在邻域已知区域内以$q_j$为中心的图像块,采用文献[7]基于块结构稀疏度的传播方式,首先给出块间相似度的定义为

$ {\omega _{p,{q_j}}} = \frac{1}{{Z\left( p \right)}}\exp \left( { - \frac{{{d_{{\rm{SSD}}}}\left( {\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p},\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right)}}{{{\sigma ^2}}}} \right) $ (1)

$ {d_{{\rm{SSD}}}}\left( {\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p},\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right) = \sum\limits_{k = 1}^m {{{\left( {\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_{{p_k}}} - \mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_{{j_k}}}}}} \right)}^2}} $ (2)

式中,$Z(p)$为归一化常数,其值为相似度向量$\mathit{\boldsymbol{\omega }}$的元素之和;$\mathit{\boldsymbol{\overline P}} $为提取已知像素的掩膜矩阵,$\mathit{\boldsymbol{\overline P}} $将未知信息置0;$\sigma$为衰减因子;${d_{{\rm{SSD}}}}\left({\mathit{\boldsymbol{\overline P}} {\mathit{\boldsymbol{\psi }}_p}, \mathit{\boldsymbol{\overline P}} {\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right)$为对应已知像素点的颜色差值的平方和(SSD),${\mathit{\boldsymbol{\psi }}_{{p_k}}}$${\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_{{j_k}}}}}$分别为待修复块和匹配块向量中对应的元素,则块结构稀疏度定义为

$ \begin{array}{*{20}{c}} {\rho \left( p \right) = {{\left\| \mathit{\boldsymbol{\omega }} \right\|}_2}\sqrt {\frac{{\left| {{\mathit{\boldsymbol{N}}_s}\left( p \right)} \right|}}{{\left| {\mathit{\boldsymbol{N}}\left( p \right)} \right|}}} = }\\ {\sqrt {\left[ {\sum\limits_{{q_j} \in {\mathit{\boldsymbol{N}}_s}\left( p \right)} {\omega _{p,{p_j}}^2} } \right] \cdot \frac{{\left| {{\mathit{\boldsymbol{N}}_s}\left( p \right)} \right|}}{{\left| {\mathit{\boldsymbol{N}}\left( p \right)} \right|}}} } \end{array} $ (3)

式中,${\left\| \cdot \right\|_2}$为向量的$\rm{L}_2$范数,$\left| {{\mathit{\boldsymbol{N}}_s}(p)} \right|$$\left| {{\mathit{\boldsymbol{N}}}(p)} \right|$分别表示邻域已知块的数量和邻域块的总数。由于边缘部分与邻域的相似度普遍较低,导致边缘处的邻域相似度向量$\mathit{\boldsymbol{\omega }}$稀疏性会比较高,因此,根据边缘结构优先修复的原则,给出优先权的定义,即

$ P\left( p \right) = D\left( p \right)C\left( p \right) = \left[ {{T_{\left( {0.2,1} \right)}}\left( {\rho \left( p \right)} \right)} \right]C\left( p \right) $ (4)

$ {T_{\left( {0.2,1} \right)}}\left( {\rho \left( p \right)} \right) = 0.8 \times \rho \left( p \right) + 0.2 $ (5)

式中,${T_{(0.2, 1)}}(\rho (p))$表示将$\rho (p)$线性映射到[0.2,1]的范围内,$C(p)$表示$p$点的置信度,具体定义为

$ C\left( p \right) = \sum\limits_{q \in {\mathit{\boldsymbol{\psi }}_p} \cap \mathit{\boldsymbol{ \boldsymbol{\varOmega} }}} {\frac{{C\left( q \right)}}{{\left| {{\mathit{\boldsymbol{\psi }}_p}} \right|}}} $ (6)

式中,$\left| {{\mathit{\boldsymbol{\psi }}_p}} \right|$代表图像块的像素个数。对于已知像素点与未知像素点的$C(q)$分别初始化为1和0,随着修复的进行,破损边界不断缩小,边界$p$点的置信度点的置信度逐渐降低。

1.2 相似块组的构造

由于多样本块的图像修复重构过程中,算法需要利用多个匹配块作为填充信息,那么匹配块的优劣直接影响着修复效果。特别是在边缘结构部分,若匹配的相似块与待填充块并不相似,不仅会重构出错误的填补块,还会对后续填充过程造成错误的传播,影响视觉效果。因此,仅采用颜色差异(即对各颜色通道采用欧氏距离衡量相似程度)寻找匹配块,容易在结构特征明显的部位匹配到变化趋势并不一致的匹配块[9]

由于余弦距离是度量向量之间方向变化趋势的有效工具,能较好地衡量向量方向上的接近度,但它对向量之间的长度差异并不敏感。因此,本文提出一种颜色信息结合余弦距离的匹配准则,将颜色信息与余弦距离相结合,对匹配块之间的距离的度量重新定义为

$ \begin{array}{*{20}{c}} {d\left( {{\mathit{\boldsymbol{\psi }}_p},{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right) = }\\ {\gamma \cdot \left(1- {{d_{{\rm{COS}}}}\left( {{\mathit{\boldsymbol{\psi }}_p},{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right)} \right) + {d_{{\rm{SSD}}}}\left( {{\mathit{\boldsymbol{\psi }}_p},{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right)} \end{array} $ (7)

式中,$\gamma = 255 \cdot \left| {{\mathit{\boldsymbol{\psi }}_p}} \right|$为平衡因子;${d_{\rm{COS} }}\left({{\mathit{\boldsymbol{\psi }}_p}, {\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right)$为图像块${\mathit{\boldsymbol{\psi }}_p}$${\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}$的余弦距离,其大小定义为

$ {d_{{\rm{COS}}}}\left( {{\mathit{\boldsymbol{\psi }}_p},{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right) = \frac{{{\mathit{\boldsymbol{\psi }}_p} \cdot {\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}}}{{\left| {{\mathit{\boldsymbol{\psi }}_p}} \right| \cdot \left| {{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right|}} $ (8)

从式(7)可以看出,对匹配块之间的距离度量不仅反映了向量之间的长度差异,同时又体现了向量之间方向变化的关系。图 1给出了以Cameraman图像为例,采用不同匹配准则获得相似块组的比较结果。在图 1(c)图 1(d)中,相似图像块组按照距离$d$由小到大从左至右、从上至下排列。从图 1可以发现,本文定义的距离度量可以较好地匹配到灰度变化趋势接近的图像块,结构上更相似,更符合主观感受,而欧氏距离匹配到的图像块(如图 1(c)红框内)变化较平缓,与目标块整体变化趋势不符,将对后续修复产生不当影响。

图 1 不同匹配准则匹配的相似块组
Fig. 1 Comparison of different matching criterions((a) Cameraman image; (b) target patch; (c) matching results of Euclidean distance; (d) matching results of our approach)

1.3 稀疏表示模型的改进

稀疏表示[11]认为自然信号能由一组尽可能“少”的原子进行线性表示,这些原子组往往由过完备字典构成。因此,传统的图像修复稀疏表示模型表述为

$ \mathit{\boldsymbol{\alpha }} = \arg \mathop {\min }\limits_\mathit{\boldsymbol{\alpha }} \frac{1}{2}\left\| {\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p} - \mathit{\boldsymbol{\bar PD\alpha }}} \right\|_2^2 + \beta {\left\| \mathit{\boldsymbol{\alpha }} \right\|_0} $ (9)

式中,$\mathit{\boldsymbol{D}}$为过完备字典,$\mathit{\boldsymbol{\alpha}}$为稀疏系数,$\beta$为稀疏平衡因子。式(9)为非确定多项式问题,Donoho等人[12]已证明$\rm{L}_1$范数能很好地接近$\rm{L}_0$范数。由于训练过完备字典需要进行大量的计算,时间耗费大,因此,本文采用相似块组替代过完备字典的方式进行稀疏求解,即

$ \mathit{\boldsymbol{\alpha }} = \arg \mathop {\min }\limits_\mathit{\boldsymbol{\alpha }} \frac{1}{2}\left\| {\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p} - \mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_p}\mathit{\boldsymbol{\alpha }}} \right\|_2^2 + \beta {\left\| \mathit{\boldsymbol{\alpha }} \right\|_1} $ (10)

式中,${\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_p} = \left\{ {{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right\}_{j = 1}^K$为相似块组。由于在由多个样本块组成的稀疏修复算法中,若直接将相似块组重构表示为填充块,会因缺少对每个相似块与目标块之间的相似性加以区分而容易产生边缘模糊的现象。为此,为了更好地利用相似块组与目标块之间的相似性,本文利用相似块组已知维度的信息,结合式(7),首先计算出与目标块的相似度${\mathit{\boldsymbol{s}}_{p, {q_j}}}$,即

$ {s_{p,{q_j}}} = \frac{1}{{Z\left( p \right)}}\exp \left( { - \frac{{d\left( {\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p},\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \right)}}{{{\sigma ^2}}}} \right) $ (11)

对于部分信息丢失的图像块,若仅利用已知信息进行稀疏重构,容易造成未知信息的模糊。为此,本文采用对目标块的未知部分进行预估计,利用相似度${\mathit{\boldsymbol{s}}_{p, {q_j}}}$对相似块组进行线性组合,得出预估计的填充块${\mathit{\boldsymbol{\widehat \psi }}_p}$的未知部分,即

$ \mathit{\boldsymbol{P}}{\mathit{\boldsymbol{\hat \psi }}_p} = \mathit{\boldsymbol{P}}\sum\limits_{j = 1}^K {{s_{p,{q_j}}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} $ (12)

式中,$\mathit{\boldsymbol{P}}$为提取未知信息的掩膜矩阵,将未知信息维度置1,已知维度置0。由于填充块${\mathit{\boldsymbol{\widehat \psi }}_p}$的已知部分固定,则整个填充块${\mathit{\boldsymbol{\widehat \psi }}_p}$向量可以表示为

$ {\mathit{\boldsymbol{\hat \psi }}_p} = \left( \begin{array}{l} \mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p}\\ \delta \mathit{\boldsymbol{P}}\sum\limits_{j = 1}^K {{s_{p,{q_j}}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \end{array} \right) $ (13)

式中,$\delta$为平衡系数,用来平衡已知信息和未知信息的约束强度,取值范围为[0, 1],$\delta$越大则表示估计出的未知信息对整个稀疏模型的约束越大。同时,考虑到不同相似块对填充块具有不同的填充效果,为了使整个稀疏表示模型更具筛选匹配块的能力,将已知信息和估计的未知信息同时考虑,对具有不同相似程度的匹配块采用不同的稀疏权重系数进行重构,将重构式(10)改为

$ \begin{array}{*{20}{c}} {\mathit{\boldsymbol{\alpha }} = }\\ {\arg \mathop {\min }\limits_\mathit{\boldsymbol{\alpha }} \frac{1}{2}\left\| {\left( \begin{array}{l} \mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p}\\ \delta \mathit{\boldsymbol{P}}\sum\limits_{j = 1}^K {{s_{p,{q_j}}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}}} \end{array} \right) - \left( \begin{array}{l} \mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_p}\mathit{\boldsymbol{\alpha }}\\ \delta \mathit{\boldsymbol{P}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_p}\mathit{\boldsymbol{\alpha }} \end{array} \right)} \right\|_2^2 + \beta {{\left\| {\mathit{\boldsymbol{W\alpha }}} \right\|}_1}} \end{array} $ (14)

$ \mathit{\boldsymbol{\alpha }} = \arg \mathop {\min }\limits_\mathit{\boldsymbol{\alpha }} \frac{1}{2}\left\| {{{\mathit{\boldsymbol{\hat \psi }}}_p} - \mathit{\boldsymbol{X}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_p}\mathit{\boldsymbol{\alpha }}} \right\|_2^2 + \beta {\left\| {\mathit{\boldsymbol{W\alpha }}} \right\|_1} $ (15)

式中,$\mathit{\boldsymbol{X}} = \left({\begin{array}{*{20}{l}} {\mathit{\boldsymbol{\overline P}} }\\ {\delta \mathit{\boldsymbol{P}}} \end{array}} \right)$$\mathit{\boldsymbol{W}}$为稀疏权重矩阵,$\mathit{\boldsymbol{W = }}\left[{\begin{array}{*{20}{c}} {{w_1}} & 0 & \cdots & 0\\ 0 & {{w_2}} & 0 & 0\\ {} & {} & \vdots & {}\\ 0 & 0 & \cdots & {{w_K}} \end{array}} \right]$,对角线上对应匹配块的稀疏权重系数$w_j$的大小为

$ {w_j} = \frac{{\mathit{\boldsymbol{X}}{\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_{{q_j}}} - \mathit{\boldsymbol{\hat \psi }}_p^2}}{h},\;\;\;j = 1,2, \cdots ,K $ (16)

式中,$h$为衰落因子。式(15)表明,当稀疏权重因子越大时,对稀疏系数的约束性越强,更倾向于选择更少的匹配块组进行组合表示;反之,则更多。对于边缘结构部分,由于局部相似度低,用少数目的匹配块组进行表示可能会产生边缘突兀、不连贯等问题。为了适应不同的局部特征,本文将利用块稀疏度大小$ρ(p)$来调整衰落因子$h$,自适应地调整稀疏权重的大小,即

$ h = \left| {\mathit{\boldsymbol{\bar P}}{\mathit{\boldsymbol{\psi }}_p}} \right| \cdot \rho \left( p \right) $ (17)

图 2分别给出了采用不同稀疏表示模型对彩色图像Barbara局部破损的修复效果图。从图 2对比可以看出,文献[5]算法在边缘结构、纹理都比较复杂时不能保持边缘连贯,这是由于过完备字典不能更新,导致在修复范围缩小时产生了断层现象,如图 2(c)所示;文献[7]算法由于约束强度不能根据局部特性调整,容易在边缘发生断裂,纹理也产生了模糊,如图 2(d)所示;文献[8]算法由于仅仅利用已知信息对稀疏系数进行约束,虽然保持了纹理的清晰,但是在强边缘部位仍然发生了模糊,弱化了边缘,如图 2(e)所示。图 2(f)中,文献[10]算法根据目标块与周围图像块的差异统计,以此匹配相似块组,容易在边缘结构区域产生伪影;从图 2(g)可以看出,本文算法获得了较好的修复效果,改善了纹理模糊和边缘弱化现象,在边缘结构和纹理的修复获得较好的修复效果,峰值信噪比(PSNR)得到了提高。

图 2 不同稀疏修复算法的比较
Fig. 2 Comparison with different sparsity-based inpainting algorithms((a) original images; (b) damaged images; (c) reference [5]; (d) reference [7]; (e) reference [8]; (f) reference [10]; (g) ours)

1.4 自适应样本尺寸

在图像块传播修复的过程中,一般采用尺寸固定的样本块去填补破损块,在边缘结构简单的部位(边缘结构线条趋于直线)能取得不错的效果,但是在一些边缘结构偏弯曲的部分,破损边界点容易沿着相同的方向进行传播,造成边缘的不连续。因此,对于边缘结构部分,应采取尺寸较小的模板,以减小错误传播。采用块结构稀疏度自适应地调整样本大小,具体定义为

$ m = \left\{ \begin{array}{l} m - 2\;\;\;\rho \left( p \right) > \eta \\ m\;\;\;\;\;\;\;\;\rho \left( p \right) \le \eta \;或\;m = 3 \end{array} \right. $ (18)

式中,初始值$m=9$$\eta$为所有边界点的块结构稀疏度的平均值($\overline \rho$)。每一次减小尺寸$m$时,都需重新计算相应的块结构稀疏度$\rho (p)$,再与$\eta$比较,直至$\rho (p) \le \eta $或者$m=3$

图 3给出了不同样本尺寸下对Lena图的修复效果,在Lena图不同的区域破损大小分别为20×20像素,通过对比修复结果可以发现,采用固定的样本尺寸容易在结构边缘处产生延伸,不能很好地适应结构变化,如图中帽檐部分。过大的样本尺寸(如9×9像素),虽然纹理区域的修复效果与周边的连续性较好,但是在边缘结构区域仍不可避免地会出现延伸;而过小的样本尺寸(如3×3像素),往往会因忽略了局部特征,造成与周边的连续性较差(如图 3(f)纹理区域所示),且运行时间大幅增长。而本文采用自适应样本尺寸能根据目标块与周围样本块的相似情况,保持局部特征的同时,动态地调整样本尺寸,其修复效果在边缘结构破损部位能保持连续,克服一定的断层和延伸现象。

图 3 采用不同样本块尺寸的修复结果比较
Fig. 3 The results of using different patch size((a) original image; (b) damaged image; (c) 9×9 pixels; (d) 7×7 pixels; (e) 5×5 pixels; (f) 3×3 pixels; (g) adaptive patch size)

综上所述,本文算法流程图如图 4所示,其实现步骤如下:

图 4 本文算法流程图
Fig. 4 The flow chart of the proposed algorithm

1) 提取待修复区域边缘$\partial \mathit{\boldsymbol{ \boldsymbol{\varOmega} }}$

2) 利用式(3)计算块结构稀疏度$\rho (p)$,由式(4)确定优先权最大的图像块作为当前待修复块${\mathit{\boldsymbol{\psi }}_p}$

3) 利用式(18)自适应地根据$\rho (p)$确定样本尺寸大小$m$

4) 采用式(7)在确定的邻域范围内构建相似块组${\mathit{\boldsymbol{ \boldsymbol{\varPhi} }}_p}$

5) 重构当前待修复块,为了快速有效地求解式(15),本文采用文献[13]特征信号搜索的方法进行求解;

6) 更新边缘置信度$C(p)$

7) 重复步骤1)—6)进行修复,直至修复完成。

2 实验结果与分析

为了验证本文算法的有效性,在3.30 GHz处理器,2 GB内存的计算机上,利用MATLAB R2012a软件进行了仿真实验,下面给出部分实验结果。取邻域$N(p)$大小为51×51像素,相似块数目$K=200$,衰减因子$\delta=5$,平衡系数$\delta = 0.25$,稀疏平衡因子$\beta=0.5$。同时也与文献[5]、文献[7]、文献[8]和文献[10]进行了比较。彩色图像的修复效果采用峰值信噪比(PSNR)及结构相似度(SSIM)[14]来进行客观评判。

图 5给出了结构较简单的彩色图像House的修复结果及局部放大效果图。从图 5(c)可以看出,文献[5]由于没有充分利用局部信息,难以修复结构连续大块破损的情况,在边缘结构变化交错的区域(如窗沿)产生了错误的填充;文献[7]由于参与重构的相似块组不足,产生了多余的图像块,造成边缘结构延伸,如图 5(d)所示;文献[8]错误延伸现象得以改善,但是由于没能调整约束强度,仍然有边缘断裂、不平滑的问题,如图 5(e)所示;图 5(f)中,文献[10]引入核回归特征进行稀疏表示,在边缘结构方向变化单一的情况下能保持一定的边缘连续,但是在多边缘重合处仍存在延伸现象;从图 5(g)可以看出,本文算法对不同的结构类型都有较好的修复效果。

图 5 House破损图像修复结果
Fig. 5 The inpainted results of House damaged image((a) original House image; (b) damaged image; (c) reference [5]; (d) reference [7]; (e) reference [8]; (f) reference [10]; (g) ours)

图 6是对边缘结构有一定弧度的Peppers彩色破损图像的修复结果图。从图 6(c)(e)可以看出,文献[5]算法、文献[7]算法、文献[8]算法对结构简单的图像整体修复效果都比较好,同时边缘保持清晰,然而这3种算法仍然存在着结构延伸现象,没有保持边缘连贯。图 6(f)虽然没有产生明显的边缘断层现象,但是修复痕迹比较明显;如图 6(g)所示,本文算法对纹理较少的区域在保持边缘清晰度的同时,延伸现象也得到了改善,使修复的边缘结构较为光滑。

图 6 Peppers破损图像修复结果
Fig. 6 The inpainted results of Peppers damaged image((a) original Peppers image; (b) damaged image; (c) reference [5]; (d) reference [7]; (e) reference [8]; (f) reference [10]; (g) ours)

图 7是对纹理比较丰富的Baboon图的修复结果。从图中可以看出,文献[5]对圆弧形结构(如眼睛)修复效果较好,同时边缘保持清晰,但是对破损区域较大的部位仍然会产生错误的填充块,如图 7(c)所示;图 7(d)图 7(e)的错误延伸明显,此外,图 7(e)的鼻子边缘部分因为约束不当产生了凹陷。图 7(f)中,文献[10]在鼻子边缘区域修复效果良好,但是在纹理与边缘连接的破损区域,产生了明显的伪影,这是由于不规则纹理导致了匹配错误的相似块组。本文算法在结构变化单一的区域修复效果较好,但是在结构变化多变的区域还是会造成延伸现象,不能保持平滑,这是由于邻域选择范围的限制,导致稀疏重构时原子信息完备性低,如图 7(g)所示。

图 7 Baboon破损图像修复结果
Fig. 7 The inpainted results of Baboon damaged image((a) original Baboon image; (b) damaged image; (c) reference [5]; (d) reference [7]; (e) reference [8]; (f) reference [10]; (g) ours)

在对比实验中,也对文字移除进行了仿真实验,图 8是对Window图像去除文字的实验。5种算法的修复结果都没有发生明显的结构延伸现象。

图 8 Window破损图像修复结果
Fig. 8 The inpainted results of Window damaged image((a) original Window image; (b) damaged image; (c) reference [5]; (d) reference [7]; (e) reference [8]; (f) reference [10]; (g) ours)

图 9是对纹理丰富的Barbara图在4种破损情形下的修复结果比较。从图 9可以看出,本文算法修复痕迹较为不明显,在多个纹理与边缘连接的区域中,本文在4种破损情况下边缘结构保持了连续,修复较为自然。表 1给出了图 9中的修复评价标准PSNR、SSIM,可以看出本文算法不仅在视觉上取得了不错的效果,PSNR和SSIM也较为稳定,均得到了一定的提升。

图 9 Barbara破损图像修复结果
Fig. 9 The inpainted results of Barbara damaged image((a) original Barbara image; (b) damaged images; (c) reference [5]; (d) reference [7]; (e) reference [8]; (f) reference [10]; (g) ours)

表 1 4种破损情况下,各修复算法的PSNR、SSIM比较
Table 1 Comparison of PSNR and SSIM resulted of four damaged cases

下载CSV
Barbara破损 PSNR/dB SSIM
文献[5] 文献[7] 文献[8] 文献[10] 本文 文献[5] 文献[7] 文献[8] 文献[10] 本文
破损1 38.11 40.38 40.53 39.81 41.39 0.990 7 0.994 8 0.995 3 0.994 4 0.995 7
破损2 39.17 40.00 40.50 40.74 41.04 0.992 9 0.994 5 0.994 2 0.994 4 0.994 5
破损3 37.53 37.79 37.14 37.75 37.95 0.991 0 0.993 8 0.993 7 0.993 4 0.993 8
破损4 37.06 37.15 37.37 37.79 38.14 0.987 6 0.991 4 0.992 1 0.991 1 0.992 1
注:加粗字体表示最优结果。

表 2给出了各算法修复结果(图 5图 8)的PSNR和SSIM比较。首先,从表 2中可以看出,对破损图像的修复,本文算法较之其他4种算法修复效果都得到了提升;其次,在图 8对Window图像文字移除的对比实验中,文献[5]的PSNR提升明显,但是SSIM仍然最低,这是由于文献[5]采用全图作为先验信息,对这种细条状、覆盖面积广的文字破损具有一定的优势,但是由于缺少考虑局部特征,在SSIM上对比其他算法则是最低的,而本文算法的PSNR位于四者之间,较为稳定。

表 2 各修复算法的PSNR、SSIM比较
Table 2 PSNR and SSIM of different algorithms

下载CSV
破损图 PSNR/dB SSIM
文献[5] 文献[7] 文献[8] 文献[10] 本文 文献[5] 文献[7] 文献[8] 文献[10] 本文
House 30.11 38.26 39.53 38.08 41.76 0.975 5 0.988 1 0.989 5 0.987 2 0.992 0
Peppers 40.21 41.40 42.76 41.49 43.08 0.991 7 0.992 6 0.994 4 0.992 6 0.994 4
Baboon 33.70 34.50 34.05 34.65 34.98 0.981 2 0.983 6 0.983 9 0.983 4 0.984 1
Window 38.33 38.06 37.99 37.82 38.55 0.981 5 0.982 4 0.984 3 0.981 9 0.984 7
注:加粗字体表示最优结果。

3 结论

针对基于多样本修复算法容易产生边缘不连贯的问题,本文充分利用余弦距离能衡量向量之间方向变化趋势的特点,将图像块的颜色信息与余弦距离相结合,从向量之间的长度和方向变化的角度,对匹配准则进行改进,使得匹配样本块时更加准确;根据不同匹配块对整个稀疏重构过程具有不同的贡献,利用不同匹配块的相似程度,对相应的稀疏系数增加不同的权重,增强在重构过程中筛选匹配块的能力,减少模糊的现象;利用块结构稀疏度自适应地迭代调整样本块尺寸,得以减少边缘断裂、延伸的现象。实验结果表明,相比于其他4种算法,本文算法对强边缘结构和多结构区域都有较理想的修复效果,有效地提高了图像的修复质量,其PSNR值和SSIM值都有所提高。但是,改进算法仍存在一些不足,如在边缘结构方向多变的情况下修复不理想,不能保持边缘的平滑,这些将是今后需要进一步研究解决的问题。

参考文献

  • [1] Bertalmio M, Sapiro G, Caselles V, et al. Image inpainting[C]//Proceedings of the 27th Annual Conference on Computer Graphics. New York, USA: ACM, 2000: 417-424.[DOI: 10.1145/344779.344972]
  • [2] Criminisi A, Pérez 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]
  • [3] Aharon M, Elad M, Bruckstein A. K-SVD:an algorithm for designing overcomplete dictionaries for sparse representation[J]. IEEE Transactions on Signal Processing, 2006, 54(11): 4311–4322. [DOI:10.1109/TSP.2006.881199]
  • [4] Filipovic' M, Kopriva I, Cichocki A. Inpainting color images in learned dictionary[C]//Proceedings of the 20th European Signal Processing Conference. Bucharest: IEEE, 2012: 66-70.
  • [5] Kang J L, Tang X H, Zhang D, et al. Image inpainting by characteristic classification learning and patch sparsity propagation[J]. Journal of Computer-Aided Design & Computer Graphics, 2015, 27(5): 864–872. [康佳伦, 唐向宏, 张东, 等. 特征分类学习的结构稀疏传播图像修复方法[J]. 计算机辅助设计与图形学学报, 2015, 27(5): 864–872. ] [DOI:10.3969/j.issn.1003-9775.2015.05.012]
  • [6] Shen B, Hu W, Zhang Y M, et al. Image inpainting via sparse representation[C]//Proceedings of 2009 IEEE International Conference on Acoustics, Speech, and Signal Processing. Taipei, China: IEEE, 2009: 697-700.[DOI: 10.1109/ICASSP.2009.4959679]
  • [7] 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]
  • [8] Shi J G, Qi C. Sparse modeling based image inpainting with local similarity constraint[C]//Proceedings of 2013 IEEE International Conference on Image Processing. Melbourne: IEEE, 2013: 1371-1375.[DOI: 10.1109/ICIP.2013.6738282]
  • [9] Li Z D, He H J, Yin Z K, et al. A sparsity image inpainting algorithm combining color with gradient information[J]. Journal of Computer Research and Development, 2014, 51(9): 2081–2093. [李志丹, 和红杰, 尹忠科, 等. 结合颜色和梯度信息的稀疏图像修复算法[J]. 计算机研究与发展, 2014, 51(9): 2081–2093. ] [DOI:10.7544/issn1000-1239.2014.20130071]
  • [10] Ghorai M, Mandal S, Chanda B. Patch sparsity based image inpainting using local patch statistics and steering kernel descriptor[C]//Proceedings of the 23rd International Conference on Pattern Recognition. Cancun: IEEE, 2017: 781-786.[DOI: 10.1109/ICPR.2016.7899730]
  • [11] Rubinstein R, Bruckstein A M, Elad M. Dictionaries for sparse representation modeling[J]. Proceedings of 2010 IEEE, 2010, 98(6): 1045–1057. [DOI:10.1109/JPROC.2010.2040551]
  • [12] Donoho D L, Huo X. Uncertainty principles and ideal atomic decomposition[J]. IEEE Transactions on Information Theory, 2001, 47(7): 2845–2862. [DOI:10.1109/18.959265]
  • [13] Lee H, Battle A, Raina R, et al. Efficient sparse coding algorithms[C]//Proceedings of teh 20th Annual Conference on Neural Information Processing Systems. Vancouver, Canada, 2006: 801-808.[DOI: http://dx.doi.org/]
  • [14] 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]