Borrar filtros
Borrar filtros

Isolating set of contiguous points in a 3D matrix

5 visualizaciones (últimos 30 días)
Steffen Adria
Steffen Adria el 9 de Ag. de 2011
I have a 3D matrix comprised of positive values (corresponding to solid matter) and zero values (corresponding to empty space.) I have several solid objects, in which there are small gaps. Between objects there are larger gaps. I'm trying to delete all objects (make them empty space) except the one of interest.
What I currently do is create (preallocated with zeros) a Nx3 coordinate holding matrix with N being equal to the total number of points in the 3D matrix. The first entry in this matrix is specified by the user as being a point within the 3D matrix that is positive. I then have a loop going through the coordinate matrix, looking at the adjacent positions and flipping the signs of the positive cells. Cells which are flipped have their locations entered into the coordinate matrix, and then in turn their adjacent cells are checked for positive values. Once the next entry in the coordinate matrix is [0 0 0] the loop terminates, all positive values in the 3D matrix are zeroed, and the signs of all points are flipped.
This works quite well, but not quickly, as it examines most spaces several times. A typical object is about 800,000 points, by the way, and run time as it is is about 80 seconds - not so great given that it's supposed to be real time. Does anyone have any idea for a way to improve this, or an entirely new method of isolating a contiguous object?
Much appreciated.
-Steffen
  1 comentario
Fangjun Jiang
Fangjun Jiang el 9 de Ag. de 2011
It would be better if you could provide a small set of data and also show your for-loop code.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by