Counting rectangular objects

I’m a complete beginner on ImageJ, with a trivial problem. I need to count the number of rectangular objects, such as the slides on this photo. Additionally the slides may have different colors (white, black, grey or green) and some of them made of 2 or 3 “layers” of different colors and/or materials.

Thanks for any hints to get me started on the right direction.

Hello Phil,
Welcome to the community. Here is one way to go about it.
First create a ‘Shadow’ (west/east) of your original image (you can find ‘shadow’ under the Process tab). Then change the image to an 8 bit image and do an ‘Invert LUT’ (under Image>>Lookup table). Now you can apply a threshold to get only the ‘shadow’ of your rectangular objects. Screenshot below.

Then go to ‘Analyze Particles’ and set a size between 50-Infinity. You should get the number of rectangular objects now.

Does this help?


Another way would be to measure the peaks of a profile plot. Draw a line and then create a profile plot:

Analyze->Plot Profile (see image below - dark slides easily identifiable in the plot)

From the plot the peaks (number of slides) can be detected, e.g. with:

Essentially the same method as measuring tree rings with ImageJ. So you may find some good tips on the Internet how to improve the measurements by searching for tree ring analysis with ImageJ.

Thanks a lot Praveen & Bio7, can’t give it a try right now, but I’ll keep you posted on my progress from next week. Phil