# Pipeline for finding hough lines in a binary image

**URL:** <https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571>\
**Category:** OpenMV Boards\
**Created:** [January 9, 2020, 3:49am UTC](https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571 "2020-01-09T03:49:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrey](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@andrey](https://forums.openmv.io/u/andrey)\
**Post date:** [January 9, 2020, 3:49am UTC](https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571/1 "2020-01-09T03:49:59Z")

</div>

Hey guys,  
Is it possible to find hough lines after thresholding an image.  
After trying it it just shows alot of random lines, im assuming because the sobel filter doesn’t really highlight edges on a binary image.  
I’ve tried doing threshold → canny edge → find\_lines as well, but it has the exact same result.

How can I find lines only around say red objects in an image.

Cheers.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [January 9, 2020, 6:14am UTC](https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571/2 "2020-01-09T06:14:37Z")

</div>

Binary images probably have too strong of an edge strength making the Hough lines algorithm go crazy.

I’d recommend running the find\_line\_segements() method instead. It does a lot of filtering on the output which should help.

---

<div class="post-metadata">

**Author:** ![andrey](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@andrey](https://forums.openmv.io/u/andrey)\
**Post date:** [January 9, 2020, 7:00am UTC](https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571/3 "2020-01-09T07:00:36Z")

</div>

Unfortunately segments would be too slow for my purposes.  
In opencv I would usually threshold what I need to get the binary → find contours → hough transform  
There must be some alternative way to do find the edges of a binary image using the openmv libs.  
😕

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [January 10, 2020, 6:25am UTC](https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571/4 "2020-01-10T06:25:23Z")

</div>

Just run find\_lines() this method does the sobel filter and then hough transform in one step. We don’t really have the memory to due these independently like with OpenCV. So, our methods typically do multiple things per call.

The output will be a list of lines which you can filter by their angle and line strength. You have to write list processing code to do something useful with this output.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [January 10, 2020, 6:30am UTC](https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571/5 "2020-01-10T06:30:05Z")

</div>

Oh, we have a optimizer that we hired… I may ask him to work on find\_line\_segments next. He might be able to 2-3x the performance on that code…

---

<div class="post-metadata">

**Author:** ![andrey](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@andrey](https://forums.openmv.io/u/andrey)\
**Post date:** [February 12, 2020, 8:23am UTC](https://forums.openmv.io/t/pipeline-for-finding-hough-lines-in-a-binary-image/1571/6 "2020-02-12T08:23:00Z")

</div>

I heard!  
Already preordered some openmv pluses for work!  
Cheers.
