opencv - extract lines from canny edge detection -


in opencv after applying canny edge detection i'd further process result (show horizontal lines, remove short lines, etc..). result of canny image. i'd array of lines describing detected edges

i'm aware of famous hough line transform, result not good, that's why i'd manually process canny result. input:

enter image description here

output canny only:

enter image description here

output canny hough line transform

enter image description here

this hough line transform result(red lines) detecting edges of stairs. 4th line below not detected correctly, although canny edge detected edge.

any idea how extract edges canny image?

a few things can try improve results:

apply region of interest

your image looks have bordering window effects. removed them region of interest resulting in image looks (i tweaked until looked right, if you're using kind of kernel operator it's window size better defines roi):

enter image description here

use standard hough transform

it seems you're using probabilistic hough transform. so, you're getting line segments instead of interpolated line. consider using standard transform full theoretical line (rho, theta). doing got image shown below:

enter image description here

here code snippet used generate lines (from python interface):

(mu, sigma) = cv2.meanstddev(stairs8u) edges = cv2.canny(stairs8u, mu - sigma, mu + sigma) lines = cv2.houghlines(edges, 1, pi / 180, 70) 

filter lines based on angle

you can filter out poor lines taking occurring line angles, , throwing away outliers. should narrow down visible steps.

hope helps!


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -