title: how to compute convex hull image/volume in 3d numpy arrays
body: <p>I wonder if there are any numpy based tools that can:</p>
  <ol>
  <li>given a binary input numpy image in 3D, find its convex hull;</li>
  <li>and return a list of indices or similar of the voxels (3D pixels) that are within this 3D convex hull.</li>
  </ol>
  <p>One possibility is to use <code>skimage.morphology.convex_hull_image()</code>, but <strike>this only supports 2D images, so then i have to call this function slice by slice (in the z-axis), which is slow.</strike> [Edit: See note below.]</p>
  <p>I definitely prefer to a more efficient way. For example, scipy.spatial.ConvexHull() could take a list of points in N-dimensional space, and return a convex hull object which seems not support finding its convex hull image/volume.</p>
  <pre><code>points = np.transpose(np.where(image))
  hull = scipy.spatial.ConvexHull(points)
  # but now wonder an efficient way of finding the list of 3D voxels that are inside this convex hull
  </code></pre>
  <p>Any ideas how? Please note efficiency is important to my application.
  Thanks!</p>
  <hr />
  <p><strong>Update:</strong> In the meantime, <code>convex_hull_image()</code> has been <a href="https://github.com/scikit-image/scikit-image/pull/2847" rel="nofollow noreferrer">extended to support ND images</a>, but it is quite slow for moderately sized data. The <a href="https://stackoverflow.com/a/46314485/162094">accepted answer below</a> is much faster.</p>