Slope Fit and Measure — ImageJ macro

screenshot of slope fit and measure macro

Quick links

Slope fitting and measurement into table

This plug-in is designed to interactively measure slopes on images. It provides a tool to draw a line selection onto an image, and two keyboard shortcuts. The first shortcut triggers a fit procedure to improve the adjustment of the line selection to an intensity step or peak in the underlying image data. The second logs the slope measurement to a table, which can then be exported in CSV format for further processing.

For questions and some (limited) support see the following discussion on the ImageJ forum: https://forum.image.sc/t/line-selection-tool-for-kymograph-velocity-measurement/32723

Video introduction

ImageJ/Fiji can do that already, can’t it ? Why this tool ?

One can indeed measure the orientation of some feature using the existing line selection tool, and either read the angle shown live in the main window, or use the Measure tool in the Analyze menu to log the angle to a measurement table.

This tool is nevertheless interesting for two reasons:

  1. In some cases you are more interested in the slope than in the angle. Of course computing the tangent or cotangent of the angle will get you the slope, but it requires one processing step that slows your measurement process. Moreover the horizontal and vertical measurement intervals - or the length of the fitted line segment - are lost in this process, and thus estimating the uncertainty from the angle alone is impossible. A typical case is the measurement of a velocity on a space-time diagram (also called a strip-videograph or kymograph), see video example below.

  2. The precision you get from adjusting the line by eye and mouse is limited, not least by the fact that your line selection endpoints move in steps determined by your screen resolution and zoom level when positioned manually. This tool can attempt to fit the line more closely to the underlying pixel data.

Installation

Installation video

Usage

Click on the tool icon in the main ImageJ window, then draw a line selection. The status bar in the main window shows the line’s horizontal and vertical increments.

Two keyboard commands are available while the tool is active:

Usage video 1 — sandpile slopes

Hit the full screen button (typically lower right corner) to see the details, best viewed with a screen resolution of 1920x1080 or more.

Usage video 2 — velocity measurement on space-time-diagrams / kymographs / strip-videographs

Author, copyright, distribution policy and disclaimer

Copyright 2020,2025 Jan Eglinger & Adrian Daerr

This macro is distributed under the GNU General Public Licence, version 3. The licencing text can be found on the site of the Free Software Foundation at http://www.fsf.org/

If you require another licence please contact the authors.

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. THE PROGRAM IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.


Last modified: 26 Aug 2026