I am trying to use the label matrix feature of bwdist, but am encountering a problem. Instead of returning the linear index of the nearest non-zero pixel, the function is returning a matrix where every pixel's value is its own linear index. I am assuming I am misusing or misunderstanding the function, but am not sure how?
Example:
% Generate test image
BW = zeros(500);BW(50:90,1:500) = 1; figure,imshow(BW)[distMap,labelMask] = bwdist(~BW);figure,imshow(labelMask,[]) % It's a gradient because of the issue noted above
It is my understanding that the labelMask here should contain mostly zeros with linear index values in the rectangular region, or at least some deviation in the rectangular region from the rest of the image.
Best Answer