# Remove jaggies from image's boundary

**URL:** <https://community.wolfram.com/t/remove-jaggies-from-images-boundary/7129>\
**Category:** Questions\
**Tags:** computer-science\
**Created:** [November 6, 2015, 3:48am UTC](https://community.wolfram.com/t/remove-jaggies-from-images-boundary/7129 "2015-11-06T03:48:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![namv1994](https://avatars.discourse-cdn.com/v4/letter/n/dfb087/32.png) [@namv1994](https://community.wolfram.com/u/namv1994)\
**Post date:** [November 6, 2015, 3:48am UTC](https://community.wolfram.com/t/remove-jaggies-from-images-boundary/7129/1 "2015-11-06T03:48:08Z")

</div>

I need to remove some jaggies from the boundary of an image. This image is taken from the depth frame of the Kinnect Camera.

This is the original image, which contains many jaggies on the boandary due to noise:

 ![Untitled.jpg](https://global.discourse-cdn.com/wolfram/original/3X/c/c/cc874706ddab2cc4f947497f6313142d993dd166.jpeg)

This is the result that i want:

 ![Untitled1.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/3/63b02b88e5023aac397bff4473e91bdf8030835f.jpeg)

Can someone help me with an algorithm or some related materials to achieve this ? It’s pretty urgent for me cause it’s my graduation thesis. Thank u so much !

---

<div class="post-metadata">

**Author:** ![mthiel](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mthiel/32/42877_2.png) [@mthiel](https://community.wolfram.com/u/mthiel)\
**Post date:** [November 6, 2015, 4:05pm UTC](https://community.wolfram.com/t/remove-jaggies-from-images-boundary/7129/2 "2015-11-06T16:05:56Z")

</div>

Hi,

a combination of Blur and Binarize should do the trick. I do not have access to the original image, i.e. the mask, so there is a bit of preprocessing to extract your black region.

If your image is saved in a variable img, then this works:

```
Binarize[Blur[MorphologicalTransform[DeleteSmallComponents[Binarize[img, 0], 950], "Commonest", 15], 30], 0.5]

```

 ![ScreenShot2015-11-06at16.03.15.png](https://global.discourse-cdn.com/wolfram/original/3X/3/6/36481b35fa30e6a9f065d5c925f791f3bc55532f.png)

you can do more sophisticated combinations, and play with the parameters. Here’s one:

```
Binarize[Blur[
  Closing[KuwaharaFilter[
    MorphologicalTransform[
     MorphologicalTransform[
      DeleteSmallComponents[Binarize[img, 0], 950], "Commonest", 15], 
     "BoundaryStraighten", 24], 22], DiskMatrix[18]], 15], 0.5]

```

 ![ScreenShot2015-11-06at16.05.14.png](https://global.discourse-cdn.com/wolfram/original/3X/1/4/14aeeddc5325453d5366ffd9cf6e9732468abd99.png)

Cheers,

Marco
