[Plugin] Pic2Shape - v1.2b - 13 Oct 25 (Image Contouring)
-
Feel free to cannibalize parts of my ImageTrimmer, which smooths jaggedness...
You pass the edges' collected vertex points, and set an epsilon factor... thus.
### epsilon is a float perhaps < 0.2 ### perhaps it's set by the user ? experiment for best default... ### the vertices are collected from the current outline[s] points = vertices.collect{|v| v.position } simplified_curve = douglas_peucker(points, epsilon) ### might return [] simplified_curve << simplified_curve[0] if simplified_curve[0] ### so it 'loops' edges = some_entities.add_curve(simplified_curve) if simplified_curve[0] ### sort out edges' faces, hide edges etc as desired
the 'douglas_peucker()' method is this...
### http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm ### http://en.wiki.mcneel.com/default.aspx/McNeel/ PolylineSimplification.html ### def douglas_peucker(points, epsilon) ### return points if points.length < 3 ### Find the point with the maximum distance dmax = 0 index = 0 line = [points.first, points.last] 1.upto(points.length - 2) { |i| d = points[i].distance_to_line(line) if d > dmax index = i dmax = d end } ### If max distance is greater than epsilon, recursively simplify result = [] if dmax >= epsilon ### Recursive call recResults1 = ImageTrimmer.douglas_peucker(points[0..index], epsilon) recResults2 = ImageTrimmer.douglas_peucker(points[index...points.length], epsilon) ### Build the result list result = recResults1[0...-1] + recResults2 else result = [points.first, points.last] end#if ### return result ### end #def
-
Thanks TIG.
Pic2Shape already includes a simplify method, more sophisticated that the Douglas Peucker algorithm.
The real issue is that the smooting is a matter of mixing local and global scale, but also boundaries of pixels, which itself is not always clean. -
it'd be interesting to process this fence in free inkscape for comparison
-
Please do it and report.
DXF conversion is likely to give better results.
-
I was about to try this extension out - using SketchUp 2025 Pro, but the extension doesn’t seem to process the image. Image size 155x50 mm / 300 pixel/inch.
After 10 minutes still at Initialization…
Is there any guideline on max/ recommended picture size?
I tried it with a smaller resolution image, but I still can not get through Initialization....
Thank you
-
update: I succeeded with the plugin, when I opened the image in a new file.
The original image was on a bent plane. I suppose that was the problem…
-
@kimga Are you going to to have trees with this amount of edges per leaf ) ?
-
-
Do you have the model for me to explore the issue.
-
I installed Fredo6 Pic2Shape but can not find it anywhere to use it. What gives?
-
@schramdesigns Have you met the requirements in the top post?
-
I installed this and cant find it to use it.
-
That suggests you either haven't installed Libfredo or you have not restarted SketchUp. But since you are omitting lots of info to help us understand fully its hard to say.
-
NEW RELEASE: Pic2Shape v1.2a - 13 Oct 25
Requirements
- LibFredo6: v15.2a or above
- Sketchup version: SU2018 and above
Pic2Shape 1.2a is a maintenance release including:
- Bug fixing
Home Page of Pic2Shape for information and Download.
-
NEW RELEASE: Pic2Shape v1.2b - 13 Oct 25
Requirements
- LibFredo6: v15.2a or above
- Sketchup version: SU2018 and above
Pic2Shape 1.2b is a maintenance release including:
- Bug fixing (one remaining from Pic2Shape v1.2a)
Home Page of Pic2Shape for information and Download.
Advertisement