insert_sphere(im, c, r, v=True, overwrite=True)[source]

Inserts a sphere of a specified radius into a given image

  • im (array_like) – Image into which the sphere should be inserted

  • c (array_like) – The [x, y, z] coordinate indicating the center of the sphere

  • r (int) – The radius of sphere to insert

  • v (int) – The value to put into the sphere voxels. The default is True which corresponds to inserting spheres into a Boolean image. If a numerical value is given, im is converted to the same type as v.

  • overwrite (boolean) – If True (default) then the sphere overwrites whatever values are present in im. If False then the sphere values are only inserted into locations that are 0 or False.


image – The original image with a sphere inerted at the specified location

Return type:



Click here to view online example.