Your A image is not what you think it is. I'd bet that it is not a logical image, but a gray scale image with most pixels at 255 but some pixels at a much darker value. Do this
and see what it shows. Do you have only 2 bins at 0 and 1? Or do you have bins at 0, 255, and, say, 20 or some small number?
You can also try this
and then label and see what you get.