One of the image processing method I'm using and studying now is watershed segmentation, and I find the examples available in Matlab is very useful. I tried it on my own image and it works just fine with some modification. However, there's few commands that I don't understand in the example, and I hope someone can help me with it:
2.Compute the distance transform of the complement of the binary image. D = bwdist(~bw); figure, imshow(D,,'InitialMagnification','fit') title('Distance transform of ~bw')
3.Complement the distance transform, and force pixels that don't belong to the objects to be at -Inf. D = -D; D(~bw) = -Inf;
Q1. What does '~ ' do in (~bw)? Why does it affect the gradient of image in computing the distance transform? Q2. In 3, why does the D needed to be complemented? Q3. What is the purpose of making the 'unrelated' pixels -Inf?