is it possible to convert 2d image into 3d binary image form?

i want to use 3d binary image for printing or sketching purpose. But i am not sure how to create the 3d binary image. please guide me through this.

8 Comments

Are you trying to stack a number of 2D binary images into a 3D binary image?
no. i want to convert only one 2d image into 3d binary image and then perform its printing.
OK, please tell us the Maths? Let say 2D Image is:
image=[2 4 6;5 6 10];
Tell us the Maths, How? So that we can help you to implement in MATLAB
Do the values in the 2D array represent height? And you want to voxelize? If so then do you want everything that is under the curve to be filled in, or do you only want a single sheet where the values are (as close as feasible) equal to the input values ?
i have read some papers about it. what i have percieved is i have to create a 3d mesh. or i have to create stl files. but i dont know which method is good and relatively easy. i am waiting for your kind responce.
@kalyan Acharya .. can't i take any 2d google image?
How is the Z value to be derived? And are you wanting only a surface or a filled volume ?
@Walter Roberson yes i have to use voxelization in order to show depth.. yes i want to show everything under curve because in the end i want to create a 3d image. but in binary form so that after performing printing one can easily see that its a 3d image not 2d.

Sign in to comment.

 Accepted Answer

h = surf(YourImageArray);
or more likely
h = surf(YourImageArray, 'edgecolor', 'none');
After that you would use https://www.mathworks.com/matlabcentral/fileexchange/4512-surf2stl . If you need x and y coordinates you can use 1:size(YourImageArray,2) for x and 1:size(YourImageArray,1) for y.

5 Comments

lets suppose i have jpg image. i have attached the image with this comment. can i apply surf2stl on the attached image? if yes then how?
You would apply surf2stl() to the result of the surf() call.
I would suggest that you use
rgbimage = imread('cube.jpg');
mask = find(rgbimage(:,:,2) > 128 & rgbimage(:,:,3) > 128); %detect white
YourImageArray = im2double(rgbimage);
%set all the white pixels to nan
[r,c,p] = size(rgbimage);
rc = r*c;
YourImageArray(0*rc + mask) = nan;
YourImageArray(1*rc + mask) = nan;
YourImageArray(2*rc + mask) = nan;
h = surf(YourImageArray, 'edgecolor', 'none');
thank you so much for your help. but i am still facing a small problem, after implementing your code i have recieved an error. its screenshot is attached to this coment.
please help me in removing this error.
The error message is misleading: what it is really complaining about is the YourImageArray being 3D.
h = surf(YourImageArray(:,:,1), 'edgecolor', 'none');
I suspect that the ragged edges you will see have to do with JPEG blurring of straight edges.
thankyou so much Mr Walter. it worked now.
i have one more question. but its not binary. As in the end i will be needing 3d binary image.Inorder to make it binary i have tried this.
surf2stl('test.stl',1,1,'binary');
but it is showing 0 facets. i dont know what does that mean and how to get 3d binary image from surf.
waiting for your responce.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!