# How to segment the area of interest in the image

**URL:** https://discourse.itk.org/t/how-to-segment-the-area-of-interest-in-the-image/2565
**Category:** Uncategorized
**Created:** [December 23, 2019, 1:36am UTC](https://discourse.itk.org/t/how-to-segment-the-area-of-interest-in-the-image/2565 "2019-12-23T01:36:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![haodafeng](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/a87d85/32.png) [@haodafeng](https://discourse.itk.org/u/haodafeng)
#### Post date: [December 23, 2019, 1:36am UTC](https://discourse.itk.org/t/how-to-segment-the-area-of-interest-in-the-image/2565/1 "2019-12-23T01:36:27Z")

</div>

i am a beginer of the ITK, as the title, i want to segment the specified region of the image , how can i do?

---

<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: [December 23, 2019, 2:23pm UTC](https://discourse.itk.org/t/how-to-segment-the-area-of-interest-in-the-image/2565/2 "2019-12-23T14:23:57Z")

</div>

In the most general form, as you stated here, it is an unsolved problem. See [Wikipedia article](https://en.wikipedia.org/wiki/Image_segmentation). Many constraints are needed in order for it to be tractable. Image modality, organ of interest, tissue of interest, etc are all common constraints.

---

<div class="post-metadata">

### Author: ![haodafeng](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/a87d85/32.png) [@haodafeng](https://discourse.itk.org/u/haodafeng)
#### Post date: [December 24, 2019, 12:27am UTC](https://discourse.itk.org/t/how-to-segment-the-area-of-interest-in-the-image/2565/3 "2019-12-24T00:27:49Z")

</div>

thank you for your relpy, maybe i did not make myself clear.  
i want to use OtsuThresholdImageFilter to segment lung, first , i have already distinguish the body and background by OtsuThresholdImageFilter, than i want to segment lung from the body part which is the result of the first step. my question is how to use OtsuThresholdImageFilter just on the body pixels.

by the way, i process 2D image.

---

<div class="post-metadata">

### Author: ![haodafeng](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/a87d85/32.png) [@haodafeng](https://discourse.itk.org/u/haodafeng)
#### Post date: [December 25, 2019, 12:32am UTC](https://discourse.itk.org/t/how-to-segment-the-area-of-interest-in-the-image/2565/4 "2019-12-25T00:32:30Z")

</div>

I seem to have solved the problem,use the member function SetMaskImage and SetMaskValue of OtsuThresholdImageFilter

 ![1577233852(1)](https://discourse.itk.org/uploads/default/original/2X/1/1944fd11f199be45756a4abba0071f868c82628e.png)
