Creating an engulfing Ellipse Roi

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

Creating an engulfing Ellipse Roi

Greg
Hi,

I have a good working Segmentation jython script giving me the nuclei as PolygonRois. I want to extend this nuclear Roi to measure stuff inside the cytoplasm. My Idea is to first fit an Ellipse to the nuclear Rois, which works very good with ImageJs EllipseFitter and gives me an EllipseRoi centered at the nucleus. Now I want to create a new EllipseRoi which is still centered at the nucleus but has a little bit bigger major and minor axes. From the EllipseFitter I get the center coordinates and also the major and minor axes of the nuclei. I drawed this nuclear Rois over my Image and it looks very good. Now when I want to construct a new EllipseRoi, I do not understand its Constructor as it is

EllipseRoi(double x1, double y1, double x2, double y2, double aspectRatio)

how do I get an Ellipse which is has the center and the major and minor axes according to the results from the EllipseFitter? I also tried the EllipseFitter.makeRoi(ip) method, but it returns (also in accordance to the API) nothing?!

In the end my Idea then is to subtract the smaller nuclear Roi from the bigger EllipseRoi giving me an elliptical stripe ROI in the cytoplasm to measure stuff. Roi subtraction will somehow work I guess?

All the best,
Gregor
Reply | Threaded
Open this post in threaded view
|

Re: Creating an engulfing Ellipse Roi

Greg
Ok, so for the Roi subtraction with jython, using the ShapeRoi class and its logical operators works like a charm!
I am still stuck with the widening of the nuclear ellipse though, I guess I just have to infer the math how to translate center, minor and major axes to the Constructor arguments x1,y1,x2,y2,AspectRatio?!
Reply | Threaded
Open this post in threaded view
|

Re: Creating an engulfing Ellipse Roi

Greg
This post was updated on .
Allright, invoking some basic trigonometry and after finally noting the inverted y-axis the transformation from the EllipseFitter (EF) output variables to the EllipseRoi Constructor input variables with jython goes as follows:

    angle = radians(EF.angle)
                                                                                                 
    y1 = EF.yCenter + sin(angle)*0.5*EF.major
    y2 = EF.yCenter - sin(angle)*0.5*EF.major

    x1 = EF.xCenter - cos(angle)*0.5*EF.major
    x2 = EF.xCenter + cos(angle)*0.5*EF.major

    ratio = EF.minor/EF.major

The first line transforms the angle from degrees to radians with the math.radians function from python.
So my original Question is now solved, I will upscale the major and minor axis with some factor 1 < alpha < 2 and subtract the original nuclear Roi from this EllipseRoi to measure stuff in the cytoplasm :)

Cheers,
Greg