Print

发布时间: 2023-03-16
摘要点击次数:
全文下载次数:
DOI: 10.11834/jig.220022
2023 | Volume 28 | Number 3




    图像处理    




  <<上一篇 




  下一篇>> 





利用功能图形的防伪码图像盲去模糊
expand article info 刘畅, 郑宏, 王田玉, 周承卓
武汉大学电子信息学院, 武汉 430072

摘要

目的 防伪码是一类经过特殊设计的QR(quick response)码,在防伪和溯源领域有着广泛应用。模糊的防伪码图像不利于解码和真伪鉴别,需要进行去模糊操作。目前主流的盲去模糊算法在用于防伪码图像时,去模糊效果不好且算法消耗时间较长。对此,本文提出一种基于防伪码功能图形的盲去模糊优化算法。方法 首先,定义了防伪码图像的强度先验和梯度先验。强度先验是图像像素的灰度值,而梯度先验是图像像素水平方向和垂直方向的差分。然后,将整幅模糊防伪码图像均分为左上、左下、右上、右下4块,提取左上、左下、右上3个位置的探测图形和右下的校正图形。最后,将强度先验和梯度先验作为约束项,利用正则化方法求出4个分块的清晰图像和模糊核。结果 本文测试了100幅人工添加模糊的防伪码图像和50幅手机实际拍摄的模糊防伪码图像,采用峰值信噪比(peak signal to noise ratio, PSNR)、结构相似度(structural similarity, SSIM)和自然图像质量评价器(natural image quality evaluator, NIQE)作为图像清晰度评价指标。从实验结果来看,相较于对比算法的最优结果,本文算法在手机拍摄的模糊防伪码图像数据集上的平均NIQE降低了3.02,复原时间缩短了22.07 s,且能较好地恢复防伪图案的细节信息。在人为添加模糊的防伪码图像数据集上,本文算法的性能也优于对比算法,且能够处理不同程度的运动模糊和离焦模糊。结论 本文提出的防伪码图像盲去模糊优化算法简单易实现,在保证一定去模糊效果的前提下,算法耗时大幅缩短。

关键词

防伪码; 盲去模糊; 功能图形; 梯度与强度先验; 正则化; 图像质量评价

Functional patterns-relevant blind-deblurring method for anti-counterfeiting code images
expand article info Liu Chang, Zheng Hong, Wang Tianyu, Zhou Chengzhuo
School of Electronic Information, Wuhan University, Wuhan 430072, China
Supported by: National Key R&D Program of China (2020YFF0304902); Nanchang Key Laboratory of Internet of Things Information Visualization Technology (2020-NCZDSY-017)

Abstract

Objective Anti-counterfeiting code can be as a sort of quick response (QR) code-special design. The functions of anti-counterfeiting and traceability of QR code are involved in beyond encoding and decoding. So, the quality of anti-counterfeiting code images is highly required for that. Actually, the obtained anti-counterfeiting code image is challenged to be blurred due to camera-derived noise, the relative shooting motion between camera and anti-counterfeiting code, and its errors-defocused. Generally, QR codes-relevant slight blur degradation does not have a great impact on the function-decoded of anti-counterfeiting codes in terms of its own error-modified ability, but the function of authenticity identification is still a challenging issue to be resolved via the restoration for blurred anti-counterfeiting code images. Most of current blind deblurring algorithms are aimed at natural images, which do not make full use of the features of anti-counterfeiting code. The restoration result is not effective and time cost is high as well. To resolve this problem, we develop a blind-deblurring method on the basis of anti-counterfeiting code's functional patterns. Method First, the blurred anti-counterfeiting code image is converted into grayscale and interpolation-bilinear is used to coordinate its size to 512×512 pixels. The intensity and gradient priors of anti-counterfeiting code image are re-identified in terms of its binary features. Intensity-prior means the gray values of clear anti-counterfeiting code image are concentrated between 0 and 255, while anti-counterfeiting code image-blurred are scattered between 0 and 255. Gradient-prior is defined as the difference between adjacent image pixels, which has horizontal and vertical directions. The gradient distribution of clear anti-counterfeiting code image is amongst 0, 255 and -255, whereas gradient values of blurred image are scattered between -255 and 255. Then, the entire blurred anti-counterfeiting code image is divided into four blocks with the same size: 1) upper left, 2) lower left, 3) upper right, and 4) lower right. After that, the three image position detection patterns of upper left, lower left and upper right and the correction pattern of lower right are extracted respectively. There are two potentials of block processing as mentioned below. The first one is beneficial for the deblurring-regularized method, which is scale-related temporal optimization. The other one is focused on comparative analysis for estimating the blur kernel of whole image to make deblurring result better in terms of non-uniform blur-melted block processing. Finally, intensity and gradient-priors cost function is as the constraints, and the deblurring problem is decomposed into two subproblems. The clear images and blur kernels of four blocks are generated based on regularization method and numerical method. Result First, we test 100 artificial blur-relevant anti-counterfeiting code images. The updated blur types consist of motion blur, defocus blur and the two blurs-coordinated. To evaluate the performance of those algorithms to be tested, peak signal to noise ratio (PSNR), structural similarity (SSIM) and the time cost are used as the indicators. The experimental result shows that our algorithm can deal with varied degrees of motion blur and defocus blur. Next, we test 50 blurred anti-counterfeiting code images collected by mobile phones. Natural image quality evaluator (NIQE) is used as the image quality evaluation index. Our average NIQE value is decreased by 3.02 and the time cost is optimized by 22.07 s compared to some popular algorithms, including blind image deblurring using patch wise minimal pixels regularization. Furthermore, the details of anti-counterfeiting pattern can be restored well. Conclusion To guarantee certain deblurring effect and time efficiency, our easy-to-use blind-deblurring optimization of anti-counterfeiting code images is demonstrated.

Key words

anti-counterfeiting code; blind deblurring; functional pattern; intensity prior and gradient prior; regularization; image quality evaluation

0 引言

日常生活中2维码的应用越来越广泛。在使用手机、相机等设备拍摄时,由于设备抖动和操作失误导致的对焦不准等原因,拍摄获得的2维码图像往往是模糊的。由于2维码本身具有一定的纠错能力,轻微的模糊退化对于2维码图像的解码并没有非常大的影响。然而,防伪2维码(以下简称为防伪码)不仅需要像普通2维码一样具有正确解码的功能,还有着防伪和溯源要求。防伪码图像模糊可能会在真伪鉴别和产品溯源时造成误判,因此需要对质量未达标的防伪码图像进行去模糊处理。

图像的盲去模糊问题一直是图像处理和计算机视觉领域的热门问题,而模糊图像模糊核的估计则是盲去模糊问题的重点与难点。Cho等人(2011)检测和分析了模糊图像中的阶跃边缘,构造出模糊核不同角度的Radon变换,然后利用逆变换得到图像的模糊核。Goldstein和Fattal(2012)提出直接从模糊图像中得到模糊核近似的功率谱,然后利用改进的相位恢复算法复原图像。Sun等人(2013)预先从500幅自然图像中提取边缘图像块,通过K-Means聚类算法获取具有代表性的样本图像块,称为块先验。然后,在迭代过程中约束潜在清晰图像块与样本块之间的相似性,以此进行模糊核的估计。Hu等人(2014)认为低光照强度图像中的光条纹(light streak)粗略描绘了模糊核的形状,通过功率谱度量检测输入图像中的光条纹来进行模糊核的估计。Whyte等人(2014)针对相机抖动而产生的模糊,提出了先求模糊核再进行非盲去模糊的算法,有效减少了伪影的产生。Mai和Liu(2015)提出将已有的多个盲去模糊算法进行结合,利用算法间的互补性解决单一算法应用于某些场景失效的问题。Yan等人(2017)基于Pan等人(2016)的工作提出了亮通道(bright channel prior)先验的概念,并结合暗通道先验(dark channel prior)得到极致通道先验(extreme channels prior),进一步提升了算法的去模糊效果和鲁棒性。Wen等人(2020)提出逐块最小像素(patch-wise minimal pixels)的概念,并结合最大后验准则进行图像去模糊。

正则化方法在图像盲去模糊问题中占据了重要地位。正则化方法是将对图像的先验知识作为正则化项加入代价函数中,在正则化项的约束下求出使代价函数最小的潜在清晰图像和模糊核。Tikhonov正则化、最大熵方法和图像全变差(total variation,TV)模型等都是经典的正则化方法。近年来,Xu等人(2013)提出以分段函数的L0范数作为图像梯度的正则化项,在保留强稀疏性的同时,避免了在求解模糊核的过程中使用额外的边缘提取操作。Pan等人(2014)针对文本图像的二值特性和稀疏性,提出同时对图像的灰度和梯度施加L0范数正则化,对低光照强度下的自然图像依然有较好的去模糊效果。Jin等人(2018)提出使用L2范数对模糊核进行归一化,解决了传统方法中L1归一化引起的尺度歧义问题。Chen等人(2019)提出基于局部最大梯度先验(local maximum gradient prior)的去模糊算法,对于自然图像、文本图像等多种场景都有着较好的效果。

除了上述通用的图像去模糊算法,很多学者针对2维码图像进行了专门研究。Chu等人(2011)针对运动模糊,提出了在图像倒谱域上估计模糊核的长度和角度,再利用反卷积去模糊的算法。该方法只适用于直线运动轨迹的运动模糊场景,有着较强的局限性。Liu等人(2013)利用2维码图像直方图的二值约束,针对离焦模糊的DataMatrix码进行去模糊,取得了不错效果。Sörös等人(2015)专门针对移动设备,提出了一种快速2维码去模糊算法。van Gennip等人(2015)首先采用全变差模型对QR(quick response)码进行去噪处理,再利用QR码左上角的位置探测图形估计图像的模糊核。该方法去模糊所需时间较短,但是对于不同场景下实际拍摄的模糊QR码图像,去模糊效果并不理想。

随着机器学习的发展,基于神经网络的去模糊方法相继问世。例如,Kupyn等人(2018)基于条件生成对抗网络(conditional generative adversarial network,CGAN)提出的DeblurGAN,吴迪等人(2020)提出的密集连接卷积网络等。本文没有采用机器学习的方法,原因有两点: 一是目前缺少机器学习所需要的数量足够的模糊防伪码图像;二是即使采用了机器学习方法,去模糊后图像的随机防伪图案部分也不能很好地复原,甚至容易造成真伪鉴别时出现误判的情况。

综上所述,现有图像去模糊方法应用于防伪码图像时存在两个问题:1)现有方法大多是针对自然图像和普通2维码图像进行去模糊操作,缺少专门针对防伪码图像的去模糊算法,且现有算法大都没有很好地利用防伪码黑白相间的先验特性;2)现有算法去模糊所需时间较长,难以满足实际需求。针对以上问题,本文提出一种基于图像梯度先验和强度先验、并利用防伪码功能图形的盲去模糊优化算法。

1 相关工作

1.1 防伪码简介

QR码是一种矩阵式2维码,由黑色和白色两种颜色的模块组成,黑色模块代表 2进制的1,白色模块代表 2进制的0。计算机采用不同的编码规则将2进制数据转化为QR码中黑白模块组成的QR码数据编码区。QR码的位置探测图形位于左上、右上和左下3个角,每个位置探测图形由3个重叠的同心正方形组成,外层和内层的正方形为黑色,中间的正方形为白色,3个正方形边长的比例为3 ∶ 5 ∶ 7,这种特殊的结构不仅可以对QR码进行定位,还可以纠正QR码图像的角度,方便识别不同方向拍摄的QR码。QR码的校正图形位于右下角,也可以视做3个重叠的同心正方形,由5 × 5像素的黑色模块、3 × 3像素的白色模块以及位于中心的一个黑色模块组成。QR码的结构图如图 1所示。

图 1 QR码的位置探测图形与校正图形
Fig. 1 Position detection patterns and correction pattern of QR code

本文采用的防伪码是武汉大学电子信息学院图像处理与智能系统实验室设计的防伪码(Guo等,2020),四周的图案结构与普通QR码相同,包含位置探测图形、校正图形、格式信息和版本信息等功能图形。防伪码中间是经过特殊设计的随机防伪图案,起到真伪鉴别和产品溯源的作用(Zheng等,2021),如图 2所示。

图 2 本文所用的防伪码
Fig. 2 Anti-counterfeiting code used in this paper

1.2 图像去模糊模型

图像模糊的数学模型为

$ \boldsymbol{b}=\boldsymbol{k} \otimes \boldsymbol{l}+\boldsymbol{n} $ (1)

式中,${\boldsymbol{b}}$表示模糊图像,${\boldsymbol{k}}$表示模糊核(又称为点扩散函数),$\otimes$表示卷积运算,${\boldsymbol{l}}$表示清晰图像,${\boldsymbol{n}}$表示图像噪声。即模糊退化图像是由清晰图像与模糊核卷积,再加上噪声得到,如图 3所示。

图 3 防伪码图像的退化模型
Fig. 3 Degeneration model of anti-counterfeiting code image

根据模糊核信息是否已知,图像的去模糊问题可以分为两类。模糊核信息未知的去模糊问题称为盲去模糊问题;模糊核信息已知的去模糊问题称为非盲去模糊问题。早期图像去模糊的研究大多是非盲去模糊问题,且只针对特定的模糊类型,如离焦模糊、运动模糊或两者的组合。非盲去模糊算法假设模糊核${\boldsymbol{k}}$已知,通过经典的逆滤波、维纳滤波、卡尔曼滤波和Lucy-Richardson算法进行反卷积,得到去模糊后的清晰图像。然而在实际情况下,图像的模糊情况往往很复杂,难以事先获得模糊核的信息。这类问题就是盲去模糊问题,即需要根据模糊图像${\boldsymbol{b}}$,同时估计模糊核${\boldsymbol{k}}$和清晰图像${\boldsymbol{l}}$

图像的盲去模糊问题是一个典型的病态问题,即使模糊核${\boldsymbol{k}}$的信息完全已知,也并不一定能找到唯一解。因此,正则化方法广泛应用于图像盲去模糊的问题中。正则化去模糊的基本思想是,首先建立图像复原的代价函数;然后利用图像的先验知识,构造相应的正则化约束项,并将其写入代价函数之中;最后,在正则化项的约束下求出使代价函数最小的唯一解,同时得到模糊核${\boldsymbol{k}}$和清晰图像${\boldsymbol{l}}$

2 去模糊算法

目前主流的图像盲去模糊方法应用于防伪码图像时,很难兼顾去模糊效果和算法耗费时间。对此,本文提出一种利用防伪码功能图形梯度与强度先验的盲去模糊优化算法。

2.1 梯度先验与强度先验

定义图像的强度先验为

$ P_t(\boldsymbol{x})=\|\boldsymbol{x}\|_0 $ (2)

即图像$\boldsymbol{x}$中的非0像素值的像素个数。图像在点($i$, $j$)处的水平梯度定义为图像水平方向的差分,即

$ \mathrm{d} x=I(i+1, j)-I(i, j) $ (3)

式中,$I(i, j)$表示图像在点($i, j$)处的像素值。同理,点($i, j$)处的垂直梯度定义为

$ \mathrm{d} y=I(i, j+1)-I(i, j) $ (4)

定义整个图像的先验条件为

$ P(\boldsymbol{x})=\sigma P_t(\boldsymbol{x})+P_t(\nabla \boldsymbol{x}) $ (5)

式中,$σ$表示权重,$\nabla$表示梯度算子,$P_t(\nabla \boldsymbol{x})$表示图像的梯度先验。

清晰的防伪码图像都是由黑白相间的色块组成,其像素的强度值(即灰度值)分布在0和255附近。而模糊防伪码图像,其强度值较为分散,分布在0~255。另外,清晰防伪码图像的梯度分两种情况讨论: 1)黑白色块内部的像素点,其水平梯度和垂直梯度都接近于0;2)黑白色块边缘的像素点,其梯度在255和-255附近。而对于模糊防伪码图像,其梯度值的分布也较为分散。因此,防伪码图像的强度和梯度可以作为正则化方法中的先验条件。清晰防伪码图像和模糊防伪码图像的强度和水平梯度统计如图 4所示。

图 4 防伪码图像的强度和梯度先验特性
Fig. 4 Intensity prior and gradient prior of anti-counterfeiting code images
((a) clear anti-counterfeiting code image; (b) blurred anti-counterfeiting code image; (c) intensity histogram of (a); (d) intensity histogram of (b); (e) horizontal gradient histogram of (a); (f) horizontal gradient histogram of (b))

2.2 L0正则化去模糊

在讨论了防伪码图像的强度先验和梯度先验后,利用正则化方法去模糊。定义代价函数为

$ \min\limits _{\boldsymbol{l}, \boldsymbol{k}}\|\boldsymbol{l} \otimes \boldsymbol{k}-\boldsymbol{b}\|_2^2+\gamma\|\boldsymbol{k}\|_2^2+\lambda P(\boldsymbol{l}) $ (6)

式中,${\boldsymbol{l}}$${\boldsymbol{b}}$分别代表清晰图像和模糊图像,$\otimes$表示卷积运算,${\boldsymbol{k}}$是图像的模糊核,$\|\boldsymbol{k}\|_2^2$表示L$_\text{2}$正则化项,$γ$$λ$表示权重。盲去模糊算法的目的是,通过找到某个${\boldsymbol{k}}$${\boldsymbol{l}}$,使式(6)取得最小值。

考虑到式(6)无法直接求最小值,将式(6)分成两个子问题,即

$ \min\limits _{\boldsymbol{l}}\|\boldsymbol{l} \otimes \boldsymbol{k}-\boldsymbol{b}\|_2^2+\lambda P(\boldsymbol{l}) $ (7)

$ \min\limits _{\boldsymbol{k}}\|\boldsymbol{l} \otimes \boldsymbol{k}-\boldsymbol{b}\|_2^2+\gamma\|\boldsymbol{k}\|_2^2 $ (8)

对于式(7),引入辅助变量$\boldsymbol{u}$$\boldsymbol{g}=\left(\boldsymbol{g}_{\mathrm{h}}, \boldsymbol{g}_{\mathrm{v}}\right)^{\mathrm{T}}$分别与$P(\boldsymbol{l})$中的$\boldsymbol{l}$$\nabla \boldsymbol{l}$相对应,将式(7)重写为

$ \begin{gathered} \min\limits _{\boldsymbol{l}, \boldsymbol{u}, \boldsymbol{g}}\|\boldsymbol{l} \otimes \boldsymbol{k}-\boldsymbol{b}\|_2^2+\beta\|\boldsymbol{l}-\boldsymbol{u}\|_2^2+\mu\|\nabla \boldsymbol{l}-\boldsymbol{g}\|_2^2+ \\ \lambda\left(\sigma\|\boldsymbol{u}\|_0+\|\boldsymbol{g}\|_0\right) \end{gathered} $ (9)

式中,$β$$μ$是正则化参数,当$β$$μ$的值趋于正无穷时,式(9)的解可以近似看做式(7)的解。在式(9)中,可以固定${\boldsymbol{l}}$${\boldsymbol{g}}$${\boldsymbol{u}}$中的任意两个变量来求解另一个变量。根据Pan等人(2014)的研究可知,${\boldsymbol{l}}$的最小二乘近似解为

$ \boldsymbol{l}=\mathcal{F}^{-1}\left(\frac{\overline{\mathcal{F}(\boldsymbol{k})} \mathcal{F}(\boldsymbol{b})+\beta \mathcal{F}(\boldsymbol{u})+\mu \boldsymbol{F}_G}{\overline{\mathcal{F}(\boldsymbol{k})} \mathcal{F}(\boldsymbol{k})+\beta+\mu \overline{\mathcal{F}(\nabla)} \mathcal{F}(\nabla)}\right) $ (10)

式中,${\mathcal F}\left(\cdot \right)$${{\mathcal F}^{ - 1}}\left(\cdot \right)$分别表示傅里叶变换和傅里叶反变换,$\overline{\mathcal{F}(\cdot)}$表示共轭复数运算,${{\mathit{\boldsymbol{F}}_G}}\overline{\mathcal{F}\left(\nabla_{\mathrm{h}}\right)} \mathcal{F}\left(\boldsymbol{g}_{\mathrm{h}}\right)+\overline{\mathcal{F}\left(\nabla_{\mathrm{v}}\right)} \mathcal{F}\left(\boldsymbol{g}_{\mathrm{v}}\right)$,其中,$\nabla_{\mathrm{h}}$$\nabla_{\mathrm{v}}$分别表示水平方向和垂直方向的微分运算。

在给定${\boldsymbol{l}}$的情况下,根据Xu等人(2011)的算法,${\boldsymbol{u}}$${\boldsymbol{g}}$的计算式为

$ \min \limits_{\boldsymbol{u}} \beta\|\boldsymbol{l}-\boldsymbol{u}\|_2^2+\lambda {\sigma}\|\boldsymbol{u}\|_2^2 $ (11)

$ \min \limits_{\boldsymbol{g}} \mu\|\nabla \boldsymbol{l}-\boldsymbol{g}\|_2^2+\lambda\|\boldsymbol{g}\|_2^2 $ (12)

式(11)的解为

$ \boldsymbol{u}= \begin{cases}\boldsymbol{l} & |\boldsymbol{l}|^2 \geqslant \frac{\lambda \sigma}{\beta} \\ 0 & \text { 其他 }\end{cases} $ (13)

式(12)的解为

$ \boldsymbol{g}= \begin{cases}\nabla \boldsymbol{l} & |\nabla \boldsymbol{l}|^2 \geqslant \frac{\lambda}{\mu} \\ 0 & \text { 其他 }\end{cases} $ (14)

求出清晰图像${\boldsymbol{l}}$后,利用式(6)计算模糊核${\boldsymbol{k}}$Cho等人(2012)发现,直接利用式(8)计算出的结果并不准确,于是改用梯度域来估计模糊核,具体为

$ \min\limits _{\boldsymbol{k}}\|\nabla \boldsymbol{l} \otimes \boldsymbol{k}-\nabla \boldsymbol{b}\|_2^2+\gamma\|\boldsymbol{k}\|_2^2 $ (15)

式(15)的解可以由快速傅里叶变换(fast Fourier transform,FFT)算出。

由模糊图像${\boldsymbol{b}}$估计清晰图像${\boldsymbol{l}}$和模糊核${\boldsymbol{k}}$的算法过程为:首先输入模糊图像${\boldsymbol{b}}$,用式(13)计算${\boldsymbol{u}}$,用式(14)计算${\boldsymbol{g}}$,然后利用式(10)求出清晰图像${\boldsymbol{l}}$,最后由式(15)得到模糊核${\boldsymbol{k}}$

2.3 算法优化

理论上,由2.2节所述的算法可以得到清晰图像${\boldsymbol{l}}$和模糊核${\boldsymbol{k}}$,但实际很难达到预期效果。原因有:1)算法消耗时间较长,经测试,一幅512×512像素的模糊防伪码图像,去模糊时间为90 s,很难满足实际需求;2)2.2节的算法对整幅防伪码图像求取模糊核,实际是默认了防伪码图像的模糊是均匀模糊,即图像各处的模糊核是相同的,但是实际情况下,手机等设备拍摄的模糊图像并不一定是均匀模糊,图像各处的模糊核可能并不相同;3)本文实验用的防伪码并不是标准的2维码,中间随机防伪码图案部分的先验条件与周围标准QR码部分的先验条件并不完全相同,这对于模糊核的准确估计有较大影响。

针对以上问题,本文在2.2节的基础上对防伪码图像去模糊算法进行改进和优化。考虑到对于防伪码图像,无论其他部分的图案如何变化,其左上、右上、左下的位置探测图形以及靠近右下角的校正图形都是不变的,且位置探测图形与校正图形黑白相间层次分明,非常契合前文所述的梯度先验与强度先验。

改进后的算法步骤如下:1)将防伪码图像以横纵两条中线为界,分为大小相同的4块,分别提取左上、右上、左下的位置探测图形和靠近右下角的校正图形;2)利用2.2节所述的去模糊算法求得3个位置探测图形和1个校正图形的模糊核;3)用这4个功能图形的模糊核替代对应分块的模糊核,将这4个模糊核分别作用于防伪码图像对应的分块,利用反卷积进行去模糊。分割后的防伪码图像与提取的位置探测图形和校正图形如图 5所示。

图 5 分割后的防伪码图像与提取的功能图形
Fig. 5 Segmented anti-counterfeiting code images and extracted functional patterns
((a) segmented anti-counterfeiting code images; (b) position detection patterns and correction pattern)

改进后的算法优点如下:1)由于该算法只需要求位置探测图形和校正图形的模糊核,而正则化方法求解模糊核的算法耗时是尺度敏感的,相比对整幅图像求取模糊核,改进后算法的去模糊效率大幅提升;2)将图像分为4块,分别计算4个分块对应功能图形的模糊核,相比对整幅图像求取模糊核,考虑到非均匀模糊的情况,对于手机拍摄的模糊图像,理论上去模糊效果更好;3)防伪码的位置探测图形和校正图形是黑白相间的色块,非常契合梯度先验与强度先验,同时又避免了图像中间随机防伪图案对于模糊核估计的影响。

3 实验与结果分析

由于没有公开的模糊防伪码图像数据集,实验选用实验室制作的模糊防伪码图像数据集对算法效果进行测试。测试环境为Intel Core i7-7700K(无独立显卡)、8 GB内存和MATLAB 2021a。

在实际情况下,手机等设备拍摄防伪码图像产生的模糊类型主要有设备抖动产生的运动模糊、设备对焦不准产生的离焦模糊以及两者的组合。因此在实验中人为添加的模糊类型均为离焦模糊、运动模糊以及二者的组合。

3.1 电子版防伪码模糊图像测试

选取50幅清晰的236 × 236像素的电子版防伪码图像,使用Photoshop添加不同程度的离焦模糊、运动模糊和两种模糊的组合,再用本文算法与Pan等人(2014)Yan等人(2017)Wen等人(2020)的算法进行比较。实验结果如图 6所示。

图 6 电子版模糊防伪码图像去模糊结果
Fig. 6 Deblurring results of electronic blurred anti- counterfeiting code images
((a) clear images; (b) blurred images; (c) Pan et al. (2014); (d) Yan et al. (2017); (e) Wen et al. (2020); (f) ours)

图 6所示的模糊防伪码图像既有离焦模糊也有运动模糊。从结果来看,在模糊程度较小时,3种对比方法与本文算法均能够较好地复原图像四周的标准QR部分和中间的防伪码部分。当模糊程度较大时,4种方法的去模糊效果都不是很好。四周的标准QR码部分或多或少出现了伪影,中间的防伪码部分则几乎完全无法复原。这是因为实验选用的防伪码图像尺寸较小,模糊程度较大时,像素点之间相互重叠,信息丢失过多,难以做到完全复原。

由于每一幅模糊防伪码图像都有一个与之对应的清晰防伪码图像,因此采用全参考图像质量标准评价算法的去模糊效果。为评价各算法的性能,选用峰值信噪比(peak signal to noise ratio, PSNR)和结构相似度(structural similarity, SSIM)作为去模糊后图像质量的评价标准。表 1记录了4种方法去模糊后图像的PSNR、SSIM和算法所用时间。从表 1可以看出,对于人为添加模糊的电子版防伪码图像,本文算法和3种对比方法在PSNR和SSIM这两个客观指标上大体相当。在算法耗时上,本文算法的平均耗时为4.47 s,相比其他算法超过11 s的平均耗时,有较大提升。

表 1 电子版模糊防伪码图像去模糊结果定量比较
Table 1 Quantitative comparison of deblurring results of electronic blurred anti-counterfeiting code images

下载CSV
算法 PSNR/dB SSIM 算法耗时/s
Pan等人(2014) 13.47 0.600 1 11.75
Yan等人(2017) 13.44 0.601 0 11.83
Wen等人(2020) 13.29 0.602 9 11.01
本文 13.65 0.601 3 4.47
注:加粗字体表示各列最优结果。

3.2 人为添加模糊的防伪码图像测试

使用Huawei Mate40 Pro和Redmi K30 Pro手机拍摄50幅清晰的防伪码图像,用双线性插值方法将图像尺寸统一为512 × 512像素并将其灰度化。然后,使用Photoshop添加不同程度的离焦模糊、运动模糊和两种模糊的组合,再用本文算法与其他3种方法进行比较。实验结果如图 7所示。

图 7 人为添加模糊防伪码图像去模糊结果
Fig. 7 Deblurring results of artificially blurred anti-counterfeiting code images
((a) clear images; (b) blurred images; (c) Pan et al. (2014); (d) Yan et al. (2017); (e) Wen et al. (2020); (f) ours)

同样,由于每一幅模糊防伪码图像都有一个与之对应的清晰防伪码图像,选用PSNR、SSIM和算法消耗时间作为评价算法性能的指标。本文算法与其他3种对比方法的定量对比结果如表 2所示。

表 2 人为添加模糊的防伪码去模糊结果定量比较
Table 2 Quantitative comparison of deblurring results of artificially blurred anti-counterfeiting code images

下载CSV
算法 PSNR/dB SSIM 算法耗时/s
Pan等人(2014) 19.79 0.656 3 81.75
Yan等人(2017) 18.38 0.581 8 98.97
Wen等人(2020) 20.14 0.634 1 31.66
本文 21.26 0.728 7 11.74
注:加粗字体表示各列最优结果。

图 7表 2可以看出,4种算法对于防伪码四周的QR码图像依旧有着较好的去模糊效果,但是Pan等人(2014)算法和Wen等人(2020)算法对于图像中间的防伪图案部分的复原效果不好,图案细节丢失较为严重。Yan等人(2017)算法和本文算法对于防伪图案部分的细节有着较好的保留。在客观指标方面,本文算法的PSNR和SSIM略高于其他3种算法,算法平均耗时为11.74 s。可见,本文方法在保证一定去模糊效果的前提下,算法效率有明显提升。

3.3 手机拍摄的模糊防伪码图像测试

为了进一步检验本文算法的特性,使用Huawei Mate40 Pro和Redmi K30 Pro手机拍摄50幅模糊防伪码图像,用双线性插值方法将尺寸统一为512 × 512像素,再将其灰度化。由于手机拍摄得到的防伪码图像会不可避免地出现形变,如果采用全参考的PSNR和SSIM作为去模糊效果评价标准,容易造成主客观不统一的情况,难以反映真实的去模糊效果。因此,选用自然图像质量评价器(natural image quality evaluator, NIQE)作为评价标准。NIQE是一种无参考的图像质量评价指标,不需要清晰原图即可评价模糊图像的质量,NIQE的值越小,表明图像越清晰,越符合人眼的主观感受。

4种算法的去模糊效果如图 8所示。表 3定量记录了本文算法和3种对比算法的NIQE值和算法平均耗时。

图 8 手机拍摄的模糊防伪码图像去模糊结果
Fig. 8 Deblurring results of blurred anti-counterfeiting code images taken by mobile phone
((a) blurred images; (b) Pan et al. (2014); (c) Yan et al. (2017); (d) Wen et al. (2020); (e) ours)

表 3 手机拍摄的模糊防伪码去模糊结果的定量比较
Table 3 Quantitative comparison of deblurring results of blurred anti-counterfeiting code taken by mobile phone

下载CSV
算法 NIQE 算法耗时/s
Pan等人(2014) 12.35 81.70
Yan等人(2017) 10.88 95.19
Wen等人(2020) 9.88 31.77
本文 6.86 9.70
注:加粗字体表示各列最优结果。

手机拍摄的模糊防伪码图像,模糊情况比人为添加的模糊复杂很多,除去离焦模糊、运动模糊之外,还可能有其他类型的模糊,且有可能出现非均匀模糊的情况。

图 8表 3可以看出,Pan等人(2014)算法去模糊后的图像有较强的伪影,算法耗时较长;Yan等人(2017)算法在中间随机防伪码图案部分产生了亮斑与暗斑,算法消耗时间最长;Wen等人(2020)算法有着较短的耗时和较好的去模糊效果,但对于第3幅较为严重的离焦模糊,中间防伪图案部分的细节几乎全部丢失。本文算法没有产生严重的伪影,中间防伪图案部分有一定的细节保留,有较为明显的去模糊效果,且相比于其他3种算法,算法耗时大幅降低。

对于手机实际拍摄的图像,本文算法在去模糊效果上略有优势,在算法时间效率上有显著提升。究其原因有以下两点:1)实际的模糊图像并不一定是均匀模糊,其他3种算法对整幅图像求取模糊核,默认了图像各处的模糊核是相同的,而本文算法将图像分为4块,分别计算各自的模糊核,考虑到了非均匀模糊的情况;2)4种算法消耗的时间主要用于模糊核的估计上,而对于正则化去模糊方法,图像尺寸越大,模糊核估计所用的时间就越长。其他3种算法都是对整幅图进行模糊核估计,而本文算法只对位置探测图形和校正图形进行模糊核估计,因此节约了大量时间。

4 结论

针对现阶段盲去模糊算法用于防伪码图像时普遍存在的去模糊效果不好以及算法耗时较长的问题,本文提出了一种基于防伪码图像梯度先验与强度先验并结合功能图形的盲去模糊优化算法。该算法考虑了防伪码本身黑白相间的特性,充分利用了防伪码特有的位置探测图形和校正图形进行去模糊。实验结果表明,本文方法在去模糊效果上略优于对比算法,在去模糊效率上有明显提升。

但是,本文方法尚有不足之处。1)复原防伪码图像的目的并非只是简单地去模糊,而是要尽可能还原防伪图案的细节,提高去模糊后的防伪码图像在真伪鉴别中的准确率。在这一点上本文算法还有待进一步检验和优化。2)相对于运动模糊,本文算法对于离焦模糊的去模糊效果更差。这是因为离焦模糊使防伪码的黑色色块向四周均匀散开,本文算法用到的梯度先验很容易将这种情况误判为原图是有一定梯度的渐变图像。此外,防伪码中间的防伪图案部分,在离焦模糊的作用下非常容易导致黑色色块之间的相互重叠,这对于去模糊是非常不利的。3)实验验证了本文算法对于离焦模糊以及运动模糊的去模糊效果和效率,但是对于其他类型模糊以及更加复杂情况下的去模糊效果还需要更进一步检验。今后的研究工作将围绕以上各方面展开。

参考文献

  • Chen L, Fang F M, Wang T T and Zhang G X. 2019. Blind image deblurring with local maximum gradient prior//Proceedings of 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Long Beach, USA: IEEE: 1742-1750 [DOI: 10.1109/CVPR.2019.00184]
  • Cho T S, Paris S, Horn B and Freeman W T. 2011. Blur kernel estimation using the radon transform//Proceedings of 2011 IEEE Conference on Computer Vision and Pattern Recognition. Colorado Springs, USA: IEEE: 241-248 [DOI: 10.1109/CVPR.2011.5995479]
  • Cho H, Wang J and Lee S. 2012. Text image deblurring using text-specific properties//Proceedings of the 12th European Conference on Computer Vision. Florence, Italy: Springer: 524-537 [DOI: 10.1007/978-3-642-33715-4_38]
  • Chu C H, Yang D N, Pan Y L, Chen M S. 2011. Stabilization and extraction of 2D barcodes for camera phones. Multimedia Systems, 17(2): 113-133 [DOI:10.1007/s00530-010-0206-9]
  • Goldstein A and Fattal R. 2012. Blur-kernel estimation from spectral irregularities//Proceedings of the 12th European Conference on Computer Vision. Berlin, Heidelberg, Germany: Springer-Verlag: 622-635 [DOI: 10.1007/978-3-642-33715-4_45]
  • Guo Z Y, Zheng H, You C H, Xu X H, Wu X B, Zheng Z H, Ju J P. 2020. Digital forensics of scanned QR code images for printer source identification using bottleneck residual block. Sensors, 20(21): #6305 [DOI:10.3390/S20216305]
  • Hu Z, Cho S, Wang J and Yang M H. 2014. Deblurring low-light images with light streaks//Proceedings of 2014 IEEE Conference on Computer Vision and Pattern Recognition, Columbus, USA: IEEE: 3382-3389 [DOI: 10.1109/CVPR.2014.432]
  • Jin M G, Roth S and Favaro P. 2018. Normalized blind deconvolution//Proceedings of the 15th European Conference on Computer Vision. Munich, Germany: Springer: 694-711 [DOI: 10.1007/978-3-030-01234-2_41]
  • Kupyn O, Budzan V, Mykhailych M, Mishkin D and Matas J. 2018. DeblurGAN: blind motion deblurring using conditional adversarial networks//Proceedings of 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Salt Lake City, USA: IEEE: 8183-8192 [DOI: 10.1109/CVPR.2018.00854]
  • Liu N, Zheng X, Sun H, Tan X. 2013. Two-dimensional bar code out-of-focus deblurring via the increment constrained least squares filter. Pattern Reognition Letters, 34(2): 124-130 [DOI:10.1016/J.PATREC.2012.09.006]
  • Mai L and Liu F. 2015. Kernel fusion for better image deblurring//Proceedings of 2015 IEEE Conference on Computer Vision and Pattern Recognition. Boston, USA: IEEE: 371-380 [DOI: 10.1109/CVPR.2015.7298634]
  • Pan J S, Hu Z, Su Z X and Yang M H. 2014. Deblurring text images via L0-regularized intensity and gradient prior//Proceedings of 2014 IEEE Conference on Computer Vision and Pattern Recognition. Columbus, USA: IEEE: 2901-2908 [DOI: 10.1109/CVPR.2014.371]
  • Pan J S, Sun D Q, Pfister H and Yang M H. 2016. Blind image deblurring using dark channel prior//Proceedings of 2016 IEEE Conference on Computer Vision and Pattern Recognition. Las Vegas, USA: IEEE: 1628-1636 [DOI: 10.1109/CVPR.2016.180]
  • Sörös G, Semmler S, Humair L and Hilliges O. 2015. Fast blur removal for wearable QR code scanners//Proceedings of 2015 ACM International Symposium on Wearable Computers. Osaka, Japan: Association for Computing Machinery: 117-124 [DOI: 10.1145/2802083.2808390]
  • Sun L B, Cho S, Wang J and Hays J. 2013. Edge-based blur kernel estimation using patch priors//Proceedings of 2013 IEEE International Conference on Computational Photography. Cambridge, USA: IEEE: 1-8 [DOI: 10.1109/ICCPhot.2013.6528301]
  • van Gennip Y, Athavale P, Gilles J, Choksi R. 2015. A regularization approach to blind deblurring and denoising of QR barcodes. IEEE Transactions on Image Processing, 24(9): 2864-2873 [DOI:10.1109/TIP.2015.2432675]
  • Wen F, Ying R D, Liu Y P, Liu P L, Truong T K. 2020. A simple local minimal intensity prior and an improved algorithm for blind image deblurring. IEEE Transactions on Circuits and Systems for Video Technology, 31(8): 2923-2937 [DOI:10.1109/TCSVT.2020.3034137]
  • Whyte O, Sivic J, Zisserman A. 2014. Deblurring shaken and partially saturated images. International Journal of Computer Vision, 110(2): 185-201 [DOI:10.1007/s11263-014-0727-3]
  • Wu D, Zhao H T, Zheng S B. 2020. Motion deblurring method based on DenseNets. Journal of Image and Graphics, 25(5): 890-899 (吴迪, 赵洪田, 郑世宝. 2020. 密集连接卷积网络图像去模糊. 中国图象图形学报, 25(5): 890-899) [DOI:10.11834/jig.190400]
  • Xu L, Lu C W, Xu Y and Jia J Y. 2011. Image smoothing via L0 gradient minimization//Proceedings of 2011 SIGGRAPH Asia Conference. Hong Kong, China: Association for Computing Machinery: #174 [DOI: 10.1145/2024156.2024208]
  • Xu L, Zheng S C and Jia J Y. 2013. Unnatural l0 sparse representation for natural image deblurring//Proceedings of 2013 IEEE Conference on Computer Vision and Pattern Recognition. Portland, USA: IEEE: 1107-1114 [DOI: 10.1109/CVPR.2013.147]
  • Yan Y Y, Ren W Q, Guo Y F, Wang R and Cao X C. 2017. Image deblurring via extreme channels prior//Proceedings of 2017 IEEE Conference on Computer Vision and Pattern Recognition. Honolulu, USA: IEEE: 6978-6986 [DOI: 10.1109/CVPR.2017.738]
  • Zheng Z H, Zheng H, Ju J P, Chen D, Li X, Guo Z Y, You C H, Lin M Y. 2021. A system for identifying an anti-counterfeiting pattern based on the statistical difference in key image regions. Expert Systems with Applications, 183: #115410 [DOI:10.1016/j.eswa.2021.115410]