Login  Register

Help with Macro

Posted by Margiotta, Joseph on Jan 14, 2015; 10:36pm
URL: http://imagej.273.s1.nabble.com/Help-with-Macro-tp5011225.html

I would like to write a macro that allows the user to set the tolerance for the wand tool by clicking on two points that represent the boundaries of light and dark and then take the difference between these values as the tolerance.

This difference value could then be used in a line of code for the macro I have already written and that is now specified as 2500 in the macro below that is set up to draw a perimeter around a light area in a stack of 25 images:


run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel");

setTool("point");

s = selectionType();


if( s == -1 ) {

    exit("There was no selection.");

} else if( s != 10 ) {

    exit("The selection wasn't a point selection.");

} else {

    getSelectionCoordinates(xPoints,yPoints);

    x = xPoints[0];

    y = yPoints[0];

    showMessage("Got coordinates ("+x+","+y+")");

};wait(2000);

w = selectionType();


if( w == -1 ) {

    exit("There was no selection.");

} else if( w != 10 ) {

    exit("The selection wasn't a point selection.");

} else {

    getSelectionCoordinates(xPoints,yPoints);

    x1 = xPoints[0];

    y1 = yPoints[0];

    showMessage("Got coordinates ("+x1+","+y1+")");

}

for (i=1; i<=25; i++) {

j=1*i;

Stack.setSlice(j);

//setTool("wand");

doWand(x, y, 2500, "8-connected");

doWand(x1, y1, 2500, "8-connected");

run("Measure");wait(200);

}


My problem is that I am new to this programming language and I can’t figure out how I input a variable and have the macro use that value in a calculation.

Can anyone out there help?


-- Joseph F. Margiotta, PhD
Dept. of Neurosciences
University of Toledo College of Medicine
3000 Transverse Drive
Block HS 120A   Mail Stop 1007
Toledo, OH  43614
419-383-4119


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