Convert 2d masks to 1d in Gaussian blur

I am trying to implement a Gaussian blur. I have already calculated the mask using the 2d function presented on wikipedia . I currently have a 2d matrix. I understand that to improve working time, you can avoid using standard convolution methods due to the decomposition of Gaussian. In other words, since this This answer says: "In the case of a Gaussian blur, it is divided into two one-dimensional operations."

This page was useful, however I do not understand how to get a 1d mask from an existing 2d mask. For example, this page converts the 2d mask in Figure 3 to the 1d mask in Figure 4. How to do this?

[EDIT]

It is enough to calculate the 1d mask to start with and apply it in the x direction, and then y?

[EDIT 2]

I realized that yes, you can simply create a 1d mask and use it in both x and y directions. The problem, however, is the quality of the resulting image when applying my Gauss filter.

Original Image (Input)Output

I assume that there are manipulations that need to be done when you calculate the point product of the mask and the selected section of the original image. What can cause the resulting image to be like this?

[EDIT]

In addition to @Jeremie Miserez's answer, this page was extremely helpful. It also has code if you need to see how it is done.

+4
source share
1

.

, : , 0,85. ​​3x3 ( Matlab).

>> h = fspecial('gaussian',3,0.85)

h =
    0.0626    0.1250    0.0626
    0.1250    0.2497    0.1250
    0.0626    0.1250    0.0626

, 1, , :

>> sum(sum(h))

ans =
     1

, rank 1, ​​ ( h1 h2, h : h1*h2=h)

>> rank(h)

ans =
     1

, . , 1, , (. ).

, svd. , U*S*V'=h .

>> [U,S,V] = svd(h)

U =
   -0.4085    0.9116   -0.0445
   -0.8162   -0.3867   -0.4292
   -0.4085   -0.1390    0.9021

S =
    0.3749         0         0
         0    0.0000         0
         0         0    0.0000

V =
   -0.4085   -0.3497   -0.8431
   -0.8162    0.5534    0.1660
   -0.4085   -0.7559    0.5115

, U*S*V'=h (V' V). 1 S , 0 (. ).

, (h1)*(h2)=h. S , s1*s2=S. , : U*s1*s2*V'=h, (U*s1)*(s2*V')=h.

, S, , S h1 h2:

>> h1 = U*sqrt(S)

h1 =
   -0.2501    0.0000   -0.0000
   -0.4997   -0.0000   -0.0000
   -0.2501   -0.0000    0.0000

>> h2 = sqrt(S)*V'

h2 =
   -0.2501   -0.4997   -0.2501
   -0.0000    0.0000   -0.0000
   -0.0000    0.0000    0.0000

, / , :

>> h1 = U(:,1)*sqrt(S(1,1))

h1 =
   -0.2501
   -0.4997
   -0.2501

>> h2 = sqrt(S(1,1))*V(:,1)'

h2 =
   -0.2501   -0.4997   -0.2501

, , h1 h2, :

h1 =
    0.2501
    0.4997
    0.2501
h2 =
    0.2501    0.4997    0.2501

>> h1*h2

ans =
    0.0626    0.1250    0.0626
    0.1250    0.2497    0.1250
    0.0626    0.1250    0.0626

() , :

>> h1*h2 - h

ans =
   1.0e-16 *
         0    0.2776   -0.1388
         0    0.5551   -0.2776
         0    0.2776   -0.1388

, eps :

>> eps
ans =
   2.2204e-16

- . , , , , 1 h. , , . .

+7

All Articles