Ask Your Question
0

magnitude of a matrix

asked 2014-02-19 02:41:47 -0600

mahsa gravatar image

updated 2014-02-19 04:02:28 -0600

berak gravatar image

I have used sobel to get the gradient of an image in X and Y direction:

cv::Sobel( Min1, grad_x, Min1.depth(), 1, 0, 3);    
cv::Sobel( Min1, grad_y, Min1.depth(), 0, 1, 3);

now I have the gradient of the Min1 in X direction stored in Mat grade_x and in Y direction stored in Mat grade_y.

How do I calculate the magnitude of grad_x and grad_y? Is there any function in Opencv to get the norm of a matrix?

Thanks in advance...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-02-19 07:36:48 -0600

OpenCV has one function called magnitude(x_gradient, y_gradient, dest);. It is exactly what you want.

edit flag offensive delete link more

Comments

wow..good news. Is there any function for "orientation"?

mahsa gravatar imagemahsa ( 2014-02-19 08:56:42 -0600 )edit

You can compute both manitude and orientation components from X-axis and Y-axis gradients with cartToPolar() function. See more at: http://stackoverflow.com/questions/8542202/image-transformation-from-2d-coordinates-to-cylindrical-coordinates. If this is what you want please mark your question as being answered.

tuannhtn gravatar imagetuannhtn ( 2014-02-19 09:34:19 -0600 )edit

Question Tools

Stats

Asked: 2014-02-19 02:41:47 -0600

Seen: 1,453 times

Last updated: Feb 19 '14