EFFICIENT HARDWARE GUIDED FILTERING METHOD FOR USE IN MULTI-LABEL PROBLEM

Information

  • Patent Application
  • 20220092751
  • Publication Number
    20220092751
  • Date Filed
    January 02, 2020
    4 years ago
  • Date Published
    March 24, 2022
    2 years ago
Abstract
The present invention provides an efficient hardware guided filtering method for use in solving a multi-label problem. The method includes the following steps: inputting an input guidance of a multi-label image; defining an efficient hardware guided filtering (HGF) model; calculating a vector by a customized matrix inversion operation; 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; and obtaining a filtering result in an efficient hardware mode by element-wise calculation and box filtering.
Description
FIELD OF THE INVENTION

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.


BACKGROUND OF THE INVENTION

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.


SUMMARY OF THE INVENTION

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.





BRIEF DESCRIPTION OF THE DRAWINGS


FIG. 1 is a flowchart of the present invention.



FIG. 2 is a flowchart of HGF using input filtering from a multi-label system.





DETAILED DESCRIPTION

With reference to FIG. 1, an efficient hardware guided filtering method for use in a multi-label problem includes a total of four processes: (1) Definition of HGF; (2) Calculation of vector {right arrow over (wp)}; (3) Synthetic polynomial guidance; (4) Efficient hardware implementation.


(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.











Z


(
q
)


=





i
=
1

n






w
p





(
i
)





G
i



(
q
)




+



w
p





(
0
)




,



q


Ω
p







(
1
)








min


w
p










λ






w
p





2
2



+




q


Ω
p






(


Y


(
q
)


-




i
=
1

n






w
p







(
i
)




G
i



(
q
)




-



w
p





(
0
)



)

2






(
2
)







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







1



Ω
q









p


Ω
q






Z
p




(
q
)







as the final filtering result Z(q).













Z


(
q
)


=





1



Ω
q









p


Ω
q








i
=
1

n






w
p





(
i
)





G
i



(
q
)






+



w
p





(
0
)









=







i
=
1

n






w


q
a



(
i
)





G
i



(
q
)




+



w


q
a



(
0
)










(
3
)







(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(qp|)]T (0≤i≤n+1) is added to the record value Gi(qk) of the kth output pixel, wherein qk∈Ωp, Ωp represents the neighboring region centered on the pixel P; and |Ωp| represents the total number of pixels in Ωp, and the image is Gi.





{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)}=XPTE+XPTXp)−1{right arrow over (c)}n+1,p=[{right arrow over (c)}0,pT, . . . ,{right arrow over (c)}n,pT]TE+Σ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,pij,pn, and can be calculated through equation (7) iterative calculation, k is from 1 to n, wherein











α

0

0

0

=

-


(

λ
+

G


0

0

,
p



)


-
1











G


i

j

,
p


=



c



i
,
p

T




c



j
,
p











F


i

j

,
p

k

=




m
,

n
=
0



k
-
1





α


i

m

,
p


k
-
1




α


n

j

,
p


k
-
1




G


m

k

,
p




G


k

n

,
p












γ
p
k

=

-


(

1
+


λ

-
1




G


k

k

,
p



+




m
,

n
=
0



k
-
1





α


m

n

,
p


k
-
1




G


k

m

,
p




G


n

k

,
p





)


-
1












(


λ

E

+




i
=
0

n





c



i
,
p





c



i
,
p

T




)


-
1


=



λ

-
1



E

+




i
,

j
=
0


n




α


i

j

,
p





c



i
,
p





c



j
,
p

T









(
6
)







α


i

j

,
p

k

=

{







γ
p
k



F


i

j

,
p

k


+

α

ij
,
p


k
-
1












i
<
k

,

j
<
k









λ

-
1





γ
p
k



(




n
=
0


k
-
1





α


i

n

,
p


k
-
1




G


n

j

,
p




)












i
<
k

,

j
=
k









λ

-
1





γ
p
k



(




m
=
0


k
-
1





α


m

j

,
p


k
-
1




G


i

m

,
p




)












i
=
k

,

j
<
k








λ

-
2




γ
p
k






i
<
k

,

j
=
k










(
7
)







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).












w
p





(
k
)


=






c



k
,
p

T



(

λE
+




i
=
0

n





c



i
,
p





c



i
,
p

T




)



-
1





c




n
+
1

,
p



=





c



k
,
p

T



(



λ

-
1



E

+




i
,

j
=
0


n




α


i

j

,
p





c



i
,
p





c



j
,
p

T




)





c




n
+
1

,
p



=



λ

-
1




I



k

n

+
1

,
p



+




i
,

j
=
0


n




α


i

j

,
p




I


k

i

,
p




I



j

n

+
1

,
p











(
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,pk=1p|Gi(qk)Gj(qk)=Σq∈Ωp Gi(q)Gj(q), and the box filtering result Gij(p)=Σq∈Ωp GiGj(q)=Σq∈Ωp Gi(q)Gj(q), so if the neighboring region Ωp of p is a box window, since there is Gij,p=Gij(p), the box filter is applied to the element to generate the image to form Gij, {right arrow over (wp)}(k) is calculated according to the linear combination of Gij to form {right arrow over (wp)}. The above steps 4), 5), 6), and 7) only consist of arithmetic calculations and box filtering, which completely eliminates matrix inversion operations in the calculation process.


(3) The Synthetic Polynomial Guidance Includes the Following Steps:


With reference to FIG. 2, in step 8, equation (9) shows a polynomial model guidance I with gray input, where d is the degree of the polynomial function. Assuming Gi=Ii, the equivalence between the linear model (1) and the polynomial model (9) can be found, when the input guidance is multi-channel, the mapping program G(i-1)d+j=Iij is applied directly to each channel independently, where Ii represents the ith channel of the multi-channel guide I, and n is the number of channels. After that, the results of each channel of the input multi-channel guide I are superimposed to form a polynomial guidance. Mathematically, the linear model (1) in this case is equivalent to the nonlinear polynomial model (10). Therefore, the nonlinearity is successfully assigned to the generalized linear model (1) of HGF.






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, custom-character(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=custom-character(GiGj)  (11)






W
i−1Gkn+1i,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, Fkm,n=0k-1 αimk-1 αnjk-1 Gmk Gkn, and γk=−(1+λ−1Gkkm,n=0k-1 αmnk-1 Gkm Gnk)−1.










α
ij
k

=

{





F
p
k

+

α
ij

k
-
1







i
<
k

,

j
<
k








λ

-
1





γ
k



(




n
=
0


k
-
1





α

i





n


k
-
1




G
nk



)







i
<
k

,

j
=
k








λ

-
1





γ
k



(




m
=
0


k
-
1





α
mj

k
-
1




G

k





m




)







i
=
k

,

j
<
k








λ

-
2




γ
k





i
=

j
=
k










(
13
)







Step 11, HGF calculates the filtering result Z according to the average value of the coefficient {right arrow over (wp)}, defining the average operator custom-character(X)=custom-character(X)/custom-character(G0), expressing the element-wise arithmetic calculation form of equation (3) as equation (14):






Z=Σ
i=1
n
custom-character(Wi)Gi+custom-character(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.

Claims
  • 1. An efficient hardware guided filtering method for use in a multi-label problem comprising: 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 means of a customized matrix inversion operation;step 4: inputting guidance through a mapping program for adding up the results of each channel to form a polynomial guidance, and introducing nonlinearity into the linear model; andstep 5: obtaining a filtering result in an efficient hardware mode by means of element-wise calculation and box filtering.
  • 2. The method according to claim 1, wherein the step 2 comprises the following steps: step 201: defining the HGF by: Z(q)=Σi=1n{right arrow over (wp)}(i)Gi(q)+{right arrow over (wp)}(0),∀q∈Ωp  (1)wherein {right arrow over (wp)}(i) is ith coefficient; {right arrow over (wp)}(0) is an initial coefficient; Gi(q) is a recorded value of a pixel q;step 202: minimizing linear ridge regression (2) to estimate equation (1), wherein coefficient {right arrow over (wp)} of HGF is obtained by:
  • 3. The method according to claim 1, wherein the step 3 comprises the following steps: step 301: calculating the vector {right arrow over (wp)} according to the following equation (4) including the customized matrix inversion operation (λE+XPTXp)−1: {right arrow over (wp)}=(λE+XPTXp)−1XpT{right arrow over (c)}n,p  (4)wherein E is an identity matrix; Xp=[{right arrow over (c)}0,p, . . . , {right arrow over (c)}n,p] is a matrix of input image pixel p, and {right arrow over (c)}n,p is the nth vector of pixel p, andwherein with respect to ith vector {right arrow over (c)}i,p of {right arrow over (c)}i,p=[Gi(q1), . . . , Gi(q|Ωp|)]T (0≤i≤n+1) is added to a recorded value Gi(qk) of the kth output pixel q, wherein qk∈Ωp, Ωp represents a neighboring region centered on the pixel P; and |Ωp| represents the total number of pixels in Ωp;step 302: replacing λE+XPTXp by λE+Σi=0n {right arrow over (c)}i,p {right arrow over (c)}i,pT to obtain equation (5), wherein if the equation is invertible then the equation (6) is valid:
  • 4. The method according to claim 1, wherein the step 4 comprises: when the input guidance is multi-channel, the mapping program G(i-1)d+j=Iij is applied directly to each channel independently, and results of each channel of the input multi-channel guide I are superimposed to form a polynomial guidance, nonlinearity is assigned to a generalized linear model (1) of the HGF to obtain a nonlinear polynomial model (10): Z(q)=Σi=1nΣj=1d{right arrow over (wp)}((i−1)d+j)Iij(q)+{right arrow over (wp)}(0)  (10)wherein d is a degree of the polynomial function; Ii represents the ith channel of the multi-channel guide I, and n is the number of channels
  • 5. The method according to claim 1, wherein the step 5 comprises the following steps: step 501: representing a box filtering result of image X as (X), Wi and αij recording values of {right arrow over (wp)}(k) and αij,p at any p point in the image region;step 502: extending equation for calculating {right arrow over (wp)}(k) to those which only use the box filtering result Gij (11) and element-wise arithmetic calculation (12)
Priority Claims (1)
Number Date Country Kind
201910047862.2 Jan 2019 CN national
CROSS-REFERENCES TO RELATED APPLICATIONS

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.

PCT Information
Filing Document Filing Date Country Kind
PCT/CN2020/070051 1/2/2020 WO 00