Remove jaggies from image's boundary

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:

This is the result that i want:

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 !

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]

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]

Cheers,

Marco