CN115578289A - Defocused image deblurring method based on boundary neighborhood gradient difference - Google Patents

Defocused image deblurring method based on boundary neighborhood gradient difference Download PDF

Info

Publication number
CN115578289A
CN115578289A CN202211345557.XA CN202211345557A CN115578289A CN 115578289 A CN115578289 A CN 115578289A CN 202211345557 A CN202211345557 A CN 202211345557A CN 115578289 A CN115578289 A CN 115578289A
Authority
CN
China
Prior art keywords
fuzzy
image
boundary
deblurring
blur
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211345557.XA
Other languages
Chinese (zh)
Inventor
王映辉
陶俊杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangnan University
Original Assignee
Jiangnan University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangnan University filed Critical Jiangnan University
Priority to CN202211345557.XA priority Critical patent/CN115578289A/en
Publication of CN115578289A publication Critical patent/CN115578289A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/73Deblurring; Sharpening

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)

Abstract

本发明公开了一种基于边界邻域梯度差值的散焦图像去模糊方法,属于计算机视觉的学科技术领域。针对现有散焦图像去模糊方法对于多深度层的静态场景无法准确获得散焦图像边界位置的模糊量,本发明充分利用边界邻域梯度差值和模糊量的关系,来准确获得散焦图像边界位置的模糊量,从而解决去模糊结果中出现边界振铃伪影的问题;针对非盲反卷积算法保留图像细节信息的能力不会够强导致去模糊结果中出现细节信息丢失的问题,本发明结合离散模糊量选择策略和稀疏先验设计了一种非盲发卷积算法来加强非盲反卷积算法保留图像细节信息的能力,解决了去模糊结果中出现细节信息丢失的问题,可用于多深度层静态场景下的散焦图像去模糊处理。

Figure 202211345557

The invention discloses a method for deblurring a defocused image based on a boundary neighborhood gradient difference, and belongs to the technical field of computer vision. In view of the fact that the existing defocused image deblurring method cannot accurately obtain the blur amount of the boundary position of the defocused image for static scenes with multiple depth layers, the present invention makes full use of the relationship between the boundary neighborhood gradient difference and the blur amount to accurately obtain the defocused image The amount of blurring at the boundary position, so as to solve the problem of boundary ringing artifacts in the deblurring result; the ability of the non-blind deconvolution algorithm to retain image detail information is not strong enough to cause the loss of detail information in the deblurring result. The present invention designs a non-blind convolution algorithm by combining the discrete fuzzy amount selection strategy and sparse prior to strengthen the ability of the non-blind deconvolution algorithm to retain image detail information, and solves the problem of loss of detail information in the deblurring results. It can be used for deblurring of defocused images in static scenes with multiple depth layers.

Figure 202211345557

Description

一种基于边界邻域梯度差值的散焦图像去模糊方法A Defocused Image Deblurring Method Based on Boundary Neighborhood Gradient Difference

技术领域technical field

本发明涉及一种基于边界邻域梯度差值的散焦图像去模糊方法,属于计算机视觉领域。The invention relates to a method for deblurring a defocused image based on a boundary neighborhood gradient difference, and belongs to the field of computer vision.

背景技术Background technique

在现实生活中散焦图像随处可见,所谓的散焦就是图像变得不清晰模糊了,而图像模糊了会使人看不清图中的物体并且丢失了细节信息,这限制了图像在精密仪器探伤检测和增强现实等领域的进一步应用。In real life, defocused images can be seen everywhere. The so-called defocus means that the image becomes unclear and blurred, and the blurred image will make people unable to see the objects in the picture and lose detailed information, which limits the accuracy of the image in precision instruments. Further applications in areas such as flaw detection and augmented reality.

为了提高散焦图像的使用效率,需要去除散焦图像中的散焦来使图像变清晰。现有的传统散焦图像去模糊方法通过对像素点的模糊程度进行估计得到模糊量,然后使用高斯函数表示的点扩散函数以及模糊量来计算模糊核。最终将模糊核和散焦图像输入到非盲反卷积算法中执行去模糊操作。In order to improve the efficiency of using the defocused image, it is necessary to remove the defocus in the defocused image to sharpen the image. The existing traditional defocused image deblurring method obtains the blur amount by estimating the blur degree of the pixel, and then uses the point spread function represented by the Gaussian function and the blur amount to calculate the blur kernel. Finally, the blur kernel and the defocused image are input into the non-blind deconvolution algorithm to perform the deblurring operation.

对于多深度层的静态场景,现有的散焦图像去模糊方法无法准确的获得散焦图像边界处的模糊量,模糊量表示的是像素点的模糊程度。边界处散焦模糊量估计不准确,会导致去模糊结果中出现边界振铃伪影,边界振铃伪影指的是灰度剧烈变化处产生的震荡。此外,散焦图像去模糊方法中的非盲反卷积算法的先验知识不够强,先验知识是指图像中的一些已知的特征和特性,利用它能够约束非盲反卷积算法使得去模糊结果能不断逼近真实的清晰图像,先验知识缺失会导致非盲反卷积算法对图像细节信息恢复的能力不够强,在最终的去模糊结果中出现细节信息丢失的问题。For static scenes with multiple depth layers, existing defocused image deblurring methods cannot accurately obtain the amount of blur at the boundary of the defocused image, and the amount of blur represents the degree of blurring of pixels. Inaccurate estimation of the amount of defocus blur at the boundary will lead to boundary ringing artifacts in the deblurring results. Boundary ringing artifacts refer to oscillations at places where the gray level changes sharply. In addition, the prior knowledge of the non-blind deconvolution algorithm in the defocused image deblurring method is not strong enough. The prior knowledge refers to some known features and characteristics in the image, which can be used to constrain the non-blind deconvolution algorithm so that The deblurring result can continuously approach the real clear image. The lack of prior knowledge will lead to the non-blind deconvolution algorithm's ability to recover image detail information is not strong enough, and the problem of detail information loss will appear in the final deblurring result.

总之,边界振铃伪影的存在和先验知识的缺乏都会影响散焦图像的去模糊过程,最终导致去模糊的效果不佳,图像清晰度不够。In conclusion, both the existence of boundary ringing artifacts and the lack of prior knowledge will affect the deblurring process of defocused images, and finally lead to poor deblurring effect and insufficient image clarity.

发明内容Contents of the invention

为了解决目前的散焦图像去模糊方法在面对多深度层的静态场景下,存在的去模糊效果不佳、图像清晰度不够的问题,本发明提供了一种散焦图像去模糊方法,所述散焦图像去模糊方法包括:In order to solve the problems of poor deblurring effect and insufficient image definition in the current defocused image deblurring method in the face of static scenes with multiple depth layers, the present invention provides a defocused image deblurring method. The defocused image deblurring method includes:

步骤1:对所述散焦图像求取边界,在边界位置处求得边界邻域的梯度差值;Step 1: Obtain the boundary of the defocused image, and obtain the gradient difference of the boundary neighborhood at the boundary position;

步骤2:利用所述步骤1求得的所述边界邻域的梯度差值,求得边界位置处的模糊量,从而得到稀疏模糊图;Step 2: using the gradient difference value of the boundary neighborhood obtained in the step 1 to obtain the blur amount at the boundary position, thereby obtaining a sparse fuzzy map;

步骤3:对所述步骤2得到的所述稀疏模糊图进行插值得到插值模糊图;Step 3: Interpolating the sparse fuzzy map obtained in step 2 to obtain an interpolated fuzzy map;

步骤4:利用所述步骤3得到的所述插值模糊图对所述散焦图像进行模糊检测并计算模糊比,当所述模糊比大于预设的模糊比阈值时,对所述散焦图像进行去模糊;Step 4: Use the interpolation blur map obtained in step 3 to perform blur detection on the defocused image and calculate a blur ratio, and when the blur ratio is greater than a preset blur ratio threshold, perform blur detection on the defocused image deblurring;

步骤5:对于所述步骤4中需要去模糊的图像,使用所述步骤3中的所述插值模糊图来获得模糊核,再结合非盲反卷积算法执行去模糊操作。Step 5: For the image that needs to be deblurred in step 4, use the interpolation blur map in step 3 to obtain a blur kernel, and then perform a deblurring operation in combination with a non-blind deconvolution algorithm.

可选的,所述步骤1包括:Optionally, the step 1 includes:

使用尺度一致边界检测算法求取所述散焦图像的边界,得到边界位置后在原图中求以每个边界位置为中心的邻域中的梯度,再将邻域中的最大梯度和最小梯度做差值得到边界位置处的梯度差值。Use the scale-consistent boundary detection algorithm to obtain the boundary of the defocused image, and after obtaining the boundary position, calculate the gradient in the neighborhood centered on each boundary position in the original image, and then calculate the maximum gradient and minimum gradient in the neighborhood Difference gets the gradient difference at the boundary position.

可选的,所述步骤2包括:Optionally, the step 2 includes:

步骤2.1:获取边界邻域梯度差值和模糊量之间的关系式:Step 2.1: Obtain the relationship between the gradient difference of the boundary neighborhood and the blur amount:

对图像的散焦过程建模,如式(1)所示:Model the defocusing process of the image, as shown in formula (1):

Figure BDA0003917084050000021
Figure BDA0003917084050000021

其中,I表示所述散焦图像,k表示模糊核,x表示清晰图像,n表示噪声,

Figure BDA0003917084050000022
表示卷积操作,所述模糊核对所述清晰图像做卷积操作再加上所述噪声就会得到所述散焦图像;Wherein, I represents the defocused image, k represents the blur kernel, x represents the clear image, n represents the noise,
Figure BDA0003917084050000022
Represents a convolution operation, the blur kernel performs a convolution operation on the clear image and adds the noise to obtain the defocused image;

所述模糊核由点扩散函数和模糊量获得,所述点扩散函数由高斯函数表示,如式(2)所示:The blur kernel is obtained by a point spread function and a blur quantity, and the point spread function is represented by a Gaussian function, as shown in formula (2):

Figure BDA0003917084050000023
Figure BDA0003917084050000023

其中,σ表示模糊量,模糊量表示的是像素的模糊程度,(x,y)表示像素坐标;Among them, σ represents the amount of blur, the amount of blur represents the degree of blur of the pixel, and (x, y) represents the coordinates of the pixel;

所述清晰图像的边界l(x,y)建模为式(3)所示:The boundary l(x, y) of the clear image is modeled as shown in formula (3):

l(x,y)=a*u(x,y)+b (3)其中,a是振幅,b是偏移量,u(x,y)是阶跃函数;l(x,y)=a*u(x,y)+b (3) where a is the amplitude, b is the offset, u(x,y) is the step function;

定义所述边界邻域梯度差值如式(4)所示:Define the boundary neighborhood gradient difference as shown in formula (4):

Figure BDA0003917084050000024
Figure BDA0003917084050000024

其中,GD(x,y)是所述边界邻域梯度差值,(x,y)′表示以(x,y)为中心的邻域,J(x,y)表示所述散焦图像边界,

Figure BDA0003917084050000025
表示边界邻域中的梯度,也就是对边界求导,求导结果如式(5)所示:Among them, GD(x, y) is the gradient difference value of the boundary neighborhood, (x, y)' represents the neighborhood centered on (x, y), and J(x, y) represents the boundary of the defocused image ,
Figure BDA0003917084050000025
Represents the gradient in the boundary neighborhood, that is, deriving the boundary, and the derivation result is shown in formula (5):

Figure BDA0003917084050000026
Figure BDA0003917084050000026

边界位置在(x,y)=(0,0),因此边界邻域梯度差值如式(6)所示:The boundary position is at (x,y)=(0,0), so the gradient difference of the boundary neighborhood is shown in formula (6):

Figure BDA0003917084050000027
Figure BDA0003917084050000027

根据式(6)推导出所述边界邻域梯度差值和所述模糊量的关系,如式(7)所示:According to formula (6), the relationship between the boundary neighborhood gradient difference and the fuzzy amount is derived, as shown in formula (7):

Figure BDA0003917084050000031
Figure BDA0003917084050000031

步骤2.2:根据所述边界邻域梯度差值和所述模糊量的关系式以及所述步骤1获得的边界邻域梯度差值,求得边界处的模糊量,从而得到稀疏模糊图。Step 2.2: Obtain the blur amount at the boundary according to the relationship between the boundary neighborhood gradient difference and the blur amount and the boundary neighborhood gradient difference obtained in step 1, thereby obtaining a sparse fuzzy map.

可选的,所述步骤4中计算模糊比的过程包括:Optionally, the process of calculating the blur ratio in the step 4 includes:

设定模糊量阈值,判断所述插值模糊图中的每个像素点的模糊量是否大于所述模糊量阈值,当像素点的模糊量大于该阈值时,该像素点被设定为模糊的,否则是非模糊的;Setting a threshold of blur amount, judging whether the blur amount of each pixel in the interpolation blur map is greater than the threshold of blur amount, when the blur amount of a pixel is greater than the threshold, the pixel is set as blurred, Otherwise it is non-ambiguous;

根据判段结果将所述插值模糊图划分为模糊区域和非模糊区域,计算所述模糊区域像素数占整张图像的像素数的比例,即模糊比。Divide the interpolation fuzzy image into fuzzy areas and non-fuzzy areas according to the judgment results, and calculate the ratio of the number of pixels in the fuzzy area to the number of pixels in the entire image, that is, the blur ratio.

可选的,所述步骤5包括:Optionally, the step 5 includes:

步骤5.1:对步骤3中获得的所述插值模糊图进行离散模糊量选择,以步进q得到n个模糊量σ1、σ2…σn;使用这n个模糊量利用点扩散函数得到n个模糊核,所述点扩散函数用高斯函数来表示,高斯函数中的标准差表示模糊量;Step 5.1: Perform discrete fuzzy quantity selection on the interpolated fuzzy graph obtained in step 3, and obtain n fuzzy quantities σ 1 , σ 2 ...σ n by step q; use these n fuzzy quantities to obtain n by using the point spread function A fuzzy kernel, the point spread function is represented by a Gaussian function, and the standard deviation in the Gaussian function represents the amount of blurring;

步骤5.2:使用基于稀疏先验的非盲反卷积算法以及n个模糊核对所述散焦图像进行n次非盲反卷积操作,得到n张去模糊图像;每个模糊核对应一个模糊量,当用第n个模糊核对散焦图像去模糊后,首先获取模糊图中比第n个模糊量大的模糊量所处的位置,将这些位置所对应的去模糊结果中的像素提取出来得到第n个去模糊结果;Step 5.2: Use the non-blind deconvolution algorithm based on sparse prior and n blur kernels to carry out n non-blind deconvolution operations on the defocused image to obtain n deblurred images; each blur kernel corresponds to a blur amount , when the defocused image is deblurred with the nth blurring kernel, firstly obtain the position of the blurring amount larger than the nth blurring amount in the blur map, and extract the pixels corresponding to these positions in the deblurring result to obtain nth deblurred result;

以上操作执行n次,最终得到n张去模糊图像;The above operations are performed n times, and finally n deblurred images are obtained;

步骤5.3:将步骤5.2的n张去模糊图像进行对应位置的像素值相加,最后对每个像素值除以255,得到一张全聚焦图像,也就是完全清晰的图像。Step 5.3: Add the pixel values of the corresponding positions of the n deblurred images in step 5.2, and finally divide each pixel value by 255 to obtain an all-focus image, that is, a completely clear image.

可选的,所述步骤3使用KNN matting插值算法对所述稀疏模糊图进行插值。Optionally, the step 3 uses a KNN matting interpolation algorithm to interpolate the sparse fuzzy map.

可选的,所述邻域的尺寸为11×11。Optionally, the size of the neighborhood is 11×11.

可选的,用于处理的图像为以下至少一项:模糊人脸图像;模糊人物图像;模糊景物图像;模糊车辆图像;模糊动物图像;以及模糊植物图像。Optionally, the image used for processing is at least one of the following: blurred face image; blurred person image; blurred scene image; blurred vehicle image; blurred animal image; and blurred plant image.

本发明的第二个目的在于提供一种电子设备,包括:至少一个处理器;以及与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行以上所述的散焦图像去模糊方法。A second object of the present invention is to provide an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication; wherein, the memory stores information executable by the at least one processor. instructions, the instructions are executed by the at least one processor, so that the at least one processor can execute the above-mentioned method for deblurring a defocused image.

本发明的第三个目的在于提供一种存储有计算机指令的非瞬时计算机可读存储介质,所述计算机指令用于使所述计算机执行以上所述的散焦图像去模糊方法。A third object of the present invention is to provide a non-transitory computer-readable storage medium storing computer instructions, the computer instructions are used to make the computer execute the above-mentioned method for deblurring a defocused image.

本发明有益效果是:The beneficial effects of the present invention are:

本发明的散焦图像去模糊方法,充分利用边界邻域梯度差值和模糊量的关系,来准确获得散焦图像边界位置的模糊量,从而解决去模糊结果中出现边界振铃伪影的问题。针对非盲反卷积算法保留图像细节信息的能力不够强导致去模糊结果中出现细节信息丢失的问题,本发明结合离散模糊量选择策略和稀疏先验设计了一种非盲发卷积算法来加强非盲反卷积算法保留图像细节信息的能力,解决了去模糊结果中出现细节信息丢失的问题。The defocused image deblurring method of the present invention makes full use of the relationship between the boundary neighborhood gradient difference and the blurring amount to accurately obtain the blurring amount at the boundary position of the defocused image, thereby solving the problem of boundary ringing artifacts in the deblurring result . Aiming at the problem that the ability of the non-blind deconvolution algorithm to retain image detail information is not strong enough to cause the loss of detail information in the deblurring result, the present invention combines the discrete fuzzy amount selection strategy and sparse prior to design a non-blind deconvolution algorithm to Strengthen the ability of the non-blind deconvolution algorithm to retain image detail information, and solve the problem of loss of detail information in the deblurring result.

相比于现有的散焦图像去模糊方法,本发明不仅能够有效地解决边界振铃伪影的问题,而且可以避免图像细节信息丢失,有效地提升了散焦图像去模糊后的清晰度。Compared with the existing methods for deblurring defocused images, the present invention can not only effectively solve the problem of boundary ringing artifacts, but also avoid loss of image detail information, and effectively improve the clarity of defocused images after deblurring.

附图说明Description of drawings

为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained based on these drawings without creative effort.

图1为本发明实施例二输入的散焦图像。FIG. 1 is a defocused image input in Embodiment 2 of the present invention.

图2展示了本发明实施例二利用尺度一致边界检测算法对图1进行边界检测得到的边界图。FIG. 2 shows a boundary map obtained by performing boundary detection on FIG. 1 by using a scale-consistent boundary detection algorithm according to Embodiment 2 of the present invention.

图3展示了本发明实施例二使用图2中的边界位置对图1中的边界求取的边界邻域梯度差值图。FIG. 3 shows a boundary neighborhood gradient difference map calculated for the boundary in FIG. 1 using the boundary position in FIG. 2 according to Embodiment 2 of the present invention.

图4展示了本发明实施例二使用图3中的边界邻域梯度差值获得的边界位置处的模糊量图。FIG. 4 shows the blur map at the boundary position obtained by using the boundary neighborhood gradient difference in FIG. 3 according to Embodiment 2 of the present invention.

图5展示了本发明实施例二使用图4中的边界位置的模糊量以及KNN matting插值算法获得的每个像素位置的模糊量图。FIG. 5 shows a map of the blur amount at each pixel position obtained by using the blur amount at the boundary position in FIG. 4 and the KNN matting interpolation algorithm according to Embodiment 2 of the present invention.

图6展示了本发明实施例二根据获得的模糊量以及非盲反卷积算法得到的最终去模糊结果图。FIG. 6 shows a final deblurring result diagram obtained according to the obtained blur amount and the non-blind deconvolution algorithm according to Embodiment 2 of the present invention.

具体实施方式detailed description

为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。In order to make the object, technical solution and advantages of the present invention clearer, the implementation manner of the present invention will be further described in detail below in conjunction with the accompanying drawings.

实施例一:Embodiment one:

本实施例提供一种散焦图像去模糊方法,包括:This embodiment provides a method for deblurring a defocused image, including:

步骤1:对所述散焦图像求取边界,在边界位置处求得边界邻域的梯度差值;Step 1: Obtain the boundary of the defocused image, and obtain the gradient difference of the boundary neighborhood at the boundary position;

步骤2:利用所述步骤1求得的所述边界邻域的梯度差值,求得边界位置处的模糊量,从而得到稀疏模糊图;Step 2: using the gradient difference value of the boundary neighborhood obtained in the step 1 to obtain the blur amount at the boundary position, thereby obtaining a sparse fuzzy map;

步骤3:对所述步骤2得到的所述稀疏模糊图进行插值得到插值模糊图;Step 3: Interpolating the sparse fuzzy map obtained in step 2 to obtain an interpolated fuzzy map;

步骤4:利用所述步骤3得到的所述插值模糊图对所述散焦图像进行模糊检测并计算模糊比,当所述模糊比大于预设的模糊比阈值时,对所述散焦图像进行去模糊;Step 4: Use the interpolation blur map obtained in step 3 to perform blur detection on the defocused image and calculate a blur ratio, and when the blur ratio is greater than a preset blur ratio threshold, perform blur detection on the defocused image deblurring;

步骤5:对于所述步骤4中需要去模糊的图像,使用所述步骤3中的所述插值模糊图来获得模糊核,再结合非盲反卷积算法执行去模糊操作。Step 5: For the image that needs to be deblurred in step 4, use the interpolation blur map in step 3 to obtain a blur kernel, and then perform a deblurring operation in combination with a non-blind deconvolution algorithm.

实施例二:Embodiment two:

本实施例提供一种基于边界邻域梯度差值的散焦图像去模糊方法,包括如下步骤:The present embodiment provides a defocused image deblurring method based on boundary neighborhood gradient difference, comprising the following steps:

步骤1:使用尺度一致边界检测算法求取散焦图像的边界,该尺度一致边界检测算法来源于文章Edge-Based Defocus Blur Estimation With Adaptive Scale Selection,得到边界位置后在原图中求以每个边界位置为中心的11x11邻域中的梯度,再将邻域中的最大梯度和最小梯度做差值得到边界位置处的梯度差值。Step 1: Use the scale-consistent boundary detection algorithm to obtain the boundary of the defocused image. The scale-consistent boundary detection algorithm comes from the article Edge-Based Defocus Blur Estimation With Adaptive Scale Selection. After obtaining the boundary position, find each boundary position in the original image is the gradient in the 11x11 neighborhood of the center, and then make a difference between the maximum gradient and the minimum gradient in the neighborhood to obtain the gradient difference at the boundary position.

步骤2:利用步骤1所得出的边界邻域梯度差值,求得边界位置处的模糊量,从而得到稀疏模糊图,具体步骤如下:Step 2: Use the boundary neighborhood gradient difference obtained in step 1 to obtain the blur amount at the boundary position, so as to obtain a sparse fuzzy map. The specific steps are as follows:

步骤2.1:获取边界邻域梯度差值和模糊量之间的关系式。Step 2.1: Obtain the relationship between the boundary neighborhood gradient difference and the blur amount.

对图像的散焦过程建模,如式(1)所示:Model the defocusing process of the image, as shown in formula (1):

Figure BDA0003917084050000051
Figure BDA0003917084050000051

其中,I表示散焦图像,k表示模糊核,x表示清晰图像,n表示噪声,

Figure BDA0003917084050000052
表示卷积操作,模糊核对清晰图像做卷积操作再加上噪声就会得到散焦图像。模糊核由点扩散函数和模糊量获得,点扩散函数由高斯函数表示,如式(2)所示:Among them, I represents the defocused image, k represents the blur kernel, x represents the clear image, n represents the noise,
Figure BDA0003917084050000052
Represents a convolution operation. The blur kernel performs a convolution operation on a clear image and adds noise to obtain a defocused image. The blur kernel is obtained by the point spread function and the blur quantity, and the point spread function is represented by a Gaussian function, as shown in formula (2):

Figure BDA0003917084050000053
Figure BDA0003917084050000053

其中,σ表示模糊量,模糊量表示的是像素的模糊程度,(x,y)表示像素坐标。Among them, σ represents the amount of blur, the amount of blur represents the degree of blur of the pixel, and (x, y) represents the coordinates of the pixel.

清晰图像的边界l(x,y)建模为式(3)所示:The boundary l(x,y) of the clear image is modeled as shown in formula (3):

l(x,y)=a*u(x,y)+b (3)l(x,y)=a*u(x,y)+b (3)

其中a是振幅,b是偏移量,u(x,y)是阶跃函数。where a is the amplitude, b is the offset, and u(x,y) is the step function.

定义边界邻域梯度差值如式(4)所示:Define the boundary neighborhood gradient difference as shown in formula (4):

Figure BDA0003917084050000054
Figure BDA0003917084050000054

通过实验发现边界邻域中的梯度最小值很小且接近于零,所以在公式推导中省略掉最小值部分。其中,GD(x,y)是边界邻域梯度差值,(x,y)′表示以(x,y)为中心的邻域,J(x,y)表示散焦图像边界,

Figure BDA0003917084050000061
表示边界邻域中的梯度,也就是对边界求导。求导结果如式(5)所示:It is found through experiments that the gradient minimum in the boundary neighborhood is very small and close to zero, so the minimum value part is omitted in the formula derivation. Among them, GD(x, y) is the gradient difference value of the boundary neighborhood, (x, y)' represents the neighborhood centered on (x, y), J(x, y) represents the defocused image boundary,
Figure BDA0003917084050000061
Represents the gradient in the boundary neighborhood, that is, deriving the boundary. The derivation result is shown in formula (5):

Figure BDA0003917084050000062
Figure BDA0003917084050000062

边界位置在(x,y)=(0,0),因此边界邻域梯度差值如式(6)所示:The boundary position is at (x,y)=(0,0), so the gradient difference of the boundary neighborhood is shown in formula (6):

Figure BDA0003917084050000063
Figure BDA0003917084050000063

根据式(6),可以推导出边界邻域梯度差值和模糊量的关系,如式(7)所示:According to formula (6), the relationship between the boundary neighborhood gradient difference and the fuzzy amount can be deduced, as shown in formula (7):

Figure BDA0003917084050000064
Figure BDA0003917084050000064

步骤2.2:根据边界邻域梯度差值和模糊量的关系式以及步骤1获得的边界邻域梯度差值,求得边界处的模糊量,从而得到稀疏模糊图。Step 2.2: According to the relationship between the boundary neighborhood gradient difference and the fuzzy amount and the boundary neighborhood gradient difference obtained in step 1, obtain the fuzzy amount at the boundary, thereby obtaining a sparse fuzzy map.

步骤3:稀疏模糊图只包含边界位置处的模糊量,为了得到剩余像素点的模糊量,本实施例使用KNN matting插值算法对步骤2获得的稀疏模糊图进行插值,从而得到包含所有像素点模糊量的插值模糊图。Step 3: The sparse blur map only includes the blur amount at the boundary position. In order to obtain the blur amount of the remaining pixels, this embodiment uses the KNN matting interpolation algorithm to interpolate the sparse blur map obtained in step 2, thereby obtaining a blur value that includes all pixels. Amount of interpolated blur maps.

步骤4:基于步骤3获得的插值模糊图以及设定的模糊量阈值,对散焦图像进行模糊区域和非模糊区域的划分。当像素点的模糊量大于该模糊量阈值时,该像素点被设定为模糊的,否则是非模糊的。对每个像素点执行以上操作,从而可以将图像划分为模糊区域和非模糊区域。计算模糊区域像素数占整张图像的像素数的比例,即模糊比。当模糊比大于一定数值时,认为该图像是模糊的,需要去模糊,否则不需要。Step 4: Based on the interpolation blur map obtained in step 3 and the set blur threshold, divide the defocused image into blurred areas and non-blurred areas. When the blurring amount of the pixel is greater than the blurring threshold, the pixel is set as blurred, otherwise it is not blurred. Perform the above operations for each pixel, so that the image can be divided into blurred areas and non-blurred areas. Calculate the ratio of the number of pixels in the blurred area to the number of pixels in the entire image, that is, the blur ratio. When the blur ratio is greater than a certain value, the image is considered to be blurred and needs to be deblurred, otherwise it is not needed.

步骤5:对于步骤4中需要去模糊的图像,使用步骤3中的插值模糊图来获得模糊核,再结合非盲反卷积算法执行去模糊操作。具体步骤如下:Step 5: For the image that needs to be deblurred in step 4, use the interpolated blur map in step 3 to obtain the blur kernel, and then perform the deblurring operation in combination with the non-blind deconvolution algorithm. Specific steps are as follows:

步骤5.1:对步骤3中获得的插值模糊图进行离散模糊量选择,得到n个模糊量,该离散模糊量选择策略来源于文章Spatially-Varying Out-Of-Focus Image DeblurringWith L1-2Optimization And A Guided Blur Map。使用这n个模糊量利用点扩散函数得到n个模糊核,本实施例的点扩散函数用高斯函数来表示,高斯函数中的标准差表示模糊量。Step 5.1: Perform discrete blurring selection on the interpolation blur map obtained in step 3 to obtain n blurring quantities. The discrete blurring selection strategy comes from the article Spatially-Varying Out-Of-Focus Image DeblurringWith L1-2Optimization And A Guided Blur Map. The n blur quantities are used to obtain n blur kernels by using the point spread function. The point spread function in this embodiment is represented by a Gaussian function, and the standard deviation in the Gaussian function represents the blur quantity.

步骤5.2:使用基于稀疏先验的非盲反卷积算法以及n个模糊核对散焦图像进行n次非盲反卷积操作,得到n张去模糊图像,其中非盲反卷积算法来源于文章Image andDepth from a Conventional Camera with a Coded Aperture。每个模糊核对应一个模糊量,当用第n个模糊核对散焦图像去模糊后,首先获取模糊图中比第n个模糊量大的模糊量所处的像素位置,将第n个去模糊图像中处于这些像素位置的像素值提取出来,剩下的像素舍去得到第n个去模糊图像,该去模糊图像只包含一部分像素位置的值,其他像素位置的值为0。模糊图是一张灰度图,每个像素位置的值就是模糊量,该模糊图是和散焦图像对应的,散焦图像中的每个像素位置和模糊图中的像素位置一一对应,而模糊图中某个像素位置的模糊量就是散焦图像中对应像素位置的模糊量。以上操作执行n次,最终得到n张去模糊图像。Step 5.2: Use the non-blind deconvolution algorithm based on sparse prior and n blur kernels to perform n non-blind deconvolution operations on the defocused image to obtain n deblurred images. The non-blind deconvolution algorithm comes from the article Image and Depth from a Conventional Camera with a Coded Aperture. Each blur kernel corresponds to a blur amount. When the nth blur kernel is used to deblur the defocused image, first obtain the pixel position of the blur amount larger than the nth blur amount in the blur map, and deblur the nth The pixel values at these pixel positions in the image are extracted, and the remaining pixels are discarded to obtain the nth deblurred image. The deblurred image only contains the values of some pixel positions, and the values of other pixel positions are 0. The blur map is a grayscale image, and the value of each pixel position is the amount of blur. The blur map corresponds to the defocused image, and each pixel position in the defocused image corresponds to the pixel position in the blur map. The blur amount of a certain pixel position in the blur map is the blur amount of the corresponding pixel position in the defocused image. The above operations are performed n times, and finally n deblurred images are obtained.

步骤5.3:将步骤5.2的n张去模糊图像进行像素值相加,最后对每个像素值除以255,得到一张全聚焦图像,也就是完全清晰的图像。Step 5.3: Add the pixel values of the n deblurred images in step 5.2, and finally divide each pixel value by 255 to obtain an all-focus image, that is, a completely clear image.

本实施例实现系统的环境如下:The environment for realizing the system in this embodiment is as follows:

表1:系统硬件配置表Table 1: System hardware configuration table

Figure BDA0003917084050000071
Figure BDA0003917084050000071

表2:系统软件配置表Table 2: System software configuration table

软件software 相关信息Related Information 操作系统operating system Windows 10 64位Windows 10 64 bit MatlabMatlab Matlab R2021aMatlab R2021a

实验效果如附图所示。The experimental results are shown in the accompanying drawings.

图1:输入的散焦图像,也就是需要进行处理让其变得清晰的图像。可以在图中看出左边的模糊程度最高,从左向右模糊程度依次递减。Figure 1: The input defocused image, that is, the image that needs to be processed to make it sharp. It can be seen in the figure that the degree of blur is the highest on the left, and the degree of blur decreases from left to right.

图2:使用尺度一致边界检测算法得到的边界图,它是一个二值图,也就是像素值只有0和1,1表示白色,0表示黑色。白色的像素点表示的就是边界位置。Figure 2: The boundary map obtained by using the scale-consistent boundary detection algorithm. It is a binary map, that is, the pixel values are only 0 and 1, 1 represents white, and 0 represents black. The white pixels represent the boundary positions.

图3:边界邻域梯度差值图,表示的就是每个边界位置的梯度差值,在本实施例的方法中发现边界邻域梯度差值和模糊量成反比,也就是越模糊的边界位置梯度差值越小,越清晰的边界位置梯度差值越大。图1中也描述了输入的散焦图像左边最模糊,从左到右模糊程度依次递减。而边界邻域梯度差值图中可以看出左边的边界位置处梯度差值较小,右边的边界位置处梯度差值较大。从而也验证了本实施例的方法。图中越亮的地方表示值越大,越暗的地方值越小。Figure 3: The gradient difference map of the boundary neighborhood, which shows the gradient difference of each boundary position. In the method of this embodiment, it is found that the gradient difference of the boundary neighborhood is inversely proportional to the amount of blur, that is, the more blurred the boundary position The smaller the gradient difference, the clearer the boundary position, the larger the gradient difference. Figure 1 also describes that the left side of the input defocused image is the most blurred, and the degree of blurring decreases from left to right. In the boundary neighborhood gradient difference diagram, it can be seen that the gradient difference at the left boundary position is small, and the gradient difference at the right boundary position is relatively large. Thus, the method of this embodiment is also verified. The brighter places in the figure represent larger values, and the darker places have smaller values.

图4:稀疏模糊图,它只包含边界位置处的模糊量,模糊量表示的是像素的模糊程度,该图中可以看出左边的边界位置处模糊量较大,右边的边界位置处模糊量较小,这也与图1的描述相对应。图中越亮的地方表示值越大,越暗的地方值越小。Figure 4: Sparse blur map, which only includes the blur amount at the boundary position. The blur amount indicates the blur degree of the pixel. In this figure, it can be seen that the blur amount at the left boundary position is larger, and the blur amount at the right boundary position Smaller, which also corresponds to the description in Figure 1. The brighter places in the figure represent larger values, and the darker places have smaller values.

图5:模糊图,它表示散焦图像中每个像素点的模糊量,它是灰度图,其中越亮的地方表示模糊程度越高,越暗的地方表示模糊程度越低。Figure 5: Blur map, which represents the blur amount of each pixel in the defocused image. It is a grayscale map, where the brighter the place is, the higher the degree of blurring is, and the darker the place is, the lower the degree of blurring is.

图6:去模糊图像,也就是变清晰了的图像,从图中可以看出相对于图1,该图中右边明显变清晰了,而且整体上看没有出现边界振铃伪影并且完全保留了图像的细节信息。Figure 6: The deblurred image, that is, the image that has become clearer. It can be seen from the figure that compared with Figure 1, the right side of the figure is obviously clearer, and overall there is no boundary ringing artifact and it is completely preserved Image details.

本发明实施例中的部分步骤,可以利用软件实现,相应的软件程序可以存储在可读取的存储介质中,如光盘或硬盘等。Part of the steps in the embodiments of the present invention can be realized by software, and the corresponding software program can be stored in a readable storage medium, such as an optical disk or a hard disk.

以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection of the present invention. within range.

Claims (10)

1. A method of deblurring a defocused image, the method comprising:
step 1: solving a boundary of the defocused image, and solving a gradient difference value of a boundary neighborhood at the position of the boundary;
step 2: obtaining a fuzzy quantity at the boundary position by using the gradient difference value of the boundary neighborhood obtained in the step 1, thereby obtaining a sparse fuzzy graph;
and 3, step 3: interpolating the sparse fuzzy graph obtained in the step 2 to obtain an interpolated fuzzy graph;
and 4, step 4: carrying out fuzzy detection on the defocused image by using the interpolation fuzzy image obtained in the step 3 and calculating a fuzzy ratio, and when the fuzzy ratio is greater than a preset fuzzy ratio threshold value, deblurring the defocused image;
and 5: for the image needing to be deblurred in the step 4, obtaining a blur kernel by using the interpolation blur graph in the step 3, and then performing a deblurring operation by combining a non-blind deconvolution algorithm.
2. The method of deblurring a defocused image as claimed in claim 1, wherein said step 1 comprises:
and solving the boundary of the defocused image by using a scale-consistent boundary detection algorithm, solving the gradient in a neighborhood taking each boundary position as a center in the original image after the boundary position is obtained, and then performing difference on the maximum gradient and the minimum gradient in the neighborhood to obtain the gradient difference at the boundary position.
3. The method of claim 1, wherein the step 2 comprises:
step 2.1: obtaining a relation between the boundary neighborhood gradient difference value and the fuzzy quantity:
modeling the defocusing process of the image, as shown in equation (1):
Figure FDA0003917084040000011
wherein I represents the defocused image, k represents a blur kernel, x represents a sharp image, n represents noise,
Figure FDA0003917084040000012
representing convolution operation, wherein the fuzzy core performs convolution operation on the clear image and the noise is added to obtain the defocused image;
the fuzzy kernel is obtained by a point spread function and a fuzzy quantity, the point spread function is represented by a Gaussian function, and the formula (2) is as follows:
Figure FDA0003917084040000013
wherein σ represents a blurring amount representing a blurring degree of the pixel, and (x, y) represents a pixel coordinate;
the boundary l (x, y) of the sharp image is modeled as shown in formula (3):
l(x,y)=a*u(x,y)+b (3)
where a is amplitude, b is offset, and u (x, y) is a step function;
defining the boundary neighborhood gradient difference value is shown as formula (4):
Figure FDA0003917084040000014
wherein GD (x, y) is the boundary neighborhood gradient difference, (x, y)' denotes a neighborhood centered at (x, y), J (x, y) denotes the defocused image boundary,
Figure FDA0003917084040000021
the gradient in the neighborhood of the boundary is represented, i.e. the boundary is differentiated, and the result of the derivation is shown in equation (5):
Figure FDA0003917084040000022
the boundary position is (x, y) = (0, 0), so the boundary neighborhood gradient difference is as shown in equation (6):
Figure FDA0003917084040000023
deriving a relation between the boundary neighborhood gradient difference and the fuzzy quantity according to equation (6), as shown in equation (7):
Figure FDA0003917084040000024
step 2.2: and (3) solving the fuzzy quantity at the boundary according to the relation between the boundary neighborhood gradient difference and the fuzzy quantity and the boundary neighborhood gradient difference obtained in the step (1), thereby obtaining a sparse fuzzy graph.
4. The method of claim 1, wherein the step 4 of calculating the blur ratio comprises:
setting a fuzzy quantity threshold, judging whether the fuzzy quantity of each pixel point in the interpolation fuzzy graph is greater than the fuzzy quantity threshold, when the fuzzy quantity of the pixel point is greater than the threshold, setting the pixel point as fuzzy, otherwise, setting the pixel point as non-fuzzy;
and dividing the interpolation fuzzy graph into a fuzzy region and a non-fuzzy region according to the judgment result, and calculating the proportion of the number of pixels in the fuzzy region to the number of pixels in the whole image, namely a fuzzy ratio.
5. The method of claim 1, wherein the step 5 comprises:
step 5.1: selecting discrete fuzzy quantity for the interpolation fuzzy graph obtained in the step 3, and obtaining n fuzzy quantities sigma by stepping q 1 、σ 2 …σ n (ii) a Obtaining n fuzzy kernels by using the n fuzzy quantities and utilizing a point spread function, wherein the point spread function is expressed by a Gaussian function, and a standard deviation in the Gaussian function expresses the fuzzy quantities;
step 5.2, using a non-blind deconvolution algorithm based on sparse prior and n fuzzy cores to perform n times of non-blind deconvolution operations on the defocused image to obtain n deblurred images; each fuzzy core is corresponding to a fuzzy quantity, when the nth fuzzy core is used for deblurring a defocused image, the positions of the fuzzy quantities which are larger than the nth fuzzy quantity in the fuzzy image are firstly obtained, and pixels in deblurring results corresponding to the positions are extracted to obtain the nth deblurring result;
executing the operations for n times to finally obtain n deblurred images;
and 5.3, adding the pixel values of the corresponding positions of the n deblurred images obtained in the step 5.2, and finally dividing each pixel value by 255 to obtain a full-focus image, namely a completely clear image.
6. The method according to claim 1, wherein the step 3 interpolates the sparse blur map by using a KNN matching interpolation algorithm.
7. The method of claim 2, wherein the size of the neighborhood is 11x 11.
8. The defocused image deblurring method of any of claims 1-7, wherein the image for processing is at least one of: blurring a face image; blurring the image of the character; blurring a scene image; blurring the vehicle image; blurring an animal image; and blurring the plant image.
9. An electronic device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the defocused image deblurring method of any of claims 1-8.
10. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the defocused image deblurring method of any one of claims 1-8.
CN202211345557.XA 2022-10-31 2022-10-31 Defocused image deblurring method based on boundary neighborhood gradient difference Pending CN115578289A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211345557.XA CN115578289A (en) 2022-10-31 2022-10-31 Defocused image deblurring method based on boundary neighborhood gradient difference

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211345557.XA CN115578289A (en) 2022-10-31 2022-10-31 Defocused image deblurring method based on boundary neighborhood gradient difference

Publications (1)

Publication Number Publication Date
CN115578289A true CN115578289A (en) 2023-01-06

Family

ID=84588287

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211345557.XA Pending CN115578289A (en) 2022-10-31 2022-10-31 Defocused image deblurring method based on boundary neighborhood gradient difference

Country Status (1)

Country Link
CN (1) CN115578289A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116311262A (en) * 2023-05-23 2023-06-23 济南大陆机电股份有限公司 Instrument information identification method, system, equipment and storage medium
CN116664451A (en) * 2023-07-27 2023-08-29 中铁九局集团第一建设有限公司 Measurement robot measurement optimization method based on multi-image processing

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116311262A (en) * 2023-05-23 2023-06-23 济南大陆机电股份有限公司 Instrument information identification method, system, equipment and storage medium
CN116664451A (en) * 2023-07-27 2023-08-29 中铁九局集团第一建设有限公司 Measurement robot measurement optimization method based on multi-image processing
CN116664451B (en) * 2023-07-27 2023-10-10 中铁九局集团第一建设有限公司 Measurement robot measurement optimization method based on multi-image processing

Similar Documents

Publication Publication Date Title
KR101871098B1 (en) Apparatus and method for image processing
CN108205804B (en) Image processing method and device and electronic equipment
CN110706174B (en) Image enhancement method, terminal device and storage medium
Deng et al. A guided edge-aware smoothing-sharpening filter based on patch interpolation model and generalized gamma distribution
CN101783012A (en) Automatic image defogging method based on dark primary colour
CN115578289A (en) Defocused image deblurring method based on boundary neighborhood gradient difference
CN103942758A (en) Dark channel prior image dehazing method based on multiscale fusion
CN110827229A (en) Infrared image enhancement method based on texture weighted histogram equalization
Agrawal et al. Dense haze removal by nonlinear transformation
CN112149672B (en) Image processing method and device, electronic equipment and storage medium
CN116468641A (en) Infrared blood vessel image enhancement processing method
CN110969046A (en) Face recognition method, device and computer-readable storage medium
CN113724155A (en) Self-boosting learning method, device and equipment for self-supervision monocular depth estimation
CN115147613A (en) Infrared small target detection method based on multidirectional fusion
CN105574823B (en) A kind of deblurring method and device of blurred picture out of focus
CN105243651B (en) Image edge enhancement method based on approximating variances and dark-coloured block pixels statistics information
Du et al. Perceptually optimized generative adversarial network for single image dehazing
CN118247181B (en) Image restoration model training method, electronic device and image restoration method
TWI784349B (en) Saliency map generation method and image processing system using the same
CN111325671A (en) Network training method and device, image processing method and electronic equipment
CN112825189B (en) Image defogging method and related equipment
CN118608438A (en) Image quality improvement method, device, equipment and medium
CN103618904B (en) Motion estimation method and device based on pixels
CN108174056A (en) A low-light video noise reduction method based on joint spatio-temporal domain
CN114913084B (en) Image processing method, device, electronic device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination