Drawing Feret and FeretMin as selection



Hi everybody,
I’m relatively new to this forum and to the image analysis at all. I have a (probably trivial) problem to submit you.

I need to measure the pixel intensity (gray values) along some specific profiles of an active selection (i.e. particle). In particular, I need to obtain the profile as a list of pixel grey values along both the Feret diameter (maximum caliper) and FeretMin (minimum caliper) of the selected particle in the reported image.

To do this, at now, I’ve selected the particle and used a macro in order to draw the Feret above the particle and to measure the intensity profile with the command ‘plot profile’, but it resulted in the complete erasure of the original pixel gray values.

So, I need to know how to identify the Feret and FeretMin of an active selection, and to record them for example as straight line selection in order to directly measure the profile using ‘plot profile’.

I provide the image below as an example: I’ve selected the shape of which I’d like to know the profile in pixel intensity along both the Feret and Feret Min.

Tanks in advance for every possible solution or even suggestions



Hi @Pietro_Gabellini ,

There’s information on the ImageJ Users Guide about Feret measurements. You may find the macro example given for FeretDiameter helpful:



Hi @dnmason, thank you so much for your help.
I’ve tried yet with this macro and it works drawing the Ferts above the particle, but unfortunately it results in the complete deletion of the original grey scale values, so that becomes difficult for me to obtain the intensity measures.
But off course, I’ll try to modify the macro.


OK, I think I understand what you mean. What your saying is that using the examples above, draws a line over the image so you can’t read off the profile.

If you want to draw lines and maintain the underlying intensities you need to use non-destructive overlays. Regardless, if you want the intensity profile, you may want to create a line selection from the Feret then use the getProfile() command to pull the intensities.


I’ve taken parts of the macro above and the examples from the macro reference and put together a quick example:

At line 47 the intensity profiles are printed out to the log file but you can obviously take the array profile and process it further, save it out as a file or whatever.

Hope that helps!


Hi Pietro,

concerning a profile along the ‘MinFeret’: Beware that there may be many cases where the solution is arbitrary. E.g. for a rectangle, every line parallel to the shorter side and inside the rectangle is a ‘MinFeret’ line.

Apart from that, one could write similar code as the macro mentioned above https://bitbucket.org/snippets/davemason/nejxxo , with a double loop:

Get the convex hull.
Outer loop:  For all pairs of neighboring edge points of the convex hull:
    Consider the line between these two points.
    Inner loop: For all other points on the convex hull:
        Calculate the distance from that line to the other point
        on the convex hull.
        If we have a maximum distance (compared to all others of the inner loop):
           Save the point of maximum distance and the angle.
   In the outer loop, we need the minimum of all these largest distances:
   When the new distance (maximum distance from the inner loop) is lower
   than the previous minimum obtained in the outer loop:
      Save the point and angle obtained in the inner loop.

[sorry, for some reason the ‘preformatted text’ prints some words in bold. I could not determine how to switch this off]

In case of a rectangle mentioned above, such a code would give you one of the short sides, not the central line.



Hi @dnmason,
yes, exactly, you’ve perfectly matched my needing.
I’ve applied the macro, and it run, but it works correctly for only one particle. I guess the problem is in the correct identification of the convex hull. I’ll try to fix this, but anyway many thanks, it helped a lot…also getting me in confidence with the macro language.


Hi schmid,
Yes what you said about FeretMin it’s definitely true. I didn’t considered that, and thus specified in my help request since my particles are strongly irregular, so that having more that one FeretMin becomes statistically difficult.
Anyway, thanks for your comment, which in case of regular or rectangular-like shapes would be absolutely important to consider.