# How to convert a binary 3d matrix to mesh.

25 Ansichten (letzte 30 Tage)
MG Poirot am 29 Apr. 2016
Kommentiert: Md Nurul Karim am 19 Nov. 2019
I have a 3D binary matrix with 1 being filled volume, and 0 being empty. For example I've added a representation of this matrix filled with a sphere but the matrix could also have been filled with irregular content.
I would like to construct a mesh from 3D binary matrix volume, how would I go about it?
I have come across the isosurf function, but I was not sure if it was applicable or how to get my data in the right format.
Thanks.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Mike Garrity am 29 Apr. 2016
Yes, I would think that isosurface is the first thing to try. Just give it the 3D array and an isolevel of 1/2. It'll use linear interpolation to put a surface down the middle of where the 1's and 0's meet.
[x,y,z] = ndgrid(-1:.05:1);
v = sqrt(x.^2+y.^2+z.^2) < .5;
isosurface(v,1/2)
As you can see, the result can be a little lumpy.
If you want your mesh to follow the grid without any interpolation, then you'll probably want a different approach.
##### 3 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Karima benzaid am 22 Apr. 2017
Hi,
I have a 3D binary grid of a canyon (obstacle=1, free-space=0). I would like to get something like this (with filled volume)
But, what I get when using isosurface(Map) is this
Am I missing something?
Thanks.
Xander May am 5 Jun. 2017
Karima, it would seem your 3D object does not have a 'Surface' anywhere besides what you are seeing. The ISOSURFACE function creates a mesh of the surface of an object, but because your object only has a surface where the interior walls of the canyon are, with other thigns extending out of the view window, that is the only part ISOSURFACE is able to render

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Noor Aamer am 4 Mai 2018
How can I get a 3D binary image from 2D binary image?
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Md Nurul Karim am 19 Nov. 2019
Just stack the 2D binary images on top of each other and make a 3D binary matrix.
then you can watch it in Volume viewer app.
You can also extract surface out of it.

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Scalar Volume Data finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by