Auto measuring fiber length? 1000+ measurements?

I have a selection of maybe 1500 fibers here and I need to find a way to measure their length.

that is what the original image looks like.

So far I’ve been able to make it 8-bit, set my scale, and set my threshold to filter out the background noise. If I analyze my particles I can get a width and height but I need a way to gather the length quickly and efficiently.

Is a macro needed?

Please, any help you can give would be much appreciated.

This is the image after threshold adjustment.

Hi Alexander,

I worked on a similar project a few month ago. Measuring all the rods was too complicated to be done quickly so I just measured the non overlapping rods to evaluate the distribution of rods length. Similar to you I binarized the image and then use the feret diameter (see also) of each region to detect the regions that might correspond to overlapping rods.

You can see on the image below the kind of results that are obtained (it is a subpart of your image).

In red the discarded regions, in green the detected lines. There are over 1800 detected lines in you image in your image. Of course results are not perfect but it is still possible to edit errors if necessary prior the measurement step.

You can download the script here if you want to give it a try. The header contains explanation on the script usage and method used. (3.1 KB)

Let me know if you find it useful, in that case I’ll add an entry on the imagej wiki.


Maybe the ridge detection plugin could help?


This is perfect, Benoit!

Thank you for the help on this.

1 Like

Instead of starting a new thread on the same subject, I’d like to revive @Alexander’s original question, make a few observations and finally issue a request. The question raised by Alexander and ably replied to by @Benoit and @twagner (I should note that I’ve been in touch with both of them) is all too familiar to people involved in the characterization of chopped-fiber-reinforced thermoplastic composites, that is, what’s the average length and the length distribution of the brittle carbon, glass or mineral fibers after various high-shear processing steps? Both these characteristics greatly affect the modulus, strength and fatigue properties of the finished product.

While the three offered solutions offer partial answers to the question, none of them seem to be able to deal with multiple instances of such straight fiber segments touching i crossing, often forming groups of more than 2 fibers. The common solution is either treat such groups as one larger Feret diameter fiber (Analyze Particles), which biases the calculated distribution towards the longer objects, or eliminating them from the calculation (rods_analysis or Ridge Detection.) That latter case biases the calculated distribution towards the shorter length values, since longer fibers have a higher probability to cross or touch other objects. Finally, the available reports do not include the Feret diameter (effectively, the max and min length of the objects.

There is one special characteristic of all these fibrous objects that makes them different from many other fibrous or wormy objects analyzed by others, that is, they are all straight (linear) objects with easily determined end points.

I’m not a programmer, but it seems to me that the problem described above is common enough and its solution would greatly benefit numerous researchers and technicians involved in the characterization of these very important materials. The enhanced plugin would have to combine the ability of the several existing utilities (Analyze Particles, Ridge Detection and to isolate and measure the full length (and maybe width) of numerous crossed linear objects (they may form figures similar to upper case letters A, C, E, F, H, K, L, M, N, O, P, R, S, T, U, V, X, Y and Z (the most often seen are bolded; the other figures are seldom seen in practice.), generate a Report exactly like the one associated with the Analyze Particle method, including the chart. The only additional column might mark the type of overlap detected (a letter?).

So, my question is, how does one get people capable of writing such a plugin interested in this extension? I can cite more than 500 papers dealing with this quirky issue which seems to me to be easier to resolve than a bunch of wiggly C. elegans worms: I wish I knew Java and Python… :flushed:


The ridge detection plugin is able to resolve overlapping fibres and measure the complete length. Furthermore it can measure the mean width. The only thing that is missing is an easy summary results table. I will try to add this feature today, but I’m on removal stress :slight_smile:


1 Like

Try out 1.3.0 of ridge detection (it’s on the imagej update site). It should display your summary table.


Thank you, Thorsten, for responding to my questions and request so quickly and providing a solution. I misunderstood the original capability of the plugin to recognize the full length and width of the crossing objects/fibers; now I’ll give your modified plugin a spin. Thanks!


Hi Benoit,
I am trying to run your script in Image J. According to the instructions, I opened the script, the image and tried running the script. But it gave me an error:

Traceback (most recent call last):
File “”, line 82, in
ImportError: No module named os

Line 82 is:
import math, os

I am not sure how to fix this. Is this an issue with the version of Image J I downloaded? Is there a more updated script you could provide me with? I am not too much of a programmer so I don"t know how to fix this issue. Thanks!

Hi @nitikathakral12 ,

Welcome to the forum and apology for my late answer.

Maybe you already find a solution but in case you did not here are some ideas. The error message you posted seems to indicate that the Jython libraries are not visible when you run the script. On top of my head I see 2 reasons for that but maybe there are others:

  1. maybe the script language in the script editor is not set to Python. There should be a language menu where this can be set.
  2. maybe you are using an imagej version that does not ship with the Fiji script editor. In that case, you can download a fresh Fiji from there:

I hope one of these comments can help you.
Good luck with your analysis

Dear the kinds people in here,

Can all of you to help me how to measure the length of this aggregate?because when I am using plugin with ridge detection, some of red area should not to be accounted by using ridge detection. so should I do?here I attach the my aggregate image. please help me. I am frustated with this.thank you170.tif (4.2 MB)