Morphological thickening/dilation while trying to preserve shape in MATLAB
<p>I'm thickening a binary image. I wished to grow the label n pixels to each direction.</p>

<p>Original image:</p>

<p><a href="https://i.stack.imgur.com/geZud.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/geZud.png" alt="Original label image"></a></p>

<p>At first I used the function bwmorph(I, 'thicken', 25) and got this image :</p>

<p><a href="https://i.stack.imgur.com/2ZDjz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2ZDjz.png" alt="After morphological thickening"></a></p>

<p>Which is no good. The thickening seems to use the structuring element [0,1,0;1,1,1;0,1,0], so it always transforms circles into diamonds. imdilate with the mentioned structuring element results in the same output.</p>

<p>Next I tried dilating the original image iteratively for n=25 times with the structuring element[1,1,1; 1,1,1; 1,1,1] and got the following image: </p>

<p><a href="https://i.stack.imgur.com/u05t1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u05t1.png" alt="iterative dilation"></a></p>

<p>The original shape is now completely gone.</p>

<p>I understand that dilation will always distort the border to some degree. I experimented with the structuring element 'disk' (r=5, dilated 5 times) and got fairly good results:</p>

<p><a href="https://i.stack.imgur.com/xuCwQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xuCwQ.png" alt="enter image description here"></a></p>

<p>Is this as good as it gets? Which structuring element should I choose if I wish to preserve the original circular shape as well as possible? Are there any good rules of thumbs for finding the right size for a particular dilation distance (which can vary from 10-100 and the labels vary from circular to elliptical)? Is there a better way of growing a binary image in all the directions while trying to keep the original shape?</p>

<p>Is there a way to keep the Euler characteristic -preserving quality of thicken while changing the structuring element to something more suitable?</p>