Gradient Directions: Shouldn't they range from 0-360 around a circles edge? [closed]
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
.
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)
print(direction)
dY = cv2.Sobel(src, cv2.CV_32F, 1, 0) No it should be dY = cv2.Sobel(src, cv2.CV_32F, 0, 1)
@LBerger Thanks, I should have double checked that silly mistake.