# canny segmentation level set

**URL:** https://discourse.itk.org/t/canny-segmentation-level-set/1896
**Category:** Algorithms
**Created:** [May 20, 2019, 10:17am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896 "2019-05-20T10:17:11Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Marco\_Festugato](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_festugato/32/696_2.png) [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)
#### Post date: [May 20, 2019, 10:17am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/1 "2019-05-20T10:17:11Z")

</div>

hi guys, thank u in advance for reading this.

Can I use the Canny Edge level set to refine this segmentation I obtained using a simple binary thresholding? I want to delete all those little points and keep only the big ones (they are vessels)…

 ![vasi](https://discourse.itk.org/uploads/default/original/1X/54211a355bbb505b564c905847dfd723c808884c.png)

---

<div class="post-metadata">

### Author: ![mattias](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mattias](https://discourse.itk.org/u/mattias)
#### Post date: [May 20, 2019, 10:45am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/2 "2019-05-20T10:45:45Z")

</div>

I would use a binary eroding filter until only remnants of the large regions remain, then use that map as seeds to reconstruct the original regions.

---

<div class="post-metadata">

### Author: ![Marco\_Festugato](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_festugato/32/696_2.png) [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)
#### Post date: [May 20, 2019, 11:30am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/3 "2019-05-20T11:30:30Z")

</div>

Hi @mattias and thank u for your reply! Do u know if I can use that level set even if the regions I want to segment are not ‘‘closed’’ regions?  
Thanks in advance for any help

---

<div class="post-metadata">

### Author: ![mattias](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mattias](https://discourse.itk.org/u/mattias)
#### Post date: [May 20, 2019, 11:47am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/4 "2019-05-20T11:47:45Z")

</div>

This is the result I get if I first label all connected regions then keep the four largest regions in your image.

![vasi](https://discourse.itk.org/uploads/default/original/1X/5c47db4aae367c8ef2bc9b5198bb6a9c15f54d76.png)

So I think that’s a possible solution for you as well.

---

<div class="post-metadata">

### Author: ![Marco\_Festugato](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_festugato/32/696_2.png) [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)
#### Post date: [May 20, 2019, 11:50am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/5 "2019-05-20T11:50:38Z")

</div>

Thank u again Mattias for your quick answer. Can I ask u which values of the level set parameters did u use?

---

<div class="post-metadata">

### Author: ![mattias](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@mattias](https://discourse.itk.org/u/mattias)
#### Post date: [May 20, 2019, 11:55am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/6 "2019-05-20T11:55:34Z")

</div>

Since I don’t have the original data I simply used the equivalent of a Connected Component Image Filter to label each connected region in your binary image then I used a Label Shape Statistics Image Filter to extract the four largest regions.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [May 21, 2019, 4:30am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/7 "2019-05-21T04:30:02Z")

</div>

Another good option to be aware of is the [BinaryOpeningByReconstructionImageFilter](https://itk.org/Doxygen/html/classitk_1_1BinaryOpeningByReconstructionImageFilter.html).

---

<div class="post-metadata">

### Author: ![Marco\_Festugato](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_festugato/32/696_2.png) [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)
#### Post date: [May 21, 2019, 6:20am UTC](https://discourse.itk.org/t/canny-segmentation-level-set/1896/8 "2019-05-21T06:20:32Z")

</div>

thank u both for your reply!
