# Is it possible to create segmentation from given coordinate information (x,y,z)?

**URL:** <https://discourse.slicer.org/t/is-it-possible-to-create-segmentation-from-given-coordinate-information-x-y-z/27281>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [January 16, 2023, 10:39pm UTC](https://discourse.slicer.org/t/is-it-possible-to-create-segmentation-from-given-coordinate-information-x-y-z/27281 "2023-01-16T22:39:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aysegul\_sayin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aysegul_sayin/32/14944_2.png) [@aysegul\_sayin](https://discourse.slicer.org/u/aysegul_sayin)\
**Post date:** [January 16, 2023, 10:39pm UTC](https://discourse.slicer.org/t/is-it-possible-to-create-segmentation-from-given-coordinate-information-x-y-z/27281/1 "2023-01-16T22:39:10Z")

</div>

Is it possible to segment the x, y, z points that I entered manually? I found that polygons or cubes are drawn with python using vtk, but what I want is to segment the coordinate points I have given by painting. For example, when I enter the point (170,100,150), this point is automatically segmented.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 16, 2023, 11:14pm UTC](https://discourse.slicer.org/t/is-it-possible-to-create-segmentation-from-given-coordinate-information-x-y-z/27281/2 "2023-01-16T23:14:20Z")

</div>

Do you mean you would want to set each voxel in the segmentation using a method call? That would mean hundreds of thousands, maybe millions of calls for a single segment. That could take dozens of seconds or more.

Python is generally not meant to be used for voxel-bygvixel processing. Can you work with higher-level objects than voxels?

What is your overall goal, clinical problem to solve?

---

<div class="post-metadata">

**Author:** ![aysegul\_sayin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aysegul_sayin/32/14944_2.png) [@aysegul\_sayin](https://discourse.slicer.org/u/aysegul_sayin)\
**Post date:** [January 17, 2023, 8:25am UTC](https://discourse.slicer.org/t/is-it-possible-to-create-segmentation-from-given-coordinate-information-x-y-z/27281/3 "2023-01-17T08:25:57Z")

</div>

thanks for answer,  
Actually I want to make this one. I want to turn the coordinates I entered into a segmentation mask on the image.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/5/95fa927802a7ff860b5994e6dd6b01de72f4e8c5.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 17, 2023, 7:50pm UTC](https://discourse.slicer.org/t/is-it-possible-to-create-segmentation-from-given-coordinate-information-x-y-z/27281/4 "2023-01-17T19:50:32Z")

</div>

You can convert your list of coordinates to a numpy array (see for example [here](https://stackoverflow.com/questions/56660387/fastest-way-to-convert-a-list-of-indices-to-2d-numpy-array-of-ones)) and then [import that numpy array into a segmentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#read-and-write-a-segment-as-a-numpy-array).

However, this whole idea of representing binary labelmaps as list of coordinate values is much more complicated than needed and extremely inefficient. What software generates point list positions instead of a labelmap image? Does that software have an option to save a binary image instead? If not, then suggest to the developer to implement saving of the result into a numpy array and write that array to a standard 3D image file using pynrrd. You can load the nrrd file into Slicer directly as a segmentation.
