run() function call for "Straight Line Tool"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

run() function call for "Straight Line Tool"

AAM71
Dear Listers,

I have tried to use Macro Record function to generate run() function
call for "Straight Line Tool" but failed. Recorder window does not
reflect anything when I try double click "Straight Line Tool" to get
second argument for this ImageJ menu command.

Can you help me, please?

Sincerely,

Alex Mironov

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

Re: run() function call for "Straight Line Tool"

Wayne Rasband-2
> On Oct 30, 2018, at 11:46 AM, Aleksandr Mironov <[hidden email]> wrote:
>
> Dear Listers,
>
> I have tried to use Macro Record function to generate run() function call for "Straight Line Tool" but failed. Recorder window does not reflect anything when I try double click "Straight Line Tool" to get second argument for this ImageJ menu command.

Selection tools like the Straight Line Tool are recorded when they are used to create a selection. For example, use the Straight Line Tool to create a line selection and a line like

   makeLine(150, 150, 350, 230);

is recorded. Look up makeLine() at

   https://imagej.nih.gov/ij/developer/macro/functions.html

and you will see it has an optional 5th argument (line width) that is not recorded. You can also look up built in functions like makeLine() by using the Function Finder (shift+ctrl+F) in macro editor windows.

-wayne

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

Re: run() function call for "Straight Line Tool"

AAM71
Dear Wayne,

Thank you very much for explanation! However, then the question reverts
to my earlier problem with overlay macro (message "Macro function
setLineWidth does not work properly with overlays"). Citing: "macro
function setLineWidth() does not work properly with overlays if I try to
use value "1" in macro. In this case it reverts to line width set by
double clicking on "Straight Line". If value is anything apart 1 then
setLineWidth() works fine with Overlay.drawLine().

With example macro (To see the effect, please, set first default line
width (by double clicking on "Straight Line") to 1 and then to bigger
number):

----------------
newImage("Untitled", "RGB ramp", 512, 512, 1);
setColor("red");

//Overlay lines
setLineWidth(0);
Overlay.drawLine(0, 50, 512, 50);
Overlay.add;

setLineWidth(1);
Overlay.drawLine(0, 100, 512, 100);
Overlay.add;

setLineWidth(2);
Overlay.drawLine(0, 150, 512, 150);
Overlay.add;

setLineWidth(4);
Overlay.drawLine(0, 200, 512, 200);
Overlay.add;

Overlay.show;
------------------

I was thinking to overcome this problem by setting line width using Straight Line Tool, but from your explanation I understand that it is not possible if I am not using makeLine(). For now the only way to get overlay line thickness of 1 pixel in macro is to set it like setLineWidth(0) because setLineWidth(1) does not work properly (it is overruled by line thickness set with Straight Line Tool).

Sincerely,
Alex


On 31/10/2018 01:11, Wayne Rasband wrote:

>> On Oct 30, 2018, at 11:46 AM, Aleksandr Mironov <[hidden email]> wrote:
>>
>> Dear Listers,
>>
>> I have tried to use Macro Record function to generate run() function call for "Straight Line Tool" but failed. Recorder window does not reflect anything when I try double click "Straight Line Tool" to get second argument for this ImageJ menu command.
> Selection tools like the Straight Line Tool are recorded when they are used to create a selection. For example, use the Straight Line Tool to create a line selection and a line like
>
>     makeLine(150, 150, 350, 230);
>
> is recorded. Look up makeLine() at
>
>     https://imagej.nih.gov/ij/developer/macro/functions.html
>
> and you will see it has an optional 5th argument (line width) that is not recorded. You can also look up built in functions like makeLine() by using the Function Finder (shift+ctrl+F) in macro editor windows.
>
> -wayne
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
Dr. Aleksandr Mironov MD, PhD
Senior Experimental Officer
D.1527, M.Smith Building
EM Core Facility
School of Biological Sciences,
Faculty of Biology Medicine and Health
University of Manchester
Oxford Road
Manchester
M13 9PT
UK

Tel. +44-(0)161-275-5645
E-mail: [hidden email]
https://www.bmh.manchester.ac.uk/research/facilities/electron-microscopy/

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