Code snippet to load an image, perform segmentation and output total, positive and negative counts

Hello, I am new to Cellprofiler and ImageJ and also don’t have a solid software development background so my question may sound dumb. Sorry.

I have a segmentation task for the immunohistochemical images containing reaction for KI-67, HER2, etc.

I want to create a simple code snippet able to load an image (or just read it from a hardcoded path), perform segmentation (to distinguish “positive” and “negative” cells) and output total, positive and negative counts.

Is it something Cellprofiler and/or ImageJ capable to do? Can you please suggest related Classes and Methods do yo it? Or, maybe it is already some CLI / Python Notebook version I can use?

I guess I can use UI to do this but I need a code snippet to allow batch processing.

Please see attached images w/ example of the input file and manually (it took like forever!) segmented cells:



To get you started with this in ImageJ … here are a bunch of helpful links:

I highlighted with ** those two workshops/slides you’ll find most beneficial… But you can essentially do everything you wish to batch process images via scripting.


Thank you very much for the answer, @etadobson!
I will check the links and come back if I have problems w/ getting results.

1 Like


I know it’s a lot of information I just threw out there… but start with those workshops and you’ll be well on your way! And of course - we are always here on the forum to help when you encounter more specific questions/problems. :slight_smile: