Convert thresholded cells/objects to separated convex areas

Hi there,

I am wondering whether it is possible to convert each single cell depicted below to a seperate convex area or object either on image or object level? The aim is to include the areas within the indentations of the cells. Sadly the morph function would draw a single convex area including all above-threshold pixels and hence cells on the below image.
Any suggestion is highly appreciated :slight_smile:


thresholded cells:

You could try dilating and then eroding the objects by the same large-ish number of pixels- as a place to start try dilating by 20, then eroding by 20, which would at least fill in the enclosed holes though I’m not sure about the edges. This will work best if your cells will always be nicely spread out, as they are in the image above.

Thank you for your helpful suggestion! Whereas it is sadly no full substitute for the convex hull it definitely helps to improve the analysis!

green: thresholded image as shown above
red: thresholded image dilated and eroded

Glad it’s at least a partial solution! Depending on your downstream requirements you could always do something like dilate 20 then erode 10; it depends on whether it’s more important to not include anything outside the cell or to get absolutely everything inside it.

You can! With a bit of CellProfiler workarounds :wink: See the attached pipeline file, which works with your original image.

The trick is to use ReassignObjectNumbers, which has a per-parent convex hull option. To use this though, you need to identify child and parent objects. That is the use of the two IdentifyPrimaryObejct modules. They are exact duplicates of each other, except for their output objects’ names. Then you need to establish a parent-child relationship, but here, they are exactly the same objects as just stated. Then you can use ReassignObjectNumbers with the per-parent convex hull object. The MeasureObjectSizeShape is just there to verify that the convex hull objects are truly larger in area, etc. (I’ve never tried this otherwise, so please verify these measurements yourself!)

Hope that helps!

ConvexHull.cppipe (9.4 KB)

P.S. This was created with a recent nightly version of CellProfiler ( But it doesn’t need to be. If you have an older version of CellProfiler, then it may work immediately, but if it complains on import, then you could download a new version and open it there, then manually create the pipeline in the older version with the same basic settings.

Nice! Never would’ve thought of that :slight_smile:

1 Like

That’s an amazing solution, thanks! Sadly the per parent convex hull option must have been implemented in later versions than the 2.1.1 that I am using currently (I have to stick to it as I use classify pixels and an ImageJ plugin). But I am looking forward to try it in a later version!
For now I am just identifying the dots and cells in seperate categories using ilastik/classify pixels, and then adding the thresholded dots and cells using ImageMath and identify. It appears to work pretty well for now! Another CellProfiler workaround :wink: