Image to 3D
June 28, 2013 07:50PM
Im trying to get a 3d object out of a JPEG. I'm using Openscad and Inkscape. I've tried exporting it from Inkscape as a DXF file and importing it into Openscad so I can linear extrude it, but it doesnt appear to be very compatible with them. Is there some other way to do this? I've attached a picture. Thanks!
Attachments:
open | download - hotrod.JPG (81.4 KB)
Re: Image to 3D
June 28, 2013 10:06PM
Hello,

You are aware that DXF is a vector format? Meaning it consists of curves and/or lines. A raster (or bitmap) image such as JPEG cannot simply be imported into Inkscape and exported to DXF, it won't work, as it will still be a raster image. You need to vectorize it.

See the Inkscape wiki page on how to do that: [wiki.inkscape.org]

I just tried with your hotrod image (cool shape by the way!) and it seems to work pretty well.

First thing is to edit your jpeg first, crop it in your image editor (Gimp, Photoshop...) to keep only one shape, as your jpeg has 5 of them. I saved one jpeg with a filled hotrod, and one with an outline-only hotrod.

I found that the filled one worked best. In the Trace Bitmap parameters, Brightness cutoff didn't work well, and Edge detection seemed to, but produced a double outline rather than a single one. What worked best was Multiple scans/2 passes, in Greys (see capture). But some processing was required afterward. First I deleted the bitmap image and kept only the generated vector object. I right-clicked on it and chose "Ungroup". I got two objects, the filled black hotrod, and a white rectangle (when I hovered over it I could only see the selection rectangle). I deleted the white rectangle. Then I selected the hotod and hit Ctrl+Shift_F to get the Fill and Stroke dialog; in the Fill tab, I clicked on "no paint" to get rid of the black filling, then in the Stroke paint tab, I clicked on "Flat color" to show the outline. Then I saved as SVG, and as DXF.

I do not use OpenSCAD as my brain is not wired for it. winking smiley I use FreeCAD which has a complete GUI my non-programmer brain can understand. It can import SVG very well. The DXF was a no-go in FreeCAD because it is made out of spline curves and the DXF importer does not support splines. LibreCAD could open the DXF fine BTW. No idea if OpenSCAD could import it.

So in FreeCAD I opened the SVG and got a series of "path" objects. I got the large rectangle again and deleted it. I was left with a series of paths which represent all the closed outlines making the hotrod. To extrude this I needed to convert all the paths to faces using the Draft Upgrade tool. Then I had to cut the larger face of the hotrod with all the other faces. For that I used the Draft Downgrade tool, one at a time. When I finally got the whole face cut with all the holes, I extruded it with the Part Extrude tool. It may sound tedious but it took me all of 5 minutes tops.

Hope this helps! smiling smiley
Attachments:
open | download - Inkscape_hotrod_trace_bitmap.png (60.5 KB)
open | download - FC_hotrod_01.png (160.3 KB)
open | download - FC_hotrod_02.png (158.6 KB)
open | download - hotrod.dxf (45.7 KB)
open | download - hotrod.fcstd (285.5 KB)
Re: Image to 3D
June 29, 2013 03:47AM
That's a nice method, NormandC, I hadn't seen one using FreeCAD before. There is some discussion in this thread about how to do it with OpenSCAD. There are several ways...
Re: Image to 3D
June 29, 2013 03:49AM
No, OpenSCAD can't handle spline curves either BUT Inkscape can convert those spline curves to line segments.
There are a number of tutorials on how to do this.
Then it is simply a two liner to linear extrude a DXF file in OpenSCAD.


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: Image to 3D
June 29, 2013 04:21AM
Quote
MattMoses
That's a nice method, NormandC, I hadn't seen one using FreeCAD before.

Thanks. I'm new in the RepRap community and have noticed that FreeCAD is not very well known around here. I hope I can remedy to this situation in some limited way. winking smiley

Quote
rhmorrison
Inkscape can convert those spline curves to line segments.

Except you loose much quality when converting from spline curves to line segments. Your outline will be jagged. Granted it might not matter for 3D printing but I'm kind of a purist. Also if you ever want to have it laser cut in another material (steel, aluminum...) it won't look good.

The nice thing with FreeCAD is it has good support for SVG now so the DXF conversion from Inkscape is unnecessary. DXF is a closed-source, proprietary and undocumented format after R2000, which is why support on open source software is lacking. For that reason I avoid this format as much as possible.

BTW I was really impressed by that Inkscape trace bitmap function, which I tried for the first time. I remember having much trouble with a product aiming for the same purpose one of my former employers bought 15 years ago from Autodesk which was a companion to AutoCAD. It was so utter cr*p we quickly gave up on it.

Edited 1 time(s). Last edit at 06/29/2013 04:23AM by NormandC.
Re: Image to 3D
June 29, 2013 06:25AM
Quote
NormandC
Except you loose much quality when converting from spline curves to line segments. Your outline will be jagged. Granted it might not matter for 3D printing but I'm kind of a purist. Also if you ever want to have it laser cut in another material (steel, aluminum...) it won't look good.

THAT is why when you follow the tutorial that you add additional points so that the quality is more than needed (at least for 3d printing which is what this forum is about). TRUE you will never get the same quality as when it is left as a spline.


Bob Morrison
Wörth am Rhein, Germany
"Luke, use the source!"
BLOG - PHOTOS - Thingiverse
Re: Image to 3D
June 29, 2013 04:46PM
Wow! You really outdid yourself NormandC! I havent got it to work in Openscad yet because of the spline thing, but if you say FreeCad supports SVG files then it sounds much easier to just do it that way. I'll give it a shot and keep you updated. Thanks for all your help guys!
Re: Image to 3D
June 29, 2013 05:02PM
Glad I could help Crussell, and don't hesitate to ask if you have questions about FreeCAD use.

Quote
rhmorrison
you add additional points so that the quality is more than needed (at least for 3d printing which is what this forum is about).

I for one prefer to keep my options open and have a design that's as "PURE" as possible without defects. You never know, even if like you say this forum is "only" about 3d printing.

It's easy to take a good CAD surface model and DEGRADE it (yup that's what it is) to an STL. Not so the other way around.

Using all caps on some words just for the fun of it. winking smiley

Edited 1 time(s). Last edit at 06/29/2013 05:05PM by NormandC.
Re: Image to 3D
July 01, 2013 07:34PM
Well I have it all figured out in Openscad, however I did not figure out how to do it with FreeCad (I didnt spend much time with it either). I will try to set aside some time to figure it out as it looks like FreeCad has alot of promising features. Thanks again for all the help!
Re: Image to 3D
July 02, 2013 01:26PM
I posted a tutorial a while ago how to convert a picture to STL using Inkscape and Blender. Hope this can help

[www.youtube.com]
Sorry, only registered users may post in this forum.

Click here to login