<p>I'm trying to break a continuous line segment into multiple, straight segments. <a href="https://i.sstatic.net/ToT9w.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ToT9w.png" alt="Group of line segments as connected"></a></p>

<p>I've tried using the Hough transform but have found it unreliable for getting the line segments I'm looking for and because it demands too much fine tuning to fit the automated medium I'm working in. </p>

<p>Analyzing points (comparing slopes/averages) as they change has shown some success, but the lines found are often too segmented or too unsegmented (just the whole line), proving unreliable so far. These are also prone to give too much of the subsequent line before cutting off when they have worked.</p>

<p>Contextual restrictions include:</p>

<ol>
<li>Only one 'Y' value per X point (this image doesn't show this, but the property holds).</li>
<li>There are no gaps between points in the line.</li>
<li>Noise is possible, but not that bad usually (within a few pixels of being correct).</li>
<li>The lines being detected are straight, not curved.</li>
<li>This is being developed in C++ using the SDL2 framework.</li>
</ol>

<p>I feel like I'm overcomplicating this question. How can I find the points that separate the segments? I suspect something comparing averages or averages of averages might be the way to go.</p>

CC BY-SA 3.0
2017-07-06T04:05:07.850Z
Can you show what you've tried so far, what the results were, and what you were expecting? Would the above image be three or four lines, for example? (Or something else?)
user1118321
CC BY-SA 3.0
2017-07-06T09:02:16.327Z
Points 1 and 2 together imply that no line will have a slope greater than 45 degrees above or below horizontal. Is this correct or do the definitions need to be adjusted?
trichoplax is on Codidact now
CC BY-SA 3.0
2017-07-06T09:03:38.063Z
What kind of noise does point 3 refer to? Does this only add points, or can points be removed/moved (which would then sometimes leave gaps between points in the line)?
trichoplax is on Codidact now
CC BY-SA 3.0
2017-07-06T09:09:27.053Z
We won't know for certain until you have fully specified what you are looking for, but it sounds likely that this is a far from trivial task, rather than you overcomplicating it.
trichoplax is on Codidact now
<c++><image-processing><line-drawing>
Finding Segments in Continuous line
user2108
# Finding Segments in Continuous line

(Asked by: username_0 on 2017-07-05)

I'm trying to break a continuous line segment into multiple, straight segments. [![Group of line segments as connected](https://i.sstatic.net/ToT9w.png)](https://i.sstatic.net/ToT9w.png)

I've tried using the Hough transform but have found it unreliable for getting the line segments I'm looking for and because it demands too much fine tuning to fit the automated medium I'm working in.

Analyzing points (comparing slopes/averages) as they change has shown some success, but the lines found are often too segmented or too unsegmented (just the whole line), proving unreliable so far. These are also prone to give too much of the subsequent line before cutting off when they have worked.

Contextual restrictions include:

1. Only one 'Y' value per X point (this image doesn't show this, but the property holds).
2. There are no gaps between points in the line.
3. Noise is possible, but not that bad usually (within a few pixels of being correct).
4. The lines being detected are straight, not curved.
5. This is being developed in C++ using the SDL2 framework.

I feel like I'm overcomplicating this question. How can I find the points that separate the segments? I suspect something comparing averages or averages of averages might be the way to go.

**Tags:** c++, image-processing, line-drawing

> **Comments:**
> **username_1**: Can you show what you've tried so far, what the results were, and what you were expecting? Would the above image be three or four lines, for example? (Or something else?)  
> **username_2**: Points 1 and 2 together imply that no line will have a slope greater than 45 degrees above or below horizontal. Is this correct or do the definitions need to be adjusted?  
> **username_2**: What kind of noise does point 3 refer to? Does this only add points, or can points be removed/moved (which would then sometimes leave gaps between points in the line)?  
> **username_2**: We won't know for certain until you have fully specified what you are looking for, but it sounds likely that this is a far from trivial task, rather than you overcomplicating it.  

---

## 0 answers

