Turn Hand Sketch Lines/curves to Rhino vector lines/Curves

Hi all, I am curious if there is any plug-ins can help to turn hand sketch lines / curves into rhino vector lines / curves. I have tried with the Rooster plug-in, but realize it recognizes color and trace it as boundary… I think this is not what I after. What I want is tracing it as lines or curves, as “03” shown.
I wonder if there is any plug-ins or methods can achieve it?
Thanks for any suggestion

Hand Sketch Lines Tracing.3dm (3.6 MB)
Hand Sketch Lines Tracing.gh (17.1 KB)

Hi @Jack_Zeng, you might try the Vectorize PlugIn:

_
c.

Thanks for your quick reply, clement. I have tried the Vectorize plug-in, it is quite nice, but seems it is doing the similar thing as Rooster did… It is also tracing the color boundary. I am curious if it can be set to trace the hand sketch as single lines, rather than double lines.
Or maybe it is right to trace the color boundary for the first step, but need another magic to turn the boundary to be single lines/curves?


I just found that there is a similar discussion as this link

Seems larch has try a few tools and eventually found that AI is the best.
But I think it would be great that we can have a better solution within Rhino.

Hi @Jack_Zeng, i know the problem, it is not possible in PoTrace (which is the code behind Rooster and the Vectorize PlugIn) to trace only contours. I guess PoTrace works best for comic like images with color fills.

To get what you want from a pure line drawing, you would use the interactive trace in AI, enable the “Contours” checkbox and disable the “Surfaces” checkbox in the trace options. Then you can play with the value for contour thickness.

_
c.

I see, thanks for the information, I will try with AI.

This is not an universal solution, i think @laurent_delrieu posted a c# code weeks ago to trace images

trace pixels.gh (11.5 KB)

Yes it is there

then some smoothing

2 Likes

Wow, cool~ it looks really good! Thanks Seghier and Laurent!

Hi Seghier,


I have try your script with another hand sketch, it works quite well! thanks very much.
But I realize there is a tiny issue there. I think the GhPython component is trying to break the polyline when sample points’ distance exceed a given value(am I right?). But for some reason it doesn’t break in my case…Am I missing something? I have try to make the t value smaller but it still doesn’t break…
Whether there is an alternative way to let GH know where to break the curve?


01.trace pixels.3dm (185.8 KB)
01.trace pixels.gh (232.4 KB)

You can follow these steps, and as i said before this is not an universal solution, it’s better if you use script of Laurent or a plugin.
And use an image with clear black color to get better result.

And sometimes you need to change this value , you can add y input to control it.

image

01.trace pixels.gh (222.9 KB)

I see, thanks Seghier

Hi Laurent, thanks for the sharing, I have just try your script on a few hand sketches, it is really cool~!!
But I found that in some case it doesn’t read some curves. I wonder if there is any parameter within the C# script that I can adjust to let it read the other curves?


I also found that it only read the black curves, is it possible for me to adjust some parameter/value to let it read the colorful curves as well?

Many thanks

Hello
yes it is possible, there is a limit brightness to transform an image to boolean so, it is possible to change the hard coded value to something different than 0.3.
image
image_thinner_LEGACY.gh (14.6 KB)

There are surely many things that can be added, filter by color …

Hi Laurent, thanks for your prompt reply.
When I open your script, it looks like there is something missing, do I need to install some specific plugin or because you are using a newer verson of Rhino7? Mine is sr14.
Or because there is some user object I don’t have?


After I connect those components together, it seems like there is something missing after the 2nd C# component.

I guess it is trying to tindy up the curves and make them smooth?

The error is just due to the fact that Grasshopper is seeking for an image that is on my computer.
You don’t need other libraries or plugin. I just added in C#
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
which are standard.

You don’t need right component. It is a topology component (like sandbox plugin). But yes I have done for my own use some tools to extract polyline from a network of lines. Then I can smooth them. But there are others ways (see the links above).

Thanks Laurent, will have a look at the Sandbox tool