text_plain_output_1.png image_output_1.png
from mpl_toolkits.mplot3d.art3d import Poly3DCollection

from scipy.ndimage import zoom

from skimage import measure

import matplotlib.pyplot as plt

import numpy as np # linear algebra

from mpl_toolkits.mplot3d.art3d import Poly3DCollection
from skimage import measure
def show_3d_mesh(p, threshold):
    verts, faces = measure.marching_cubes(p, threshold)

    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(111, projection='3d')
    mesh = Poly3DCollection(verts[faces], alpha=0.15, edgecolor='none', linewidth = 0.1)
    mesh.set_facecolor([.1, 1, .1])
    mesh.set_edgecolor([1, 0, 0])
    
    ax.add_collection3d(mesh)

    ax.set_xlim(0, p.shape[0])
    ax.set_ylim(0, p.shape[1])
    ax.set_zlim(0, p.shape[2])
    
    ax.view_init(80, 5)
    return fig

from scipy.ndimage import zoom
fossil_downscale = zoom(closed_fossil_data.astype(np.float32), 0.25)
_ = show_3d_mesh(filter_fossil_data, 0.5)