Feature request: make line selection tool show dx/dy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Feature request: make line selection tool show dx/dy

Adrian Daerr-2
Hello,

I frequently use the line selection tool to measure the speed on
kymographs[1] (also known as spatio-temporal diagrams), which are images
where one dimension (say the horizontal) is a spatial dimension, and the
other (say the vertical) is a temporal dimension. A moving object or
interface produces an oblique trace, whose speed is just the slope dx/dy
(assuming, as above, that the y axis represents time).

[1] https://en.wikipedia.org/wiki/Kymograph

To get the speed or slope of a trace, I use the line selection tool to
visually fit a tangent to this trace. This tool shows the angle of the
line in the status bar of the main application window, and computing its
tangent yields the slope in the chosen units.

I wonder if it were possible for the line selection tool to show the two
increments dx and dy of the line selection - that is the x and y offsets
of the current point to the starting point -  'live' in the statusbar
along with the other information ? The increments are more meaningful as
measurements than the angle in my use case, and the calculations become
less error-prone (e.g. when using the angle, depending on which
dimension is the time, one must take either the tangent or the
cotangent, and the wrong choice may go unnoticed for a while). Moreover
the spatial and temporal measurement intervals - that is the length of
the fitted line segment - are lost in this process, and thus estimating
the uncertainty from the angle alone is impossible.

If that makes the infoline too long, one could add to the line selection
tool options (currently only line width) the possiblity to choose what
data is shown (I am very rarely interested in the x/y coordinates of the
cursor location when I use this tool for example, and would happily
trade them for the dx/dy of the segment).

I am aware of at least two work-arounds:

1) finishing the line selection (second mouse click) and doing a
measurement with 'bounding box' selected will give me the desired
increments as 'Width' and 'Height' in the measurement results table.

2) using the rectangle selection tool provides the increments between
current and starting points as Width and Height in the statusbar, but
fitting the invisible diagonal of the rectangle to the trace via just
the two corners is much less reliable and reproducible than visually
fitting a line to the entire trace.

If there is an easy way of replacing/customising the status bar
information via a macro or plugin, that could be an interesting and
flexible solution.

So this is merely a feature request to ease the workflow.

Thanks for reading up to here,
cheers,
Adrian

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: make line selection tool show dx/dy

Jan Eglinger
Hi Adrian,

you might want to create a custom line selection tool for this. Here's
an example (mind the possible line breaks introduced by the mail client
- that's one of the reasons I prefer the image.sc forum over the mailing
list):


// Author: Jan Eglinger
macro "Kymograph Line Selection Tool - L1af1Ca00V0933Ve033C00fL1afaLfaf1" {
     var leftButton = 16;
     getCursorLoc(x, y, z, flags);
     x0 = x;
     y0 = y;
     while (true) {
         getCursorLoc(x, y, z, flags);
         makeLine(x0, y0, x, y);
         showStatus("dx: " + (x-x0) + "; dy: " + (y-y0));
         if (flags&leftButton==0) {
             return;
         }
     }
}






On 2020-01-06 12:43 PM, Adrian Daerr wrote:

> Hello,
>
> I frequently use the line selection tool to measure the speed on
> kymographs[1] (also known as spatio-temporal diagrams), which are images
> where one dimension (say the horizontal) is a spatial dimension, and the
> other (say the vertical) is a temporal dimension. A moving object or
> interface produces an oblique trace, whose speed is just the slope dx/dy
> (assuming, as above, that the y axis represents time).
>
> [1] https://en.wikipedia.org/wiki/Kymograph
>
> To get the speed or slope of a trace, I use the line selection tool to
> visually fit a tangent to this trace. This tool shows the angle of the
> line in the status bar of the main application window, and computing its
> tangent yields the slope in the chosen units.
>
> I wonder if it were possible for the line selection tool to show the two
> increments dx and dy of the line selection - that is the x and y offsets
> of the current point to the starting point -  'live' in the statusbar
> along with the other information ? The increments are more meaningful as
> measurements than the angle in my use case, and the calculations become
> less error-prone (e.g. when using the angle, depending on which
> dimension is the time, one must take either the tangent or the
> cotangent, and the wrong choice may go unnoticed for a while). Moreover
> the spatial and temporal measurement intervals - that is the length of
> the fitted line segment - are lost in this process, and thus estimating
> the uncertainty from the angle alone is impossible.
>
> If that makes the infoline too long, one could add to the line selection
> tool options (currently only line width) the possiblity to choose what
> data is shown (I am very rarely interested in the x/y coordinates of the
> cursor location when I use this tool for example, and would happily
> trade them for the dx/dy of the segment).
>
> I am aware of at least two work-arounds:
>
> 1) finishing the line selection (second mouse click) and doing a
> measurement with 'bounding box' selected will give me the desired
> increments as 'Width' and 'Height' in the measurement results table.
>
> 2) using the rectangle selection tool provides the increments between
> current and starting points as Width and Height in the statusbar, but
> fitting the invisible diagonal of the rectangle to the trace via just
> the two corners is much less reliable and reproducible than visually
> fitting a line to the entire trace.
>
> If there is an easy way of replacing/customising the status bar
> information via a macro or plugin, that could be an interesting and
> flexible solution.
>
> So this is merely a feature request to ease the workflow.
>
> Thanks for reading up to here,
> cheers,
> Adrian
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: make line selection tool show dx/dy

Herbie
In reply to this post by Adrian Daerr-2
Good day Adrian,

here is a macro that may help:

macro "straightLineParams [l]" {
  h=getHeight()-1;
  while (is("line")) {
    getLine(x1, y1, x2, y2, lineWidth);
    s=(y1-y2)/(x2-x1);
    c=round(h-y1-s*x1);
    showStatus("slope="+s+"; y-intercept="+c);
  }
}

Please install the macro and make a line-selection, then type "l" and any
changes you make to the line will be displayed as the slope and the
y-intercept in the status bar.

Please note that slope and intercept are relative to the bottom left corner
of the image. If you prefer another convention, it is easy to adapt the
above macro code.

HTH

Herbie



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: make line selection tool show dx/dy

Adrian Daerr-2
In reply to this post by Jan Eglinger
Thank you Jan and Herbie for your macros, using them will make the
measurements a breeze, especially once I figure out how to get scaled
lengths in addition to pixel dimensions.

The nice icon is much appreciated too @imagejan :-)

Adrian


On 06/01/2020 14.31, Jan Eglinger wrote:

> Hi Adrian,
>
> you might want to create a custom line selection tool for this. Here's
> an example (mind the possible line breaks introduced by the mail client
> - that's one of the reasons I prefer the image.sc forum over the mailing
> list):
>
>
> // Author: Jan Eglinger
> macro "Kymograph Line Selection Tool - L1af1Ca00V0933Ve033C00fL1afaLfaf1" {
>      var leftButton = 16;
>      getCursorLoc(x, y, z, flags);
>      x0 = x;
>      y0 = y;
>      while (true) {
>          getCursorLoc(x, y, z, flags);
>          makeLine(x0, y0, x, y);
>          showStatus("dx: " + (x-x0) + "; dy: " + (y-y0));
>          if (flags&leftButton==0) {
>              return;
>          }
>      }
> }
>
>
>
>
>
>
> On 2020-01-06 12:43 PM, Adrian Daerr wrote:
>> Hello,
>>
>> I frequently use the line selection tool to measure the speed on
>> kymographs[1] (also known as spatio-temporal diagrams), which are
>> images where one dimension (say the horizontal) is a spatial
>> dimension, and the other (say the vertical) is a temporal dimension. A
>> moving object or interface produces an oblique trace, whose speed is
>> just the slope dx/dy (assuming, as above, that the y axis represents
>> time).
>>
>> [1] https://en.wikipedia.org/wiki/Kymograph
>>
>> To get the speed or slope of a trace, I use the line selection tool to
>> visually fit a tangent to this trace. This tool shows the angle of the
>> line in the status bar of the main application window, and computing
>> its tangent yields the slope in the chosen units.
>>
>> I wonder if it were possible for the line selection tool to show the
>> two increments dx and dy of the line selection - that is the x and y
>> offsets of the current point to the starting point -  'live' in the
>> statusbar along with the other information ? The increments are more
>> meaningful as measurements than the angle in my use case, and the
>> calculations become less error-prone (e.g. when using the angle,
>> depending on which dimension is the time, one must take either the
>> tangent or the cotangent, and the wrong choice may go unnoticed for a
>> while). Moreover the spatial and temporal measurement intervals - that
>> is the length of the fitted line segment - are lost in this process,
>> and thus estimating the uncertainty from the angle alone is impossible.
>>
>> If that makes the infoline too long, one could add to the line
>> selection tool options (currently only line width) the possiblity to
>> choose what data is shown (I am very rarely interested in the x/y
>> coordinates of the cursor location when I use this tool for example,
>> and would happily trade them for the dx/dy of the segment).
>>
>> I am aware of at least two work-arounds:
>>
>> 1) finishing the line selection (second mouse click) and doing a
>> measurement with 'bounding box' selected will give me the desired
>> increments as 'Width' and 'Height' in the measurement results table.
>>
>> 2) using the rectangle selection tool provides the increments between
>> current and starting points as Width and Height in the statusbar, but
>> fitting the invisible diagonal of the rectangle to the trace via just
>> the two corners is much less reliable and reproducible than visually
>> fitting a line to the entire trace.
>>
>> If there is an easy way of replacing/customising the status bar
>> information via a macro or plugin, that could be an interesting and
>> flexible solution.
>>
>> So this is merely a feature request to ease the workflow.
>>
>> Thanks for reading up to here,
>> cheers,
>> Adrian
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Feature request: make line selection tool show dx/dy

Herbie
Bonjour Adrian,

here is a version of the suggested macro that gives the y-intercept in
scaled units:

macro "straightLineParams [l]" {
    h=getHeight()-1;
    while (is("line")) {
       getLine(x1, y1, x2, y2, lw);
       s=(y1-y2)/(x2-x1);
       y=h-y1-s*x1;
       toScaled(y);
       showStatus("slope="+d2s(s,2)+", interceptY="+d2s(y,0));
    }
}

Please adjust the number of displayed decimals according to your needs!
d2s(s,2); // two decimals
d2s(y,0); // no decimals

Regards

Herbie

::::::::::::::::::::::::::::::::::::::::::
Am 07.01.20 um 12:49 schrieb Adrian Daerr:

> Thank you Jan and Herbie for your macros, using them will make the
> measurements a breeze, especially once I figure out how to get scaled
> lengths in addition to pixel dimensions.
>
> The nice icon is much appreciated too @imagejan :-)
>
> Adrian
>
>
> On 06/01/2020 14.31, Jan Eglinger wrote:
>> Hi Adrian,
>>
>> you might want to create a custom line selection tool for this. Here's
>> an example (mind the possible line breaks introduced by the mail
>> client - that's one of the reasons I prefer the image.sc forum over
>> the mailing list):
>>
>>
>> // Author: Jan Eglinger
>> macro "Kymograph Line Selection Tool -
>> L1af1Ca00V0933Ve033C00fL1afaLfaf1" {
>>      var leftButton = 16;
>>      getCursorLoc(x, y, z, flags);
>>      x0 = x;
>>      y0 = y;
>>      while (true) {
>>          getCursorLoc(x, y, z, flags);
>>          makeLine(x0, y0, x, y);
>>          showStatus("dx: " + (x-x0) + "; dy: " + (y-y0));
>>          if (flags&leftButton==0) {
>>              return;
>>          }
>>      }
>> }
>>
>>
>>
>>
>>
>>
>> On 2020-01-06 12:43 PM, Adrian Daerr wrote:
>>> Hello,
>>>
>>> I frequently use the line selection tool to measure the speed on
>>> kymographs[1] (also known as spatio-temporal diagrams), which are
>>> images where one dimension (say the horizontal) is a spatial
>>> dimension, and the other (say the vertical) is a temporal dimension.
>>> A moving object or interface produces an oblique trace, whose speed
>>> is just the slope dx/dy (assuming, as above, that the y axis
>>> represents time).
>>>
>>> [1] https://en.wikipedia.org/wiki/Kymograph
>>>
>>> To get the speed or slope of a trace, I use the line selection tool
>>> to visually fit a tangent to this trace. This tool shows the angle of
>>> the line in the status bar of the main application window, and
>>> computing its tangent yields the slope in the chosen units.
>>>
>>> I wonder if it were possible for the line selection tool to show the
>>> two increments dx and dy of the line selection - that is the x and y
>>> offsets of the current point to the starting point -  'live' in the
>>> statusbar along with the other information ? The increments are more
>>> meaningful as measurements than the angle in my use case, and the
>>> calculations become less error-prone (e.g. when using the angle,
>>> depending on which dimension is the time, one must take either the
>>> tangent or the cotangent, and the wrong choice may go unnoticed for a
>>> while). Moreover the spatial and temporal measurement intervals -
>>> that is the length of the fitted line segment - are lost in this
>>> process, and thus estimating the uncertainty from the angle alone is
>>> impossible.
>>>
>>> If that makes the infoline too long, one could add to the line
>>> selection tool options (currently only line width) the possiblity to
>>> choose what data is shown (I am very rarely interested in the x/y
>>> coordinates of the cursor location when I use this tool for example,
>>> and would happily trade them for the dx/dy of the segment).
>>>
>>> I am aware of at least two work-arounds:
>>>
>>> 1) finishing the line selection (second mouse click) and doing a
>>> measurement with 'bounding box' selected will give me the desired
>>> increments as 'Width' and 'Height' in the measurement results table.
>>>
>>> 2) using the rectangle selection tool provides the increments between
>>> current and starting points as Width and Height in the statusbar, but
>>> fitting the invisible diagonal of the rectangle to the trace via just
>>> the two corners is much less reliable and reproducible than visually
>>> fitting a line to the entire trace.
>>>
>>> If there is an easy way of replacing/customising the status bar
>>> information via a macro or plugin, that could be an interesting and
>>> flexible solution.
>>>
>>> So this is merely a feature request to ease the workflow.
>>>
>>> Thanks for reading up to here,
>>> cheers,
>>> Adrian
>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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