Gradient Directions: Shouldn't they range from 0-360 around a circles edge? [closed]

asked 2018-08-09 03:04:51 -0600

sazr gravatar image

updated 2018-08-09 03:06:51 -0600

I have the below image and I am inspection the gradient directions around the circle edge. When I print out the gradient direction values they are only ever 2 values 44.99 and 224.99 (for the edges around the circle) the black and white areas are 0.

image description

I thought the gradient directions around a circles edge would always point perpendicular to the edge. So my gradient directions would range from 0-360 degrees.

Is my calculation of the gradient direction wrong or my understanding of image gradient directions?

src = cv2.imread('../images/circle.png', cv2.IMREAD_GRAYSCALE)

dX = cv2.Sobel(src, cv2.CV_32F, 1, 0)
dY = cv2.Sobel(src, cv2.CV_32F, 1, 0)
# mag, direction = cv2.cartToPolar(dX, dY, angleInDegrees=True)
mag = cv2.magnitude(dX, dY)
direction = cv2.phase(dX, dY, angleInDegrees=True)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2018-08-09 03:33:42.731567



dY = cv2.Sobel(src, cv2.CV_32F, 1, 0) No it should be dY = cv2.Sobel(src, cv2.CV_32F, 0, 1)

LBerger gravatar imageLBerger ( 2018-08-09 03:06:41 -0600 )edit

@LBerger Thanks, I should have double checked that silly mistake.

sazr gravatar imagesazr ( 2018-08-09 03:09:16 -0600 )edit