2

I want to create a 3D geometry of the following image. enter image description here

I could find ways of generating centerlines using image processing tools in Mathematica. But I am not sure how to generate 3D geometry from the skeleton.

enter image description here

Could someone suggest CAD software that can be used to create 3D geometry from centerline image?

Natasha
  • 1,111
  • 5
  • 28
  • 66
  • 1
    The relatively new (*v11.3*), and experimental, function `ImageGraphics` will vectorise that image. You could then pick the line coordinates you want out of the `FullForm` of the resulting graphic. – High Performance Mark Jan 04 '20 at 14:47
  • @HighPerformanceMark I am installing the latest version right away. Is it also possible to pick the coordinates of the contours from the first image using `ImageGraphics`? Or, let's say I have the line coordinates. Could you please suggest how to proceed and create a 3D geometry? – Natasha Jan 04 '20 at 15:07
  • 2
    How do you want to create 3D geometry from Flatland ? –  Jan 04 '20 at 15:18
  • @YvesDaoust I'm sorry, I don't have the expertise in this field. But I am trying understand whether the coordinates from the centerline can be used to create a 3D geometry using the extrude options in CAD softwares – Natasha Jan 04 '20 at 15:24
  • Any CAD package could do a sweep of a profile along the centerlines. – John Alexiou Jan 04 '20 at 15:29
  • 1
    "extrude" was the missing information. –  Jan 04 '20 at 15:43
  • 1
    Yes, `ImageGraphics` will pick out the coordinates of the contours from the first image. – High Performance Mark Jan 04 '20 at 17:16

2 Answers2

2
  1. Take centerline data points and apply smoothing to remove any wavyness
  2. Fit cubic splines about the data
  3. Relax the cubic splines by smoothing the 2nd derivatives
  4. Import the splines curves into CAD
  5. Extrude/Sweep the desired profile (circle, rectangle, .. ) along the curves.
  6. Join the ends with spheres for a smooth transition.
John Alexiou
  • 28,472
  • 11
  • 77
  • 133
  • Many thanks for the response. Could you please explain whether data points in your comment refers to the coordinates of the contours from the second image? Also, could you please suggest a CAD software. I am completely new to this. And can we specity a diameter while using sweep? – Natasha Jan 04 '20 at 15:42
  • Can I simply export the image in vector format after smoothing? Look like there are vector graphics formats that can be directly imported in AutoCAD. I couldn't understand why splines have to be fit. – Natasha Jan 05 '20 at 12:34
  • You can try, but the point would be to reduce the control points from the thousands down to less than 100 in order to produce a reasonably smooth result. A small kink in the centerline results in a big problem as a 3D solid. – John Alexiou Jan 05 '20 at 15:12
  • Thanks a lot for the response. I understand why it is important to smooth. I tried to smooth my actual image in Mathematica, please find the output [here](https://github.com/DeepaMahm/misc/blob/master/smooth.png). Following this, I tried to vectorize the image to obtain the x,y coordinates vector = ImageGraphics[smoothed_image]. But the resulting [ouput](https://github.com/DeepaMahm/misc/blob/master/vector.png) doesn't appear good. I am not sure how to procced wfrom here. I intend to obtain the coordinates of white pixels (after smoothing), use the coordinates to fit a spline. – Natasha Jan 05 '20 at 16:15
  • From the suggestions received [here](https://community.wolfram.com/groups/-/m/t/1853175) (using BeizerCurve command in Mathematica which fits a cubic polynomial by default, I could obatin [this](https://github.com/DeepaMahm/misc/blob/master/TourLines1.png) image. Could you please suggest how this can be imported in CAD? – Natasha Jan 06 '20 at 14:43
  • That is a nice smooth centerline. "How can this be imported?" So you are asking how to export the Bezier curves from Mathematica into a CAD file like .dxf or .dwg. [Read online](https://www.cadtutor.net/forum/topic/59683-bezier-curves-vs-segmented-curves/) on the topic, check the documentation of your CAD package (is it AutoCAD?) or [edit] the question with what steps you have achieved so far and ask how to go between `Mathematica` and `AutoCAD`. Then you will get some real answers here. Please make sure you change the title also. – John Alexiou Jan 06 '20 at 15:27
2

There are many different ways to generate 3D geometry from 2-dimensional or planar objects such as those shown in your image, depending on the result that you desire.

For example, given an arbitrary centreline:

enter image description here

You can extrude the centreline perpendicular to the plane of the geometry to yield an extruded 3D solid:

enter image description here

Alternatively, you can first offset the centreline to both sides in the same plane by a given amount:

enter image description here

...and then extrude both offsets perpendicular to the plane, before performing a boolean operation to subtract the central solid from the outer solid, yielding the following result:

enter image description here

But note that you are not limited to an extrusion operation perpendicular to the plane of the centreline, for example, you could alternatively construct an arbitrary closed profile, such as the circle in the following example:

enter image description here

...and then sweep the profile along the centreline to obtain a 3D solid:

enter image description here

Finally, you could even revolve the centreline about an arbitrary axis, by an arbitrary angle, to yield a 3D solid such as the following demonstrates:

enter image description here

All of the above were generated using AutoCAD.

Lee Mac
  • 15,615
  • 6
  • 32
  • 80
  • The second last image is interesting. I'd like to know if centerline image can be imported in AutoCAD. Or is it recommended to import a coordinate file (of the centerline image)? – Natasha Jan 05 '20 at 07:13
  • The centerline will need to exist as a native AutoCAD object (e.g. for the above examples, the centreline is a 2D Lightweight Polyline object). Given a set of vertex coordinates, you can generate these objects using any of the APIs exposed by AutoCAD (LISP, .NET, ARX), or you could write a DXF file directly using tools such as the ezdxf Python package. – Lee Mac Jan 05 '20 at 11:36
  • Sorry, I am a little confused over what has been suggested in the below comment. It says `import spline curves into CAD`. So I have been trying to smooth the curves in the second image posted in the original post; fit a cubic spline to the [x,y] vertex coordinates of the white pixels in the binary image and then import it. But I'm not sure how to import the splines. Is it a good idea to import the spline curves? – Natasha Jan 05 '20 at 12:08
  • I think I can use the suggestion DXF export option in Mathematica (mentioned in the solution posted [here](https://mathematica.stackexchange.com/a/183190/58343)) . But I don't really understand the need to fit splines here – Natasha Jan 05 '20 at 12:31
  • Whilst splines will obviously yield a smoother result and smaller file sizes, you don't necessarily have to generate 3D geometry from splines, as you can use 2D polylines with linear or arc segments (per my example), or a combination of lines & arcs. – Lee Mac Jan 05 '20 at 12:41