mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-09 05:18:57 +08:00
FIX: correct other instance of np.linalg.norm, clarify comments
This commit is contained in:
@@ -68,6 +68,12 @@ def marching_cubes(volume, level, spacing=(1., 1., 1.)):
|
||||
lexicographical order) coordinate in the contour. This is a side-effect
|
||||
of how the input array is traversed, but can be relied upon.
|
||||
|
||||
The generated mesh does not guarantee coherent orientation because of how
|
||||
symmetry is used in the algorithm. If this is required, e.g. due to a
|
||||
particular visualization package or for generating 3D printing STL files,
|
||||
the utility ``skimage.measure.correct_mesh_orientation`` is available to
|
||||
fix this in post-processing.
|
||||
|
||||
To quantify the area of an isosurface generated by this algorithm, pass
|
||||
the outputs directly into `skimage.measure.mesh_surface_area`.
|
||||
|
||||
@@ -240,11 +246,12 @@ def correct_mesh_orientation(volume, verts, faces, spacing=(1., 1., 1.),
|
||||
grad_centroids = np.c_[grad_centroids_x, grad_centroids_y,
|
||||
grad_centroids_z]
|
||||
grad_centroids = (grad_centroids /
|
||||
np.linalg.norm(grad_centroids, axis=1)[:, np.newaxis])
|
||||
(np.sum(grad_centroids ** 2,
|
||||
axis=1) ** 0.5)[:, np.newaxis])
|
||||
|
||||
# Calculate and normalize cross products for each face
|
||||
# Find normal vectors for each face via cross product
|
||||
crosses = np.cross(a, b)
|
||||
crosses = crosses / np.sum(crosses ** 2, axis=1) ** (0.5)[:, np.newaxis]
|
||||
crosses = crosses / (np.sum(crosses ** 2, axis=1) ** (0.5))[:, np.newaxis]
|
||||
|
||||
# Take dot product
|
||||
dotproducts = (grad_centroids * crosses).sum(axis=1)
|
||||
@@ -260,7 +267,7 @@ def correct_mesh_orientation(volume, verts, faces, spacing=(1., 1., 1.),
|
||||
raise ValueError("Incorrect input %s in `gradient_direction`, see "
|
||||
"docstring." % (gradient_direction))
|
||||
|
||||
# Swap orientation and return, without modifying original data
|
||||
# Correct orientation and return, without modifying original data
|
||||
faces_corrected = faces.copy()
|
||||
faces_corrected[indices] = faces_corrected[indices, ::-1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user