Distance transform `bwdist` output is completely black
<p>Why is the <code>bwdist</code> and <code>imhmin</code> image completely black? When I check the the two matrices in the workspace, the values seem fine. You can run this code in Matlab to check it out. The expected result is a grayscale image where the centre of each connected component has low intensity, while the edges of the connected components have high intensity. The pixel distance of the edges are further from the centroid and would have a high distance value. If the distance values are considered to be an intensity, thus high intensity at the edges.</p>

<p>Consider the 1's as the connected components to be distance transformed while the 0's are merely the background. I would like to have the background as 0's.</p>

<pre><code>image = zeros(5,5);
image(2,2) = 1;
image(4,4) = 1;

binary = im2bw(image,graythresh(image));
distance = bwdist(binary,'cityblock');
hminima = imhmin(distance,5);

figure; imshow(binary)
figure; imshow(distace)
figure; imshow(hminima)
</code></pre>

<p>The needed result is something like this.</p>

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