Making an ellipse ROI from user input.

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

Making an ellipse ROI from user input.

Ethan Cohen
I have tried several ways to get user input of values for an ellipse to write a macro.
With this macro I can select the ellipse, and draw, but I am not sure how to extract the" x1,y1,x2,y2,aspectRatio" values.

//Blah
macro "MakeEllipse" {

  run("Select None");
  setTool("ellipse");
  setKeyDown("alt");
  print(x1,y1,x2,y2,aspectRatio);
}.

And with this version....
makeEllipse(88, 67, 223, 182, 0.60);   draws an elliptical ROI

But
  waitForUser(makeEllipse...);  // open tool

Or
  run("makeEllipse...", x1, y1, x2, y2, aspectRatio);  // open tool
These all fail..

Ethan.
Ethan Cohen, Ph.D.
Div of Biomedical Physics,
Office of Science and Engineering Labs,
FDA Center for Devices and Radiological Health
White Oak Federal Res Ctr.
10903 New Hampshire Ave.
Silver Spring, MD 20993
\
________________________________


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

Re: Making an ellipse ROI from user input.

Olivier Burri
Dear Ethan,

The way to recover the necessary info from the ellipse is to measure it on the image using either the run("Measure") command or List.setMeasurements as per the demo by Wayne
http://imagej.nih.gov/ij/macros/DrawEllipse.txt

  if (selectionType==-1)
      exit("Area selection required");
  List.setMeasurements;
  //print(List.getList); // list all measurements
  x = List.getValue("X");
  y = List.getValue("Y");
  a = List.getValue("Major");
  b = List.getValue("Minor");
  angle = List.getValue("Angle");
print(x,y,a, b,angle);

If you want to ask the user to draw an ellipse interactively and do not need the angle, you can use
run("Specify...") that will show a menu where the user can enter the values

You then need to use the method above to recover the data.

Another way is to let the user draw using
setTool("ellipse");
waitForUser("Please draw an ellipse and press OK");  

And use the method above once again to recover the information you need.

Finally if you want to prompt the user for a very specific set of coordinates, you can create a dialog.

Dialog.create("Make me an Ellipse");
Dialog.addNumber("X1");
Dialog.addNumber("Y1");
Dialog.addNumber("X2");
Dialog.addNumber("Y2");
Dialog.addNumber("Aspect Ratio");

Dialog.show();
x1 = Dialog.getNumber();
y1 = Dialog.getNumber();
x2 = Dialog.getNumber();
y2 = Dialog.getNumber();
ar = Dialog.getNumber();

// Now make the ellipse
run("makeEllipse...", x1, y1, x2, y2, ar);  

But this is not interactive, so the user will not see if the coordinates are correct.

Hope this helps you..

Best

Oli

Olivier Burri
Image Analyst
BioImaging & Optics Platform
Ecole Polytechnique Federale de Lausanne
EPFL - SV - PTECH - BIOP
Lausanne, Switzerland

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