# How to draw a circle or plane on an existing 3d image?

**URL:** <https://discourse.itk.org/t/how-to-draw-a-circle-or-plane-on-an-existing-3d-image/2550>\
**Category:** Uncategorized\
**Created:** [December 19, 2019, 9:50am UTC](https://discourse.itk.org/t/how-to-draw-a-circle-or-plane-on-an-existing-3d-image/2550 "2019-12-19T09:50:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)\
**Post date:** [December 19, 2019, 9:50am UTC](https://discourse.itk.org/t/how-to-draw-a-circle-or-plane-on-an-existing-3d-image/2550/1 "2019-12-19T09:50:51Z")

</div>

I want to draw a plane(say I have the plane equation) on a 3d image. Is there any option to do so in ITK snap or slicer? If not what could be the approach through ITK?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [December 19, 2019, 2:53pm UTC](https://discourse.itk.org/t/how-to-draw-a-circle-or-plane-on-an-existing-3d-image/2550/2 "2019-12-19T14:53:19Z")

</div>

Conceptually most simple approach is to use iterators. [Iterate over your circle’s bounding box](https://itk.org/ITKExamples/src/Core/Common/IterateRegionWithAccessToIndexWithWriteAccess/Documentation.html), and at each voxel evaluate the circle equation by using [TransformIndexToPhysicalPoint()](https://itk.org/Doxygen/html/classitk_1_1ImageBase.html#a8360b9623d685997725c81c85716c4d2). If the given voxel is within one voxel’s size of the mathematical circle, set the voxel’s intensity to 255, otherwise do not modify the voxel.

ITK-SNAP does not support arbitrary orientations. This can be done using Slicer: use segment editor to draw a circle, then use “Simple Filters” to add it to the base image.

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)\
**Post date:** [December 19, 2019, 7:03pm UTC](https://discourse.itk.org/t/how-to-draw-a-circle-or-plane-on-an-existing-3d-image/2550/3 "2019-12-19T19:03:06Z")

</div>

There is already GUI for these in 3D Slicer’s Segment editor module (_paint_ and _scissors_ to define the stencil, then _mask volume_ to paint it into the 3D image). You can easily automate these operations using Python scripting. You can ask details on [Slicer forum](https://discourse.slicer.org/).

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [December 20, 2019, 1:05am UTC](https://discourse.itk.org/t/how-to-draw-a-circle-or-plane-on-an-existing-3d-image/2550/4 "2019-12-20T01:05:38Z")

</div>

ITK contains a nice framework for parametric object representation called _SpatialObject_’s. An  
`itk::SpatialObject` can be sampled on an image pixel grid with `itk::SpatialObjectToImageFilter`. Here is an example:

[https://itk.org/ITKExamples/src/Core/SpatialObjects/Ellipse/Documentation.html](https://itk.org/ITKExamples/src/Core/SpatialObjects/Ellipse/Documentation.html)

_SpatialObject_’s are covered thoroughly in the [ITK Software Guide](https://itk.org/ItkSoftwareGuide.pdf).
