# Extract contours from 3D image

**URL:** https://discourse.itk.org/t/extract-contours-from-3d-image/5209
**Category:** Algorithms
**Tags:** cpp
**Created:** [July 22, 2022, 1:50pm UTC](https://discourse.itk.org/t/extract-contours-from-3d-image/5209 "2022-07-22T13:50:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kap](https://discourse.itk.org/letter_avatar_proxy/v4/letter/k/67e7ee/32.png) [@Kap](https://discourse.itk.org/u/Kap)
#### Post date: [July 22, 2022, 1:50pm UTC](https://discourse.itk.org/t/extract-contours-from-3d-image/5209/1 "2022-07-22T13:50:10Z")

</div>

Dears,

I am trying to extract the contour from an object after the procedure of the segmentation.  
The complie is error free but the output is an empty(black) image.  
Maybe the output image type is wrong ? Any ideas ?

Here is my function:

```cpp
ImageType::Pointer Segmenter::Contours(ImageType::Pointer image)
{          
  using SimpleContourExtractorImageFilterType = itk::SimpleContourExtractorImageFilter <ImageType, ImageType>;
  SimpleContourExtractorImageFilterType::Pointer contourFilter
          = SimpleContourExtractorImageFilterType::New();
  contourFilter->SetInput(image);
  contourFilter->Update();  
  return contourFilter -> GetOutput();            
}

```

Thanks in advance

---

<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: [July 22, 2022, 2:15pm UTC](https://discourse.itk.org/t/extract-contours-from-3d-image/5209/2 "2022-07-22T14:15:55Z")

</div>

You might need to set `InputBackgroundValue` to 255, 1 or maybe something else. Other, possibly relevant settings of the filter are `OutputBackgroundValue` and `Radius`.

---

<div class="post-metadata">

### Author: ![Kap](https://discourse.itk.org/letter_avatar_proxy/v4/letter/k/67e7ee/32.png) [@Kap](https://discourse.itk.org/u/Kap)
#### Post date: [July 22, 2022, 6:39pm UTC](https://discourse.itk.org/t/extract-contours-from-3d-image/5209/3 "2022-07-22T18:39:10Z")

</div>

Thanks a lot Dženan, cheking it…
