How to apply 2D active contours (snakes) in 3D image? - matlab

I am trying to apply a snake method on a 3D image with no sucess. To my understanding, MATLAB's "activecontours" can be applied to 3D images but it seems that it fits a surface (balloon) into an object, instead of a single contour (snake). Or at least it seems to repeat the seed contour slice by slice, instead of fitting a single countour into a 3D object, because the end result is the whole 3D image segmented. I am looking for an active contour that has 3D awareness, as suggested by the following figure:
If the seed contour is the blue contour (slightly in perspective as to see it is a contour), I want the final snake to be the green one, as it fits the closest and easiest edge, instead of the red one, which would happen if I simply applied a 2D snake onto a slice of the 3D image coplanar with the seed contour. Thanks for your time!

Related

How to transform a non-planar surface on a plane using a pair of 2D and 3D control points?

I have a set of control point pairs. One part of the pair is in world coordinates (3D). The other one is in pixel corrdinates of the image (2D).
My goal is to transform a surface you can see in this image onto a flat plane. The problem is that the surface is not perfectly flat, it kinda looks like a ribbon. Otherwise I could have used OpenCV's getPerspectiveTransform() or Matlab's fitgeotrans().
I know that I can use OpenCV's solvePnP() or Matlab's estimateWorldCameraPose() to get the pose of the camera. The camera matrix is known and the image is rectified. But what is the next step then? How can I transform my ribbon shaped surface onto a flat plane, i.e. get an orthographic top view? That is the step, I'm stuck on.

Crop 3D Mesh with plane Cut in Matlab

I have made 3D analysis code and I want to split or crop 3D mesh into 2 parts with 2D plane, what i expected: the final result I need is to find out what are the nodes on the left side and the right side, what you see on the image below is the nodes of the 3D object (bumpy), Do you know what method or library I need to use to solve this problem?
my problem
Here is my data structure from the 2D plane:
Column 1: Face
Column 2: X coordinate
Column 3: Y coordinate
column 4: Z coordinate
Column 5: Finite Element Value
data structure
.
The data structure from the 3D mesh is containing the same data as the table above, Thanks so much!
We can know the plane XYZ Coordinates, so I tried to find by using <= to find the axis value is larger or smaller than the plane coordinates:
find x,y,z 3D model coordinate is smaller than x,y,z cut plane coordinate
[r] = find((Name_OT(:,1)>=x) & (Name_OT(:,2)>=y) & Name_OT(:,3)>=z);
the blue line is the plane, and the coloured one is the result from my code, the ideal result is the coloured nodes full, but what happened here the colour node has a big hole or gap
not good result
You need to first decide whether you want to segment your data by a (linear) plane or not. If you prefer to keep a curved surface, please follow my earlier comment and edit your question.
To get a plane fit to the data for your cut, you can use fit.
Base on the plane, you can get a normal vector of the plane. That is reading coefficients of fit results and is in the documentation. Using that normal vector, you can rotate all your data so that the plane is normal to z axis. The rotation is matrix multiplication. From there, you can use logical indexing to segment your data set.
You can ofc also get the normal component of the data points relative to the plane cut and decide on a direction that way. You still need fit. From that point, it's basic matrix manipulation. An nx1 vector can multiply a 1xn vector in Matlab. So projectors can also be constructed from basic matrix manipulation. At a glance, this method is computationally inefficient.

Matching RGB image with point cloud

I have an RGB image and a point cloud acquired by LIDAR.
In the RGB image I detect a feature, let's say a circle.
I want to use this circle as a ROI in my 3d point cloud.
How can I do that? I was thinking to produce a 3d point cloud from the RGB image through the camera parameters and then match the 2 with icp algorithm.
The problem's that on the moment I produce the point cloud from the 2D image, my coordinates system change, so I don't know anymore the position of my circle.
To perform 3d reconstruction I use triangulateMultiview function
I was thinking to produce a 3d point cloud from the RGB image through the camera parameters and then match the 2 with icp algorithm.
-> this would not work and not efficient.
Actually, there is a much better way. Assuming that you know the extrinsic between the camera and lidar, any circle(or ellipse) on the image can be extended into a 3d cone using the camera intrinsic and by selecting the points within the cone you can do the ROI operation.
Let's say you can define an ellipse on your image plane by detecting and finding the parameters of an ellipse equation. The ellipse equation can be extended into the quadric(cone) equation which representing the 3D cone. Now the only thing left is testing if your 3d point is within the cone by putting the cone equation.
This is a mathematically little bit complicated problem if you are not comfortable with camera model or quadric equation.

matlab: How to get textured using triangulation points in 3d reconstruction

I am working on 3d Reconstruction from two views. Till now I have got Fundamental matrix, Essential matrix and Triangulation Points. After this stage, how do I go forward to obtain textured image from the input image? and save those results in VRML model?
Are your cameras calibrated? If so, then you can rectify the images, and get a dense reconstruction. You can then plot the points using the colors from the RGB image. See this example.

Minimizing area of a triangle containing data points in 3D plane

I have a set of data in 3D which are in the same plane. I have a Triangle containing those data points in the same plane. But the Area of the Triangle is much larger. I want to find the smallest area triangle (co-ordinate of its 3 points) containing all the data point inside it. There are some concepts available for 2D data points, but I need to find this in 3D dimension.
It looks like Matlab has a function for this, convhull. You want to find the convex hull of the data set. http://www.mathworks.com/help/matlab/ref/convhull.html This function works for points in 2d or 3d space.