# Merging Connected Components

**URL:** <https://discourse.slicer.org/t/merging-connected-components/34975>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [March 19, 2024, 1:58pm UTC](https://discourse.slicer.org/t/merging-connected-components/34975 "2024-03-19T13:58:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkraaijveld](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@rkraaijveld](https://discourse.slicer.org/u/rkraaijveld)\
**Post date:** [March 19, 2024, 1:58pm UTC](https://discourse.slicer.org/t/merging-connected-components/34975/1 "2024-03-19T13:58:58Z")

</div>

Hi,

I’d like to create a button in my extension that merges all the segmentations in the image.

I found this: [Slicer: vtkSegmentation Class Reference](https://apidocs.slicer.org/master/classvtkSegmentation.html#a9498f59bcdf034585209f4bf79b76357)

Where I see that I can use GenerateMergedLabelmap() and GenerateMergedLabelmapForAllSegments(), but I’m unsure how to use it. Can anyone help?
