Convert binary to objects


I would like to convert a binary image to a set of objects but I can’t figure out how. I need the opposite of the ConvertObjectsToImage module. Basically, what bwlabel does in Matlab. I have a binary image that I have masked down to isolate structures of interest and now I want to clean out some unwanted content using object metrics like solidity and perimeter ratio but I can’t because I’m starting from a binary not an object set.

It seems like this is computationally simple. It must be happening behind the scenes in IdentifyPrimaryObjects so the code can do it. There are a lot of examples where binary manipulations are preferred and others where object manipulations are preferred so I can’t the first person to want to go both ways.

What am I missing?



Hi John,

Unless I’m missing something myself(!), you’re just describing simple segmentation. The attached pipeline has an ApplyThreshold module which simply creates the binary, and then IdentifyPrimaryObjects doe she segmentation. Note that I set the thresholding method in IDPrim to ‘Binary image’ which may have been what you missed.

Hope that helps,
Binary_segmentation.cppipe (8.07 KB)

Why a binary image with pixel values of only 0 and 1 can not be converted “as is” into objects? I tried as David suggested to John earlier. I also tried a manual threshold value of 0.5. The result is the same - see identified primary objects, there are objects where input image pixels have 0 value. It doesn’t make any sense to me. Thanks, Jama.

Never mind! “Fill holes in identified objects” was causing it, all is good!

1 Like