The present invention relates to the field of computer vision techniques in a multi-channel guiding the filtered image, particularly an efficient hardware guided filtering method for use in a multi-label problem.
Since 2010, guided filtering (GF) has been used to many problems in computer vision and graphics such as image redirection, color transfer and video defogging. Among them, a multi-label system may be one of the most suitable applications for GF to fully utilize its efficiency and effects, because the heavy calculations in the multi-label system urgently require a fast filtering tool.
Due to linear complexity and edge preservation abilities, GF is considered to be the best choice among all candidate filters in a multi-label system. However, a shortcoming of GF is that the color image guided filtering algorithm is not efficient. It is observed that the running time increases significantly according to the size of the matrix. Specifically, matrix inversion is a time-consuming operation. Therefore, it is inefficient to apply GF to a multi-label system with multi-channel guidance, especially for a large number of channels.
In order to reduce the execution time, the most direct method of GF is to start a group of threads to invert the matrix at the same time. However, this strategy is not efficient on current hardware. This is because: (1) Both CPU and GPU rely on Single Instruction Multiple Data (SIMD) architecture to improve performance; (2) Branch instructions are inevitable for traditional matrix inversion methods such as LU algorithm; (3) The SIMD architecture cannot run branch instructions at the fastest speed, because these instructions need to decompose each vector into elements and process them sequentially on the architecture. In order to avoid branch instructions, the matrix can be inverted according to an analytical solution of the matrix inversion. GF uses the fastest OpenCV to implement this strategy to invert the 3×3 matrix, and successfully reduces the running time of inverting 106 matrices to less than 100 ms. However, the implementation complexity of the analysis solution increases as the size of the matrix increases. When the size of the matrix becomes larger, this method can no longer be implemented manually.
An objective of the present invention is to provide an efficient hardware guided filtering method for use in a multi-label problem, where the method includes:
Step 1, inputting the input guidance of a multi-label image;
Step 2, defining an efficient hardware guided filtering (HGF) model;
Step 3, calculating a vector {right arrow over (wp)} by a customized matrix inversion operation;
Step 4, inputting guidance through a mapping program for adding up result of each channel to form a polynomial guidance, and introducing nonlinearity into the linear model;
Step 5, obtaining a filtering result in an efficient hardware mode by element-wise calculation and box filtering.
The invention adopts element-wise arithmetic calculation and box filtering, having the following advantages: (1) Introducing nonlinearity to GF by inputting synthetic polynomial multi-channel guidance to overcome the shortcomings of GF linear model; (2) Linear models are usually not suitable for the input data due to their simplicity, so they tend to produce excessively smooth results; (3) Through the hardware efficient matrix inversion algorithm, the additional running time accompanying the nonlinear model can be reduced to an acceptable level.
The present invention will be further described below in conjunction with the accompanying drawings of the specification.
With reference to
(1) Defining HGF Includes the Following Steps:
Step 1. multi-point estimation: to calculate the estimation of a group of points in local support. Specifically, HGF estimates the coefficient {right arrow over (wp)} of the filter model (1) by minimizing linear ridge regression (2), where Y represents the input image.
Step 2. Aggregation: Fusion of each point available for multi-point estimates.
Equation (2) is used to optimize equation (1) to minimize {right arrow over (wp)} input HGF, getting a set of values Zp′(q)=Σi=1n {tilde over (w)}i,p Gi(q)+{right arrow over (w)}0,p, q∈Ωp for a given window Ωp; HGF aggregates these values together, and regards their average value
as the final filtering result Z(q).
(2) Calculating the Vector {right arrow over (wp)} Includes the Following Steps:
Step 3. To calculate the vector {right arrow over (wp)} according to equation (4) including the matrix inversion operation (λE+XPTXp)−1. E represents the identity matrix, the matrix Xp=[{right arrow over (c)}0,p, . . . , {right arrow over (c)}n,p] of input image pixel p. For the ith vector {right arrow over (c)}i,p of P, {right arrow over (c)}i,p=[Gi(q1), . . . , Gi(q|Ω
{right arrow over (wp)}=(λE+XPTXp)−1XpT{right arrow over (c)}n,p (4)
Step 4. Replacing λE+XPTXp by λE+Σi=0n {right arrow over (c)}i,p {right arrow over (c)}i,pT, equation (4) is re-expressed as equation (5).
{right arrow over (wp)}=XPT(λE+XPTXp)−1{right arrow over (c)}n+1,p=[{right arrow over (c)}0,pT, . . . ,{right arrow over (c)}n,pT]T(λE+Σi=0n{right arrow over (c)}i,p{right arrow over (c)}i,pT)−1{right arrow over (c)}n+1,p (5)
Step 5, if λE+Σi=0n {right arrow over (c)}i,p {right arrow over (c)}i,pT is invertible in step 4, then equation (6) is valid. Where αij,p=αij,pn, and can be calculated through equation (7) iterative calculation, k is from 1 to n, wherein
Step 6, to put the equation (6) into equation (5): the kth element {right arrow over (wp)}(k) of {right arrow over (wp )} converts into a linear combination Gij,p as in equation (8).
Step 7, there is a vector inner product result of point p: Gij,p={right arrow over (c)}i,pT {right arrow over (c)}j,p=Σk=1|Ω
(3) The Synthetic Polynomial Guidance Includes the Following Steps:
With reference to
Z(q)=Σi=1d={right arrow over (wp)}(i)Ii(q)+{right arrow over (wp)}(0),∀q∈Ωp (9)
Z(q)=Σi=1nΣj=1d{right arrow over (wp)}((i−1)d+j)Iij(q)+{right arrow over (wp)}(0) (10)
(4) Efficient Hardware Implementation Includes the Following Steps:
Step 9, equation (8) reveals the effective hardware method for calculating {right arrow over (wp)}, guaranteeing that the kth element {right arrow over (wp)}(k) of {right arrow over (wp)} is a linear combination of the box filtering result Gij(p). Specifically, (X) represents the box filtering result of image X, Wi and αij record the values {right arrow over (wp)}(k) and αij,p of any p in the image region (Wi(p)={right arrow over (wp)}(i), αij(p)=αij,p).
Step 10, extending equation (8) to the following box filtering result Gij (11) and element-wise arithmetic calculation (12), G0 represents all-ones matrix, Gi(1≤i≤n) represents the ith channel of G guided by the synthetic polynomial n channel, Gn+1 is another representation method of the input image Y.
G
ij=(GiGj) (11)
W
i=λ−1Gkn+1+Σi,j=0nαijGkiGjn+1 (12)
Updating the formula αij,pk can also be modified to the element-wise arithmetic calculation of matrix (13), where α000=−(λ+G00,p)−1, Fk=Σm,n=0k-1 αimk-1 αnjk-1 Gmk Gkn, and γk=−(1+λ−1Gkk+Σm,n=0k-1 αmnk-1 Gkm Gnk)−1.
Step 11, HGF calculates the filtering result Z according to the average value of the coefficient {right arrow over (wp)}, defining the average operator (X)=(X)/(G0), expressing the element-wise arithmetic calculation form of equation (3) as equation (14):
Z=Σ
i=1
n
(Wi)Gi+(W0) (14)
Step 12, observing the equation (11), (12), (13), (14), all equations involve only two calculation types: one is the element-wise arithmetic calculation of the matrix, and the other is the box filtering of the image, element-wise arithmetic calculation is a typical data parallel task. It applies element functions to the actual set of input data. The arithmetic calculation can be directly assigned to the core of the CPU or the threads of the GPU for parallel calculation. Many software or libraries support element-wise arithmetic calculations, such as Matlab, ViennaCL and Arrayfire.
Step 13, the value of the smoothed image produced by the box filtering is equal to the sum of its neighboring pixels in the input image. There is no need to manually implement box filtering, Intel's two libraries, the NPP of OpenCV and Nvidia are already available.
Number | Date | Country | Kind |
---|---|---|---|
201910047862.2 | Jan 2019 | CN | national |
This application is a 371 application of PCT application number PCT/CN2020/070051 filed Jan. 2, 2020 claiming priority from a Chinese patent application number 201910047862.2 filed Jan. 18, 2019, which are hereby incorporated herein by reference in its entirety for all purposes.
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2020/070051 | 1/2/2020 | WO | 00 |