# Centerline Extraction on Bronchoscopy

**URL:** <https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900>\
**Category:** Support\
**Tags:** python\
**Created:** [April 14, 2023, 5:36am UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900 "2023-04-14T05:36:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Komal](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@Komal](https://discourse.slicer.org/u/Komal)\
**Post date:** [April 14, 2023, 5:36am UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/1 "2023-04-14T05:36:21Z")

</div>

Hi,  
Please can you help me to get centerline extraction on bronchoscopy using python ,VMTK and which algorithm I need to use .Please send me the source code of the same.

---

<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:** [April 15, 2023, 3:20am UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/2 "2023-04-15T03:20:05Z")

</div>

You first need to segment the airways and then you can use VMTK extension to extract the centerline. You can find tutorials on YouTube and source code on Github ([GitHub - Slicer/Slicer: Multi-platform, free open source software for visualization and image computing.](https://github.com/Slicer/Slicer), [GitHub - vmtk/SlicerExtension-VMTK](https://github.com/vmtk/SlicerExtension-VMTK)).

---

<div class="post-metadata">

**Author:** ![Komal](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@Komal](https://discourse.slicer.org/u/Komal)\
**Post date:** [April 17, 2023, 7:21am UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/3 "2023-04-17T07:21:46Z")

</div>

Hi,  
Thank you  
Actually I want simple code like which consist STL file airway tree and algorithm to extract centerline. I am getting like this output ,please can you help me.

 ![airwayoutput](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/1/51275f7a80c9ec949fc9f8b557286c8c8f2ac298.png)

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 17, 2023, 12:17pm UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/4 "2023-04-17T12:17:06Z")

</div>

You’ll need to generate an airway segmentation similar to the one that you showed in your image. You can use the Lung CT Segmenter (part of Lung CT Analyzer extension) for that in connection with a thin sliced lung CT tissue kernel. Then you should hollow the structure with 3D Slicers Segment Editor and follow @lassoan’s advice/link in the above post.

---

<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:** [April 17, 2023, 1:01pm UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/5 "2023-04-17T13:01:44Z")

</div>

> [@rbumm](#):
>
> Then you should hollow the structure with 3D Slicers Segment Editor

Clarification: for centerline extraction you need a segment that contains the airway lumen. If you hollow the airways (for visualization, 3D printing, etc.) then do it after the centerline extraction or keep a copy of the lumen segment.

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 17, 2023, 1:15pm UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/6 "2023-04-17T13:15:10Z")

</div>

That is a very important point, thanks for the clarification. It even spins some ideas for pulmonary vessels, which I thought must be hollowed for VMTK.

---

<div class="post-metadata">

**Author:** ![Komal](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@Komal](https://discourse.slicer.org/u/Komal)\
**Post date:** [April 21, 2023, 5:57am UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/7 "2023-04-21T05:57:10Z")

</div>

Ok Thank you,  
I installed vmtk in visual studio code. I want to build vmtk in visual studio 2019 professional,  
how can I do ? please help .

---

<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:** [April 21, 2023, 9:24pm UTC](https://discourse.slicer.org/t/centerline-extraction-on-bronchoscopy/28900/8 "2023-04-21T21:24:04Z")

</div>

All the tools are built and made conveniently available as Slicer extensions that you can use in either Python or C++.

If you want to build the underlying libraries yourself and implement and application that integrates all the tools then it is a lot of work and you have to do it all yourself. But to give some help with getting started:

- VMTK can compute the centerline from airways segmentation. You can configure and build VMTK using CMake. There are no prerequisites or any special configuration options, everything just works with default settings.
- For segmenting the airways you can use semi-automatic methods in Slicer or CIP or you can try various neural network based automatic segmentation tools.
