Drawing non-orthogonal ellipses....and measure "ellipse" question

imagej

#1

Hi all,

is there any supported macro way to (easily) create an ellipse overlay that isn’t orthogonal to the axes? (ie has a rotation specified)

My ultimate goal here is to use measure to identify the best fit ellipse on a selection, and then draw the resulting fitted ellipse back over the image …but it’s proving a bit of a problematic task

I searched and there doesn’t seem to be directly in the supported macro functions.

I did manage to modify an idea here (http://imagej.1557.x6.nabble.com/makeEllipse-defined-by-angle-td4999674.html) for using selection->specify to create an oval selection, then using rotate on that to rotate the selection an arbitrary amount, then using Overlay-> add selection to finally get it into an overlay. …cool idea, if a bit convoluted (I hadn’t seen Overlay->specify before!)

Here’s a rough bit of code that illustrates it:

run(“Specify…”, “width=100 height=150 x=228 y=228 oval centered”);
run(“Rotate…”, “angle=33”);
run(“Add Selection…”)

But the problem with this is there doesn’t seem to be a way to specify the line width or color of the overlay item above - they’re always yellow and 0 width! (setLineWidth and setColor don’t seem to apply when you use “add selection”).

…is there a way to modify an overlay’s color and line width from a macro after it’s created?

My second question is about using measure, with “ellipse” specified, to do a best fit ellipse to a current region. The ellipse measurements returned are major/minor axis lengths and angle.
…but what is the ellipse centre? is it the region’s centroid values?


#2

My ultimate goal here is to use measure to identify the best fit ellipse on a selection

Please study the ImageJ User Guide.
(Edit >> Selection >> Fit Ellipse)

…is there a way to modify an overlay’s color and line width from a macro after it’s created?

Yes, please study the ImageJ User Guide.
(Image >> Overlay >> Overlay Options…)

…but what is the ellipse centre? is it the region’s centroid values?

Yes, of course.
Why don’t you simply try?

Regards

Herbie