If you're willing to learn a lot of theory, you could look up the wavelet packet transform. That transform has the very nice property that it is very good at finding boundaries in noisy data. Typical uses included picking phonemes out of a sound wave, filtering out white noise, and image recognition software.

It would therefore solve this problem nicely, but learning enough theory to properly understand and implement this solution may take you a considerable amount of time. (Think multiple weeks.) Sorry, but I don't know the theory. I did learn it at one point, but I forgot it somewhere in the last millennium.

If you're looking for easier heuristics I'd suggest something like this. Take the minimum and maximum values on the Y-axis. Suppose that range is 60-140. Divide the range into 20 pieces. (20 is arbitrary, try it with several other numbers until you get satisfactory results.) So you'd have intervals 60-64, 64-68, 68-72 and so on. Now make (overlapping) intervals of adjacent pairs. So you'd have 60-68, 64-72, 68-76 and so on. For each of those slices on the Y-axis there are one or more maximal intervals on the X-axis where you stay inside of the range. Compute all of those.

You now have a ton of overlapping intervals on the X-axis. Take out the longest interval you've got. That's a stable area. Then cut out the longest interval in what is left. And the largest that is left in that. And so on.

Then what you do is call all labels above a certain length stable, and you know their end points.

(The reason for making them overlapping is that if you have a stable interval varying around, say, 68, you want to notice it even if 68 is one of the boundaries of a vertical slice you're looking at.)

You'll have to play around with how many pieces to cut the vertical into, and how long a horizontal piece will be called stable. It won't be pretty code and you will need some playing around. But you will probably get somewhat reasonable results. And you won't have to learn a ton of math to do it properly.


In reply to Re: How to Determine Stable Y-Values... or Detect an Edge..? by tilly
in thread How to Determine Stable Y-Values... or Detect an Edge..? by ozboomer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.