# Automatic paint tool along curve

**URL:** <https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800>\
**Category:** Support\
**Created:** [October 20, 2022, 7:36am UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800 "2022-10-20T07:36:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bserrano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bserrano/32/17034_2.png) [@bserrano](https://discourse.slicer.org/u/bserrano)\
**Post date:** [October 20, 2022, 7:36am UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/1 "2022-10-20T07:36:08Z")

</div>

Hello,

I want to implement a paint tool that can automatically follow a path so I can set the radius and threshold and get the segmentation from the beginning to the end of the curve. Can anyone give some idea how to do it?

Thanks,

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 20, 2022, 1:13pm UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/2 "2022-10-20T13:13:12Z")

</div>

With some python scripts you can do that. You could look at the Endoscopy module and the Segment Editor code to find the logic parts you would need. Tracing along a curve with threshold painting could be a good way to segment faint vessels.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [October 20, 2022, 1:21pm UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/3 "2022-10-20T13:21:22Z")

</div>

You may have a look at the ‘Curve centerline extraction’ module in SlicerVMTK extension, that you can install from the ‘Extension manager’. It segments along a curve using ‘Flood filling’ and not ‘Paint’ tool. You can specify the radius, and tune the intensity range until you get a satisfactory result. Very poorly contrasted vessels may be out of scope though.

---

<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:** [October 20, 2022, 2:45pm UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/4 "2022-10-20T14:45:38Z")

</div>

Filling a segment around a curve with a specified radius is already available in the “Draw tube” effect in Segment Editor, after you install “SegmentEditorExtraEffects” extension.

---

<div class="post-metadata">

**Author:** ![bserrano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bserrano/32/17034_2.png) [@bserrano](https://discourse.slicer.org/u/bserrano)\
**Post date:** [October 20, 2022, 3:08pm UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/5 "2022-10-20T15:08:02Z")

</div>

Thanks.  
But we are interested in adjust radius and intensity in each point given some conditions. Maybe the easiest way to do it is modify “Draw tube” code?

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [October 20, 2022, 3:32pm UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/6 "2022-10-20T15:32:48Z")

</div>

Sample images would be helpful.

---

<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:** [October 20, 2022, 3:50pm UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/7 "2022-10-20T15:50:37Z")

</div>

> [@bserrano](#):
>
> But we are interested in adjust radius and intensity in each point given some conditions. Maybe the easiest way to do it is modify “Draw tube” code?

What would you like to achieve? Generate a vascular network? Would you like to get a surface mesh or synthetic CT as output? Where do the input curves come from?

---

<div class="post-metadata">

**Author:** ![bserrano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bserrano/32/17034_2.png) [@bserrano](https://discourse.slicer.org/u/bserrano)\
**Post date:** [October 21, 2022, 10:03am UTC](https://discourse.slicer.org/t/automatic-paint-tool-along-curve/25800/8 "2022-10-21T10:03:22Z")

</div>

> [@lassoan](#):
>
> Generate a vascular network?

Yes, we want to generate vessels having in count the curve points neighbourhood, so we can adjust parameters like radius or threshold.  
Pseudocode may look like:

```auto
curve = MarkupsCurve(...)
for point in curve:
      radius = adjustRadius(point)
      threshold = adjustThreshold(point)
      applyPaint(point, radius, threshold)

```

We want a segment as output.

Thanks 🙂
