# In instance segmentation, if the segmented parts are discontinuous, how to put the contours of the discontinuous parts into the same mask

**URL:** <https://community.ultralytics.com/t/in-instance-segmentation-if-the-segmented-parts-are-discontinuous-how-to-put-the-contours-of-the-discontinuous-parts-into-the-same-mask/432>\
**Category:** YOLO\
**Tags:** segment, question, yolo, support\
**Created:** [October 26, 2024, 3:43pm UTC](https://community.ultralytics.com/t/in-instance-segmentation-if-the-segmented-parts-are-discontinuous-how-to-put-the-contours-of-the-discontinuous-parts-into-the-same-mask/432 "2024-10-26T15:43:22Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![BurhanQ](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/burhanq/32/7_2.png) [@BurhanQ](https://community.ultralytics.com/u/BurhanQ)\
**Post date:** [October 26, 2024, 4:23pm UTC](https://community.ultralytics.com/t/in-instance-segmentation-if-the-segmented-parts-are-discontinuous-how-to-put-the-contours-of-the-discontinuous-parts-into-the-same-mask/432/2 "2024-10-26T16:23:41Z")

</div>

If I recall correctly (iirc), the output from `results[0].masks.xy` is list of Numpy arrays. This would mean that you’d need to extract each array from the list to get the mask. The reason this is a list and not a Numpy array, is because the mask contours might be different lengths, and would not be able to be stacked with mismatch array sizes.

```py
result[0].masks.xy
>>> [
>>> array[i, 2],
>>> array[j, 2],
>>> array[k, 2],
>>> ...,
>>> array[N, 2],
>>> ]

# here, i, j, k represent different values for the first
# array dimension, with up to N different values

```

One important factor to consider (and possibly answer) is what do you wish to accomplish with the contours? Knowing this might provide better insight on how to accomplish your end goal ([see this post for context](https://community.ultralytics.com/t/advice-on-asking-for-support/126)).

---

_[View the full topic](https://community.ultralytics.com/t/in-instance-segmentation-if-the-segmented-parts-are-discontinuous-how-to-put-the-contours-of-the-discontinuous-parts-into-the-same-mask/432)._
