You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defpoints_to_spheres_fixed(im):
r""" Inserts disks/spheres into an image at locations indicated by non-zero values Parameters ---------- im : ndarray The image containing nonzeros indicating the locations to insert spheres. If the non-zero values are `bool`, then the maximal size is found and used; if the non-zeros are `int` then these values are used as the radii. Returns ------- spheres : ndarray A `bool` array with disks/spheres inserted at each nonzero location in `im`. """fromscipy.spatialimportdistance_matrixifim.ndim==3:
x, y, z=np.where(im>0)
coords=np.vstack((x, y, z))
else:
x, y=np.where(im>0)
coords=np.vstack((x, y))
ifim.dtype==bool:
dmap=distance_matrix(coords.T, coords.T)
mask=dmap<1dmap[mask] =np.infr=np.around(dmap.min(axis=0)/2, decimals=0).astype(int)
else:
ifim.ndim==3:
r=im[x, y, z].flatten()
else:
r=im[x, y].flatten()
im_spheres=np.zeros_like(im, dtype=bool)
im_spheres=ps.tools._insert_disks_at_points_parallel(
im_spheres,
coords=coords,
radii=r,
v=True,
smooth=False,
)
returnim_spheres```
The text was updated successfully, but these errors were encountered:
Thanks for the detailed bug report and solution. Much appreciated. Would you be willing to do a pull request? Those changes are pretty minor so it should be a quick and easy.
jgostick
changed the title
Bug: tools.points_to_spheres not adding spheres correctly for 3D impoints_to_spheres not adding spheres correctly for 3D images
Mar 8, 2024
heinsimon
added a commit
to heinsimon/porespy
that referenced
this issue
Mar 12, 2024
The function points_to_spheres is not correctly adding spheres for a 3D image.
Potential fix:
Fix used for example above
The text was updated successfully, but these errors were encountered: