Counting on image J


I’m new to image J and i’ll try to explain my problem as precisely as i can.
I have to analyse cells on a rat brain image and they appear as black dots on the brain.So i turn my picture into a 8 bit one and use the threshold to make them red.
But when i use the threshold to make them red, some stains on the image and on the brain also become red.

Is there a way to threshold only certains pixels wide things on image J? Or to isolate the little black dots?
Because as far i as know about image J i have to use the paintbrush tool to clear all the stains pixel after pixel.

Please help

Have a look at morphological opening and closing.

Depending on your exact situation, there are also a few other things you could try. If the other stains are in a different region of the brain than the cells, then you could simply crop the image or use some other technique to ignore the region with the stains. Another thing you could try is using the Local Thickness plugin (also provided as part of the BoneJ plugin) after the initial segmentation. This will produce a image where the value of each pixel corresponds to the size of the “object” the pixel belongs to in the segmented image. You could then segment this result to sort by size.

Well it could a lot easier to explain my problem if i could upload pictures… i’ll try the solutions you gave me and keep you updated


actually, this would be super useful :wink:

Since i’m a new user, i can’t. Do you know when i’ll be able to upload pictures?

Hi Vincent,
You should be able to as of now since you responded to anothers comment.

Ok let’s try

It is unlikely that your problem can be resolved with a greyscale threshold because greyscale thresholding does not know anything about the spatial distribution of the grey values on the image (i.e. whether they are dark dots or dark regions), it is histogram based.
You’ll probably have better luck trying to find dark dots that are surrounded by bright pixels using template matching, or morphological domes, or local maxima, or some machine learning method, like the weka segmentation in Fiji.


Agreed. Unfortunately, using these methods could take a while longer to fine-tune. However, after seeing the image, I certainly agree that thresholding probably will never work on this/these image(s).

Vincent0304, if you do use Weka, I would be interested in hearing about your results. I have a similar problem with poor contrast between classes and have yet to get significant improvement (compared to my previous method) using Weka.

Got it Vincent, I’ll take a closer look.


maybe it’s only me: but I can barely find a difference by eye.

1 Like

yes it’s actually a bit more visible on the real picture, but the image quality is not that good.

Thanks a lot, i’ll try to use Weka and keep you updated on the results. Maybe not today though…

Okay i’m trying a new way to solve my problem (Weka does not work thanks to my very old computer)

here’s my image. See those not round red thing? That’s my problem. When i use analyse particules, i try to change the settings but it seems they are included in the analysis (i know cause it’s shown with the “Show : outlines” setting).
Do anyone know a way to not calcule it?

Hello Vincent0304,
First when you use analyze particles it will give you a list of the particles and their area. This is done by the lines size, so in your data the longest line or area will be your outline. Just subtract that data from the rest.
Meanwhile I don’t think that computer age has anything to do with Weka for it is also somewhat aged. So read the help included carefully and try again.
Also it would benefit you to try to correct the illumination slope of the image by using possibly Polynomial Shading corrector available in the Plugins site, or some other type of background smoothing technique.

1 Like

Ok thanks a lot. Sorry but i’m a total rookie, i can’t find the help included. i looked into the fiji app. file and in the file called wekafiles and found nothing.

after Google search: Fiji weka

1 Like

Oh… thanks a lot everybody. I think i’m good now

1 Like