0

I would like to find the gradient at each element of a 2D Matrix of doubles. I think there are many ways to do that, the most simple one is probably to apply a 3x3 Kernel matrix looking like that:

0,  1,  0,
1, -4,  1,
0,  1,  0,

Is there a way in Eigen to do such a thing or should I do this manualy with a double for-loop ?

There are other more sophisticated ways to compute the gradiant of an matrix, like the Sobel Operator, but I can't find anything about it in the Eigen lib's documentation, but I might just lack the proper mathematical knowledge to type the correct keywords. I would greatly appreciate someone pointing me in the right direction.

Thank you

mathislm
  • 65
  • 1
  • 7
  • 2
    Eigen does not have a built-in function to apply a convolution kernel directly on a 2D matrix. Like what you've mentioned, you can implement it manually using a nested for-loop. – Kozydot Apr 11 '23 at 07:55
  • 2
    Looks like you are using wrong library. What are you actually doing? Are you trying to analyze some image? If yes then you should use OpenCV. – Marek R Apr 11 '23 at 08:51
  • I guess I should, but 1. I have this matrix in Eigen and 2. I'm just trying to compute the gradient of a matrix, I should be able to do that in Eigen. – mathislm Apr 11 '23 at 09:30
  • Eigen is a linear algebra library, not image processing. You can [combine it with OpenCV](https://stackoverflow.com/questions/14783329/opencv-cvmat-and-eigenmatrix) for convolution kernels – Homer512 Apr 11 '23 at 22:56

0 Answers0