# How can I get a 3D model from a bunch of 2D photos?

I am a physics graduate student and I want to create some 3D models for my crystal samples. We have an X-ray diffractometer in our lab. It comes with a goniometer inside it, so basically I can take as many photos as needed from any angles. (I have included a gif animation made of 10 photos taken by the machine as an example below)

My problem is, given these 2D photos, am I able to construct 3D models for my crystals in AutoCAD or similar software so that I can determine angles, edge lengths and volume more precisely.

I am new to 3D printing section. I just thought maybe someone here has encountered with a similar problem. It would be very helpful if anyone could tell me any Github codes, MATLAB scripts, Mathematica scripts or software that can finish this kind of job. I can try to figure it out myself.

YES, it is possible to make a model from several shots, if you know the angle of rotation between the pictures.

most CAD programs allow to insert a picture, for example as backdrop or to trace it. We are interested in the later use:

We insert the picture, trace it in the picture's layer, then insert the next picture, rotated around the axis of rotation of the picture, and trace that. This we repeat again and again. The resulting cloud of outlines approximates the photographed body to a good degree.

There is a big caveat though: all photos must be in the same scale and distance, the rotation of the object has to be around one axis of the item itself (no wobble) and the rotation between the pictures has to be known quite exact. This principle is pretty much used by raster scanning by the way.

With a very hard contrast between the crystal and the backdrop, software might be able to automate the tracing process (for example use a white background and a black crystal and make sure no reflection hits the camera).

# Example using Fusion360

Let's assume I have a perfect crystal like this octahedron with two cut tips

To model this, we need at least a photo of the XZ and YZ shape (that is, 90° rotation to each other), which look like this:

But that shape would also match a double-cone! So we'll need some intermediary photos, in this case, the 45° shot that lies on the plane of (XY-diagonal)Z Plane

As you see, the more outlines you have, the more detailed the pseudo-body becomes - it is just a gathering of vertices and lines yet though! But, we can take 3 points and create a construction area on these, then draw the face to merge all points on these faces...

Now, we turn these construction faces into modeling faces, then create a too large object and cut out the whole thing out...

The whole workflow looked like this for 4 pictures (0°, 45°, 90°, 135°)

The actual f3D design file is here.

• Hi Trish, thank you for your advice! I have downloaded Auto CAD and 3ds max (3ds max seems to match my goal perfectly when I was browsing Autodesk product page) and I am currently working on it. I will update this page when I have figured it out. Commented Dec 29, 2018 at 2:56
• I found a very useful tutorial youtube.com/watch?v=GmIkOJmBv_c. In this tutorial two photos of a fork were imported into AutoCAD. First the cross sections on two orthogonal directions were traced from the raster images. Then, extend the cross section into two columns. Finally intersect two columns so a nice 3D fork is presented (14:30 in the video). My case is similar but more complicated. I probably need like 6 photos. I have to align photos along the rotation axis and create 6 columns with their cross sections traced from the photos. Then I finally intersect them. Am I right? Commented Dec 29, 2018 at 4:41
• pretty much - the more photos you take, the more of the imperfections you get. automatic rastering software uses several 100 photos Commented Dec 29, 2018 at 9:39
• @Mr.Octopus I added a simple example using Fusion 360, but most programs should allow to follow a similar workflow Commented Dec 29, 2018 at 13:48

Inspired by the answer given by @Trish and the following YouTube video, I finally worked out the way to reconstruct the 3D crystal model in AutoCAD.

1. Import 6 images into AutoCAD. The photos are taken from 6 different angles with 30 degrees separation.

2. Draw 6 lines of length 100 along Y axis in the XY plane.

3. Use ALINE command to align the rotation axis in the photos to the added vertical lines.

4. Use SCALE command to rescale all 6 photos into a uniform size.

5. Use POLYLINE command to trace the cross sections from 6 raster images.

6. Use 3DROTATE command to rotate 6 images and the corresponding rotation axes and traced cross sections along Y axis. The first picture was rotated 75 degrees clockwise when viewed along the +Y axis, the second 45 degrees, the third 15 degrees, the fourth -15 degrees... (Tips: The rotation gizmo will only show in a 3D view. If you didn't see the gizmo, drag the view cube on the right-top to change the view point and try again.) (view from Y axis) (view from Z axis)

7. Use 3DMOVE command to move 6 images so that the rotation axis of each image is aligned in a same circle on the YZ plane. (You would need a little bit calculation to finish this step) (view from Y axis) (view from Z axis)

8. Use EXTRUDE command to extrude 6 cross sections into 6 cylinders, the height of each cylinder should be long enough so that 6 cylinders will intersect.

9. Use INTERSECT command to get the intersected part from 6 cylinders, this would be the wanted crystal model.

• the more pictures you use, the better the results will be, but it is a good workflow if it works for you Commented Jan 7, 2019 at 1:09
• Yes, but you will also need more time. For me, a model based on 6 photos is a good balance between the quality and the time. I am very grateful to your answer, though I didn't use the Fusion360 in the end. Your answer inspired me to a great extent. Commented Jan 10, 2019 at 18:46

You may want to do a search for "photogrammetry". This is software that uses many photos to build a 3D model. Dr. Falkingham did a good review of free software on his blog:

His conclusion that works very well for me uses COLMAP to take the photos and build a point cloud, then OpenMVS to build and texture a mesh from the point cloud.

I have not used many commercial packages, but Pix4D has worked very well for me.

https://www.pix4d.com/

I hope that gets you started.

• Thank you, UrQuan3! You just offered so many open-source softwares. I will test them and post another learning notes if I find any software being useful. Commented Jan 10, 2019 at 19:08