correct_mesh_orientation
-
skimage.measure.correct_mesh_orientation(volume, verts, faces, spacing=(1.0, 1.0, 1.0), gradient_direction='descent')
[source] -
Correct orientations of mesh faces.
Parameters: volume : (M, N, P) array of doubles
Input data volume to find isosurfaces. Will be cast to
np.float64
.verts : (V, 3) array of floats
Array containing (x, y, z) coordinates for V unique mesh vertices.
faces : (F, 3) array of ints
List of length-3 lists of integers, referencing vertex coordinates as provided in
verts
.spacing : length-3 tuple of floats
Voxel spacing in spatial dimensions corresponding to numpy array indexing dimensions (M, N, P) as in
volume
.gradient_direction : string
Controls if the mesh was generated from an isosurface with gradient descent toward objects of interest (the default), or the opposite. The two options are: * descent : Object was greater than exterior * ascent : Exterior was greater than object
Returns: faces_corrected (F, 3) array of ints
Corrected list of faces referencing vertex coordinates in
verts
.Notes
Certain applications and mesh processing algorithms require all faces to be oriented in a consistent way. Generally, this means a normal vector points “out” of the meshed shapes. This algorithm corrects the output from
skimage.measure.marching_cubes
by flipping the orientation of mis-oriented faces.Because marching cubes could be used to find isosurfaces either on gradient descent (where the desired object has greater values than the exterior) or ascent (where the desired object has lower values than the exterior), the
gradient_direction
kwarg allows the user to inform this algorithm which is correct. If the resulting mesh appears to be oriented completely incorrectly, try changing this option.The arguments expected by this function are the exact outputs from
skimage.measure.marching_cubes
. Onlyfaces
is corrected and returned, as the vertices do not change; only the order in which they are referenced.This algorithm assumes
faces
provided are all triangles.
Please login to continue.