Login  Register

Re: Distance measurement displayed in image

Posted by Rasband, Wayne (NIH/NIMH) [E] on May 28, 2014; 6:00pm
URL: http://imagej.273.s1.nabble.com/Distance-measurement-displayed-in-image-tp5007955p5007957.html

On May 28, 2014, at 10:43 AM, Stefan Kapser wrote:

> Dear ImageJ-users,
> it is easy to perform measurements in ImageJ, but the values are always
> displayed in a separate window. Next to the drawn line in the image only
> the measurement number is displayed.
> Is there a way to display the length of the measured straight line directly
> next to this straight line within the image?
> Thanks a lot for your help!
> Stefan

The following is a macro that creates a custom Measure command that labels line selections with the measured length and area selections with the measured area. Installing it creates a Plugins>Macros>Measure and Label [m] command that has a "m" keyboard shortcut. Add it to the ImageJ/macros/StartupMacros.txt file to have it installed when ImageJ starts up.

-wayne

  macro "Measure and Label [m]" {
     run("Measure");
     label = "" + getResult("Length", nResults-1);
     if (label=="NaN" || label=="0")
         label = "" + getResult("Area", nResults-1);
     Roi.setName(label);
     Overlay.addSelection;
  }

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html