Ask Your Question
0

magnitude of a matrix

asked Feb 19 '14

mahsa gravatar image

updated Feb 19 '14

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

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Feb 19 '14

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

Preview: (hide)

Comments

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

mahsa gravatar imagemahsa (Feb 19 '14)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 (Feb 19 '14)edit

Question Tools

Stats

Asked: Feb 19 '14

Seen: 1,705 times

Last updated: Feb 19 '14