How can I convert a series of 2D images (grayscale) into a 3D image?

I have collected a series of images from a line laser hitting a rotating metal sphere with an industrial camera, and processed them accordingly, now keeping a series of images of the outline of the metal sphere (grayscale image). I need to convert this series of 2D images into a 3D image. How do I do this? How do I write the code?

 Risposta accettata

You can use cat
image3d = cat(3, image1, image2, image3, image4, image5); % etc.
Or you can do in a loop
image3d = cat(3, image3d, thisImage);
where this image is that particular image, for example read in from a disk file or cell array or whatever.

9 Commenti

Thanks a lot, Sir! Do I need to consider the conversion between 2D and 3D coordinates? That is, the conversion from pixel to world coordinate system?
If you're dealing in pixels, then no. If you want to deal in "real world coordinates" then yes. You'd need to know the real world spacing between pixels laterally (in x and y) and the separation between slices/planes in 3-D. I don't know why you want a 3-D image though. It's not like you have a CT or MRI image.
See attached spatial calibration demo.
Your third dimension is time. You might potentially need some conversion if the time samples are not uniform.
This is because I want to generate a 3D image and estimate the radius of the metal sphere in the resulting image.
If it's a sphere, then if you know the angle that the line is hitting it, you can figure out the radius. It's just simple trigonometry. If you don't know the angle, then you can get a fair estimate of the radius by fitting all the curves you detect to a circle and take the largest one. Then after that you can render a model of the sphere using sphere
But my task requires that I first generate a 3D point cloud image, but I don't know exactly which method to use? After that I need to then calculate the radius of the 3D point cloud image.
@Sterne_17 it's simple geometry. Imagine longitude lines on a globe. Let's call the angle of the longitude line phi with phi=0 where the line is along the far left edge of the sphere. If the line moved to a different longitude line in the middle of the sphere, the x values (only) would be multiplied by cos(phi). So you can divide the x values by cos(phi) to get what they are if they were at the left edge and then you can get the radius by fitting a circle to those points using the attached function. The z value (distance out of the plane) is sin(phi) * radius if you wanted that for some reason. If you don't know phi, you can compute it if you assume that you have a point on the equator. The ratio of the leftmost x in a middle longitude to the very leftmost x when the line is along the far left side of the sphere (you can get both of those x from the image) is cos(phi) so take the arc cosine of the ratio of leftmost x to get the angle.
Sir, thank you very much. I will give it a try.
Hello sir @Image Analyst.
I am uploading in the attachment the code I used in this project and the image that was used as input, and the final image generated is an image in the 3D coordinate system where I can get the coordinates of the sets of spheres I want.
if I have already got the coordinates of some points on the sphere, I now need to fit a sphere with this function sphere and my goal is to find its radius, how can I do that?
Can you give me an example if you can, I don't really know how to write a complete program.
Thank you so much!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Image Processing and Computer Vision in Centro assistenza e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by