Exlude object a certain distance from edge

Hi all,

Is there a way of excluding objects, not touching the edge but rather by some arbitrary distance from the edge?
This will be useful especially when secondary objects “children” are not totally on the image, ie. outside the edge.

For example, a nucleus is not touching the edge, but my insulin granules are not all on the image, and therefore not detected, making result for that cell skewed.


Sounds like adjusting the code for the module is your best bet, but a very klugey way to address this using existing modules is to create a single binary (black/white) image in Photoshop (or CellProfiler) that is:

  • the same size as your original images
  • white at the edges (whatever thickness of edges you want; it could even be a non-rectangular shape if you want)
  • black in the middle of the image
  • let’s call it "EdgeImage"
    Then, use LoadSingleImage to load up EdgeImage and make it available to the pipeline. Use a MeasureObject intensity to measure the intensity of EdgeImage within objects. Then, use FilterObjectsByMeasurement to exclude any objects that contain an integrated intensity greater than or equal to 1 (in other words, exclude objects that have any overlap with the EdgeImage white parts). I’m not certain whether this will work for secondary objects or just primary ones.

Make sense? Can you give it a try and let us know if it works?

Hi Anne,

Thanks a lot. I’ve just tried this technique, and it works! No problems getting it working either.

Thanks so much.
Would it be much work to integrate this into the IdentifyPrimAutomatic module?
Say, an input for pixels, to disregard objects from the edge within the nominated pixel distance?

Appreciate all you guys!

Well, I can at least put it on the TO DO list! Perhaps if we obtain an NIH grant for this project we will be able to add more features.

Haha - thanks heaps. Fine job so far!


Well, for what it’s worth, here’s one that for sure hopes you do get an NIH grant!!! That would be SOOOOO helpful to the whole scientific community!!!


In regards to this question: In CellProfiler 2.0, there is an option in IdentifySecondaryObjects (formerly IdentifySecondary) where secondary objects can be discarded if touching an edge and the associated primary object along with it.