Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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 (degrees).

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)

print(direction)

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

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 (degrees). (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)

print(direction)

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

I have the below image and I am inspection inspecting 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)

print(direction)