Automating line measurement

Tags: #<Tag:0x00007fd548a57588> #<Tag:0x00007fd548a56f70> #<Tag:0x00007fd548a56ac0>



I am currently measuring the horizontal distance between the two lowest peaks (ie. horizontal distance between 1&2, 3&4, 5&6, etc.). I would like to know if there is a way to make the measurements less tedious, for instance through the usage of macros. Your help will be greatly appreciated. Thanks in advance!

PS. My goal is to measure the band width (Image 2), so I have attached that if that’s easier.

Image 1:

Image 2:


Good day,

yes, an ImageJ-macro could definitely help. Just get the profile as an array and search for minima and order them according to a suitable criterion.

Here is a list of the commented macro functions:

If the troughs would be orthogonal to the long image side, you could reduce the noise by taking not only a line profile but a projection of suitable rectangular selection.




Hello Herbie,

Thanks for the reply. I have recently started using ImageJ, so I am not too familiar with the macros and not sure where to begin.


Start with generating the line selection by using “makeLine(x1, y1, x2, y2);”.
Then get the profile as an array with “array = getProfile();”.
Then learn about the array functions, especially “Array.findMinima(array, tolerance);”.

A general intro to macro coding is given in this document:




Thank you so much Herbie! I got it to detect the minima and display the x values where those minima occur. One last question, though: is there a way to place some kind of a tick mark (like x or *) wherever the minima are?


Look at the plot routines in the list of commented macro functions.
You can draw whatever line segments (as ticks) you want and even in color.

Please try to learn about the available macro functions.