Determining density using a set length

Hi all,

I’m new to ImageJ and would like to measure the density of Purkinje cells (PCs) in the cerebellum (image attached).

To keep it consistent, I would like to count the number of PCs over a length of 4000 microns for all of my images. Currently, I am tracing the length with the freehand tool and measuring it until it is close to 4000microns, and then counting the number of PCs along that line.

Is there a way to set the freehand tool so that it stops at 4000microns automatically? Any help would be greatly appreciated! :slight_smile:


Hello and welcome Yasika.

Sorry, can’t help here. But I propose an alternative solution. First of all, the manual selection of this 4000 micron line is not ideal as it is inherently biased because your results depend on where you start drawing it… How can you avoid this? As always there are many solutions to a problem, I present a simple one:

Draw a line along the entire purkinje cell layer like so:

Go to edit >> selection >> straighten. Your output will be something like this:

So, now you have all your cells in a rectangular image. You could crop it to 4000 microns width by hand or: write a macro that selects a random 4000 micron width region in this image.

Then the next step is counting cells… which brings up the question of how many of these do you count as cells? The best practice here would be an automated segmentation that defines cells by the same set of rules for every image.

It all depends on how much time you want to invest in this. If you have a lot of images, this would of course save you a ton of time in the end.

Sorry that I couldn’t answer your initial question, but I hope this helps.

Edit: And if you were wondering why this looks different from your image: I used CLAHE to enhance contrast and rolling ball background subtraction to remove some noise.



Hi Sverre,

Thank you so much for your help! I will take your advice and try setting an automated segmentation process. Also, could you specify what values you used for blocksize, histogram bins, and maximum slope for CLAHE and the value of the rolling ball radius? Thanks again!


1 Like

Default settings for CLAHE, 30 for rolling ball. I encourage you to play around with the settings, see if you can improve it :slight_smile:

Good luck with your segmentation, and let us know how it goes!