Grasshopper

algorithmic modeling for Rhino

I was trying to figure out how to trace an image directly by grasshopper.

It is really time consuming if I manually trace a complicated image using the bitmap method.

If possible can anyone post the grasshopper file for tracing image.It doesn't need to be very accurate.

There had been a discussion on it before but it did not give me the output as I saw.There might be some error in the  file I created.

Could anyone post the working grasshopper file for it?

Thanks in advance..

Views: 26265

Attachments:

Replies to This Discussion

Hi Shubham,

Your image looks as a perfect candidate for potrace ...(raster to vector soft)

Sorry, I'm of no help at all for grasshopper ...

Cheers

Coluld you please attach the grasshopper file you used for it.
Thankyou for your prompt reply.
It will be useless now
First You have to upload Peacock plugin, on food4rhino I think
Put vectorize component on your canvas
The path of your image on a panel and change res and str if needed
That s all!

potrace seems good, whitout changing the image just copying in bmp and using potrace 

with these line command

potrace 1.bmp -o u1.svg -s -u 1
potrace 1.bmp -o u10.svg -s -u 10

potrace 1.bmp -o u10.dxf -b dxf -u 10 

DXF in rhino

Attachments:

What's potrace? Good results indeed. 

I see: http://potrace.sourceforge.net/

They are using a sort of look-a-head strategy with smarts, not smoothing:

http://potrace.sourceforge.net/potrace.pdf

Thank you for the reply.

I wanted to ask how to get potrace working for rhino.

I downloaded the 64-bit zip file from sourcefourge and extracted it in rhino plugins but it says unknown command .

Please help.

Thank you in advance.

Potrace is not a plugin for Rhino it is an executable with command lines. So here are the steps I used : 

  1. Unzip potrace zip
  2. Put it somewhere on your disk, me I named a folder "c:\potrace" it is more easy to call program when they have a short folder name
  3. put your image in format BMP on this folder
  4. make a file with an extension ".bat".
  5. Open this file with atext editor (notepad++ for me, but notepad is enough). 
  6. Copy in this file the line "potrace yourfile.bmp -o yourfile.dxf -b dxf -u 10 " whithout quotes
  7. Save the file
  8. Double click on file.bat so it is executed (it execute the line command)
  9. Open "yourfile.dxf" with Rhino

Nik method is more simple you have to specify files (potrace.exe and yourfile.bmp) but you need GHPython (http://www.food4rhino.com/project/ghpython)

Hope it helps

Thanks a lot.
It worked perfectly.

Wanted to ask if I could use GHPython as a plugin for inbuilt rhino iron python.

Would it be easier or its better to use normal python environment?

Again a thank you for all the help.
I prefer working on the Grasshopper canvas since I can prototype solutions and post-process output before having to hard code it with Rhinocommon help file frustrations, and I enjoy the Grasshopper preview that I can often turn meshing off for when things are going slow debugging and tweaking.

No, I wouldn't somehow link native Rhino Python editing system to Grasshopper Python, both which access IronPython, but would have to "port" the Grasshopper version to Rhino itself, and then you lose the free Grasshopper preview so would have to add code to push the created geometry stored in Python lists into Rhino, like a baking step in Grasshopper. Fairly straightforward boilerplate technique.

I'm barely familiar with the native Rhino Python system though and am not sure how to store or initiate Python as commands, nor how to share a script and associated command name assignments with others. I mean how do scripts install and *stay* installed unless you re-save your various unit template Rhino files, since a script isn't a plug-in? Is there a separate scripts directory and scripts menu or something?

Educate me if you want help on this.

There's a way to have grand control over the result using Photoshop. Change to grayscale, then up the resolution way up and Gaussian blur to very effectively smooth any pixelation. Then use the Wand (not contiguous) to select the black and make a work path from selection in the Paths palette and the secret is to use the Alt key to bring up the Tolerance setting in order to set it small.

Original after using the Levels command white eyedropper and clicking on gray to make the watermark crap white too:

Upping the resolution by 3X:

Gaussian blurring a whopping six pixels:

Using Curves to tweak the result, beefing up details, then use Threshold to see result. Now create a Work Path from the selection, crucially using the Alt key to also bring up the Tolerance setting for the work path, using 0.5 pixels to make it not be crude:

Now you can export the path to Illustrator that Rhino can open:

The point of all this is that it gives you full control over the result. In haste I've lost some detail, but I'm also able to create smooth tracings even from pixelated artwork. You can see I'm already pulling a lot more detail than Laurent's example:

Even though the image is pixelated, the nature of these type of bezier curve artwork means the information of the original is still there as long as you average the pixel outline using blur.

Being a bit more careful with my initial Curves tweaking, along with Threshold use, here are the overly complex 0.5 pixel Tolerance Photoshop selection work paths, and a much simpler one with 1.0 Tolerance setting, turned into shaded surfaces using PlanarSrf in Rhino:

Enclosed is the final 1.0 pixel tolerance Illustrator file export from Photoshop, which is 1/10 the size of the 0.5 tolerance one.

My brother was an Adobe Press book writer and Photoshop trainer, and I invented this method in the late 1990s but it's no longer a trade secret.


The blurring then threshold back to black adds poor man's edge awareness.

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service