2D projection of a 3D model - matlab

I have a question about Matlab. I have a three dimensional model (*.stl) in Matlab and I want to create some kind of a two dimensional projection. The attached image shows the visualisation of the model by using the patch command. I want to create a two dimensional image/plot from this view on the three dimensional model. This two dimensional projection should have an own x-y-coordinate system, is that possible?
3D view
New coordinate system

Related

Area of intersection of connected components

I am doing a segmentation task using MATLAB. To analyze the performance of my algorithm, I need the area of intersection of each connected component in both images.
In what way are the connected components labelled in an image? Also, does PixelIdxList list all the linear indices of points that are a part of the connected component?
In what way are the connected components labelled in an image?
bwconncomp discovers the connected components by either using 4-(or 8)-connected neighborhood for 2D images or 6-(18, 26)-connected neighborhood for 3D images. Labels are enumerated starting from the left-top corner in 2D and in 3D (first slice).
Also, does PixelIdxList list all the linear indices of points that are a part of the connected component?
Yes. So, once both images are labelled, you can use intersect to find intersection between different labels. Also, you might want to read about Jaccard index.

How to interpolate scattered data on a predefined 3D surface in Matlab?

I need to interpolate scattered data on a model represented by a 3D surface in Matlab. I tried it using "scatteredInterpolant", but the results were quite bad. This function only allows to specify the query points but not the 'ConnectivityList' because internally it performs its own Delaunay triangulation from the specified point set. However, I perfectly know not only the points but also the 'ConnectivityList', so I can create a Matlab 'triangulation representation' using "triangulation".
So my question is the following. Is there any way to give a predefined 'triangulation' to "scatteredInterpolant"? If it is not possible, is there any other Maltab function or class able to perform data interpolation on a previously triangulated 3D surface instead of performing its own triangulation from the query points?

Generate 3D surface from scattered or data points

Can anyone tell me how to generate a 3D surface model like CAD in Matlab ?
1.Input: Input is a collection of points with (x,y,z) where surface is present for an object(I'm using this for a 3D scanner where my inputs are (x,y,z) of surface)
2.Points should be displayed as a surface using some smooth interpolation.
3.More like surface generation from data points.
Thanks you.
In order to plot surfaces, you can use patch function. However, you need along with the points the faces information. In patch a surface consists of polygons that is specified using 3 point, which is the face information.
1
Since it seems like you will be inputting discrete points located on the surface of the object, you will first want to create a Nonconvex Polygon based on the data using Matlab's boundary function.
https://www.mathworks.com/help/matlab/ref/boundary.html
You can then use the trimesh function to create the figure
This question shows the input data and what was produced using this method: How do I create a 3D polygon/mesh over data points?

Multiview 3D reconstruction

I tried to do 3D reconstruction of multiple views by using multiview essential matrices to construct 3D view of each image view of object. However, I am shocked that the 3D points I found are all on about XY plane. I guess that it maybe regarding to the large value of essential matrix or weird number of projection matrix estimated. What are the suggestions for me to compute precise 3D points coordinate?
If you have the Computer Vision System Toolbox, this example may be helpful.

Getting 3D image from 2D image

I am doing a project in Matlab on Image processing
Is there any possibility of getting 3d image from 2d image?
If you have multiple images of the same object and the position of the camera when the picure was taken, then it is possible, but still not easy. You can find two such datasets and links to relevant articles here: http://vision.middlebury.edu/mview/
a 3d image would be a projection from 4d (and to show one of those you've got to project down to 2d) and most images that can be displayed on computer or in a picture frame are 2d projections of 3d objects due to this projection which in fact selects a slice of the higher dimensional space it doesn't contain the information needed to invert that projection and get back to 3d from a 2d image
but if you have sufficient sampling of the space it is possible to reconstruct a 3d object from 2d images of it but i don't know of any simple ways to do this
You can't do this without supporting data such as multiple 2D images describing the same 3D object. You then need to figure out the perspectives from which each image was taken, reconcile those into real space, and generate your points using a method such as intersection of stereo lines through each image plane onto the same physical coordinate.
You can also attempt a superpixel approach by exploiting lighting data within a single image, though these methods aren't as accurate.
This is a big field.
The Radon transform is used in tomography applications to reconstruct 3D representations (i.e.images) from many 2D projections of the 3D "scene". This transform and its inverse are present in the image processing toolbox of Matlab. You might want to have a look at it.
Hope this helps.
A.