Weird result while finding angle
Hi
I wanted to find the angle of a curve at every pixel. For that, I applied canny edge detection. For test image, i took a filled rectangle. So obviously, canny edge result is just a rectangle.
Then i applied Sobel derivative in x and y direction and to find the angle, i took arctan(dy/dx). ( dx = dx+0.001 to avoid divide by zero)
For vertical side, i got an angle of 0 which is true since dy=0 in vertical direction and dx is some high value.
But for horizontal side also, i got zero. I don't understand why. When i took its corresponding dx,dy values, dx = 0.001... and dy = 0. Isn't it wrong to get dy = 0 on the horizontal side of the rectangle?
I checked the dy image, and it clearly shows the top and bottom sides of the rectangle. But still, why dy = 0 on that side?
Below is my dx image:
My dy image:
You have a rectangle (I'm suppose it sides are parallel to coordinate axises), so one of angles must be 90 degrees (on vertical side) and the other is 0 (on horizontal side).
I know. But I get both as zero. that is my question. since equation is arctan(dy/dx), we should get 90 for horizontal sides. ( ie dy is high on horizontal side , and dx = 0 there, check out the images)
Could you explain, what is dx an dy image? Sobel gets an one input array and produces one output. Why you have two images?
dx is result i got while applying sobel in horizontal direction. and dy in vertical direction.