Convert 2D image into 3D (to get the x y z coordinates of the image)

4 views (last 30 days)
I know there have been similar articles related to this but I am not sure if those articles can help me with what I am trying to do.
So I have a regular png 2D image which I want to convert into 3D image so that I can get the x y and z coordinates. Basically, I need those coordinates in order to calculate some volume.
What should be the appraoch to start this?
  2 Comments
Athul Prakash
Athul Prakash on 30 Oct 2020
Edited: Athul Prakash on 30 Oct 2020
I couldn't understand your question clearly. What do you mean by 3D image to 2D? Are you talking about the number of channels, i.e. converting from greyscale to color perhaps?
jahnavi s
jahnavi s on 28 Mar 2021
@Kajimusugura Hoshino, Sir i did u got answer for converting 2D image to 3D, canu please share how to do it if u have done it

Sign in to comment.

Answers (1)

drummer
drummer on 30 Oct 2020
Tecnically, with only one single 2D image, you cannot obtain a tridimensional image.
As you might know, a 2D image has [x, y] dimensions. You can see it by calling
size(yourPNGimageFile) % It will return a vector of two values (x and y)
The z dimension (that represents real data) come from a volumetric (3D) image.
>>size(brainScan) %example of volumetric image of x = 128, y = 128, z 256
ans =
128 128 256
if you pick
brainScan(:, :, 45) % It means you're taking all x, all y and a single slice of the volume (the 45th).
So the way around is possible: to get a 2D image out of a stack of slices in a 3D-image volume.
YOU CAN make a stack of your png 2D images. But it would not make sense, as it will be a stack of repeated images.
yourStack(:, :, 1) = yourPNGfile;
yourStack(:, :, 2) = yourPNGfile; % Then, you have your x, y and z coordinates.

Community Treasure Hunt

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

Start Hunting!