You can use the Color Thresholder on the Apps tab of the tool ribbon. Tell it to export the code. Then you can pass the mask into bwlabel() or bwconncomp().
For the image you've shown, it looks like it was already labeled and passed in to label2rgb() function to produce a pseudocolored image. If not, then tell me how you obtained that image and why you don't have the labeled image for it.