-1

I'm trying to design a line detector in opencv, and to do that, I need to get the Gaussian matrix with variance σs.

The final formula should be H=Gσs∗(Gσd')T, and H is the detector that I'm going to create, but I have no idea how am I supposed to create the matrix with the variance and furthermore calculate H finally. Update

This is the full formula.where “T” is the transpose operation.Gσd' is the first-order derivative of a 1-D Gaussian function Gσd with varianceσd in this direction

enter image description here

****Update****

These are the two formulas that I want, I need H for further use so please tell me how to generate the matrix. thx!

richard
  • 742
  • 2
  • 9
  • 21
  • I just answered this question [here](https://stackoverflow.com/a/64766664/4917686) for the first derivative, the same logic could be applied for the second. – João Cartucho Nov 10 '20 at 09:59

1 Answers1

1

As a Gaussian filter is quite common, OpenCV has a built-in operation for it: GaussianBlur.

When you use that function you can set the ksize argument to 0/0 to automatically compute the pixel size of the kernel from the given sigmas.


A Gaussian 2D filter kernel is separable. That means you can first apply a 1D filter along the x axis and then a 1D filter along the y axis. That is the reason for having two 1D filters in the equation above. It is much faster to do two 1D filter operations instead of one 2D.

Danvil
  • 22,240
  • 19
  • 65
  • 88
  • Thanks for the answer, but I still don't know how to get the result that I want. I'm not very familiar with `opencv` maybe more details? thanks again! – richard May 02 '14 at 09:30
  • To be precise: http://docs.opencv.org/doc/tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.html#smoothing – Danvil May 02 '14 at 11:07
  • I've seen that tutorial, but how can I use that function? `GaussianBlur( src, dst, Size( 0, 0 ), σs, σd )`? but there is a `first-order`,I don't know whether this can get the result I want? can you please show me how to use the function? – richard May 03 '14 at 07:25
  • @richard: Please be more specific. I do not understand your problem. – Danvil May 03 '14 at 08:36
  • ok, I want to get `I0'` in the formula that I provide and I don't know how to use `GaussiaBlur` to get that, sorry for not being clear, I just don't know how to describe it clearly in English.. – richard May 03 '14 at 09:11
  • @richard: This is in detail described in the linked tutorial. Read it carefully, compile the example code and execute it. – Danvil May 03 '14 at 09:14
  • @Danvil, I must be too stupid to understand that, I don't see what the `Gaussian blur` do with the first-order derivative, and I don't see how `Gaussianblur` give me the result that I want. I really need your explanation. thanks – richard May 03 '14 at 14:06
  • I need to get the matrix, could you please show me how to generate it? – richard May 04 '14 at 07:38