A few things you can try to improve your results:
Apply area of ββinterest
There are some border window effects in your image. I deleted them with the region of interest, the result is an image that looks like this (I changed it until it looked right, but if you use some kind of kernel operator, the window size is probably better defined by this ROI):

Use standard Hough transform
It also seems that you are using the Hough probabilistic transformation. Thus, you get only line segments instead of the interpolated line. Consider the standard transformation to get the complete theoretical line (rho, theta). To do this, I got an image as shown below:

Here is the code snippet I used to create the strings (from the Python interface):
(mu, sigma) = cv2.meanStdDev(stairs8u) edges = cv2.Canny(stairs8u, mu - sigma, mu + sigma) lines = cv2.HoughLines(edges, 1, pi / 180, 70)
Angle-based filter lines
You can probably filter out the bad lines using the most common linear angles and discarding outliers. This should narrow it down to the most visible steps.
Hope this helps!
mevatron
source share