Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simplifying wiggly paths

87 views
Skip to first unread message

Malcolm McLean

unread,
Dec 6, 2022, 5:52:35 AM12/6/22
to
I'm working on a problem where a user enters a degraded, wiggly curve (it's actually created by tracing software from what might have been once a rectangle, for example, but has been physically printed, then scanned, and so on, so that there are plenty of stray pixels picked up by the tracing software).

So basically what I want to do is sample the curve at a fairly low resolution, then re-fit it, to get rid of the noise. However I want to retain the genuine sharp corners. So in the rectangle case, the desired output wouldn't be a mathematical rectangle, but it would be four clean almost straight curves, connected by four corners of almost ninety degreees.

The curve tends to go back on itself. It's like a coastline. It's easy to pick out the real curve from the noise by eye, but harder to do it automatically.

Paul N

unread,
Dec 6, 2022, 8:04:13 AM12/6/22
to
Would it help to assume that if the "curve" is close enough to a straight line, then it is meant to be one, and choose the best straight line that fits?

Malcolm McLean

unread,
Dec 6, 2022, 9:50:31 AM12/6/22
to
That's part of the idea. However the underlying shapes might not have straight lines.

Ben Bacarisse

unread,
Dec 11, 2022, 6:49:36 PM12/11/22
to
How is this going? I can't help, but I was hoping so see some
interesting discussion as it seems both challenging and likely to have
been solved before (though possibly with constraints that don't match
your circumstances).

--
Ben.

Malcolm McLean

unread,
Dec 12, 2022, 7:34:30 AM12/12/22
to
I got an artist to draw up a test set for me.

The core of it is a function called "GetRealCorners", which takes a Bezier path,
and returns the real corners. A Bezier path has a corner if the two handles at
a knot point don't form a straight line. But a mathematical corner could represent
either a real corner in the underlying image, or local noise.

So what I am doing is taking ten pixels in curve space on each side of the corner.
If either the leading or the trailing sample isn't at least three times a long as it is
wide, as measured by the bounding box, I say that the corner isn't real. If any
of the leading or the trailing curves overhangs the corner, I say the corner isn't
real. Then I compare the angles of the tangents at the corner point to the vectors
obtained by going from start to end on the leading and trailing curves. If they are
not similar enough, I say the corner isn't real. Finally I take the angle between the
start o fthe leading curve, the corner, and the end of the trailing curve. If it is too
close to 180 degrees, I say the corner isn't real.

Having marked the real corners, I sample the curve at fairly coarse intervals,
apply a Gaussian filter to smoothing things out and then refit it with a sloppy
tolerance factor, which gives me a fairly smooth curve between the corners.

Whilst it works on the test set, the snag is that I had to fiddle with the parameters
in an ad hoc way to achieve this.


Julio Di Egidio

unread,
Dec 12, 2022, 1:21:18 PM12/12/22
to
On Monday, 12 December 2022 at 13:34:30 UTC+1, Malcolm McLean wrote:

> Whilst it works on the test set, the snag is that I had to fiddle with
> in an ad hoc way to achieve this.

Next step is Machine Learning (learning the parameters)...

Julio

Y V A

unread,
Apr 20, 2023, 7:31:36 AM4/20/23
to
Hello.....
Girls, boys, come see:

⠀⠀⠀⠀⠀⠀⠀⠀kohtumispaik2.freehostpro.com/a.php
⠀⠀⠀⠀⠀⠀⠀⠀kohtumispaik3.66ghz.com/a.php
⠀⠀⠀⠀⠀⠀⠀⠀kohtumispaik4.medianewsonline.com/a.php
⠀⠀⠀⠀⠀⠀⠀⠀aaaaaaaaaaaaaaaar.medianewsonline.com/firstpage.php
⠀⠀⠀⠀⠀⠀⠀⠀themostconfortabletalkplace.medianewsonline.com/a.php


I will wait You there patiently, but I may not be all the time there.

Y V A

unread,
Apr 20, 2023, 7:31:52 AM4/20/23
to
Hello.....
Girls, boys, come see:

⠀⠀⠀⠀⠀⠀⠀⠀kohtumispaik2.freehostpro.com/a.php
⠀⠀⠀⠀⠀⠀⠀⠀kohtumispaik3.66ghz.com/a.php
⠀⠀⠀⠀⠀⠀⠀⠀kohtumispaik4.medianewsonline.com/a.php
⠀⠀⠀⠀⠀⠀⠀⠀aaaaaaaaaaaaaaaar.medianewsonline.com/firstpage.php
⠀⠀⠀⠀⠀⠀⠀⠀themostconfortabletalkplace.medianewsonline.com/a.php


I will wait You there patiently, but I may not be all the time there.



0 new messages