Segmenting a ROI

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

Segmenting a ROI

flettster
Hi

I have a donut (with a hole in the middle) shaped ROI (an outer circle with an inner circle to create a ring). I need to split it into 6 equal parts to create six ROI's something like this:



Any ideas how to do this without rewriting the good book?

Thanks in advance as always

Andy
Reply | Threaded
Open this post in threaded view
|

Re: Segmenting a ROI

Nathaniel Ryckman
Here is an idea:

1) Duplicate the Roi's
2) Use colors, clear, and fill command to make a black ring on a white canvas
3) Get coordinates of center of small circle, size of small circle, and size of big circle
4) Draw white lines to segment the donut
(big radius - small radius = length of lines, startY = centerY + radius * sin(iterator * 2pi/6 + 0), startX = centerX + radius * cos(iterator * 2pi/6 + 0), starting point + length = end point)
5) Particle analyzer

I hope that helps get you started. Definitely double check the math since I didn't double check it very well.

Good luck!  

flettster wrote
Hi

I have a donut (with a hole in the middle) shaped ROI (an outer circle with an inner circle to create a ring). I need to split it into 6 equal parts to create six ROI's something like this:



Any ideas how to do this without rewriting the good book?

Thanks in advance as always

Andy
Reply | Threaded
Open this post in threaded view
|

Re: Segmenting a ROI

flettster
That is a great idea!

Thank you

Only thing i would be worried about would be that the area under the white lines would be outside of the segments? That would not be ideal, how thin could the lines be?

And i dont understand what the iterator is? is it a function in imagej?

I guess i would use getSelectionbounds to calculate the center of the circle = x+halfwidth,y+half height.(and the radius) - or is there a direct method?

And why am i adding 0?

And the instruction so far would draw just one line? I just need to figure out the other 5.

Thanks

Andy
Reply | Threaded
Open this post in threaded view
|

Re: Segmenting a ROI

Nathaniel Ryckman
"Only thing i would be worried about would be that the area under the white lines would be outside of the segments?"

What you could do is make 6 duplicates of the donut (one to process/retrieve each segment)  and then make the white lines so they are just outside the segment that you are trying to create (I'm not sure about the math to calculate "just outside" off hand, but it should just be more trig).

"That would not be ideal, how thin could the lines be?"

I'm fairly certain that the white lines could be 1 pixel in diameter, but, if you are using 1 duplicate of the donut for each segment that you are trying to retrieve, you can make the diameter much bigger than 1 pixel to be on the safe side.

"And i dont understand what the iterator is? is it a function in imagej?"

The iterator would be a variable that you would create that would iterate through the numbers 0 through 5.

"And the instruction so far would draw just one line? I just need to figure out the other 5."

This is what the iterator would be used for.

"I guess i would use getSelectionbounds to calculate the center of the circle = x+halfwidth,y+half height.(and the radius) - or is there a direct method?"

That would probably be the easiest way. You could also use the measure command and pull xc and yc from the Results table.

Here's a  small discussion I found about manipulating circles:
http://imagej.588099.n2.nabble.com/automatically-draw-a-ROI-circle-td3056517.html

"And why am i adding 0?"

I was just thinking that you might decide to draw the first line at 0 radians, but you could really start from any position.

Just to warn you, there are some preciseness issues that have the potential to be nasty problems if you need extreme preciseness due to the nature of pixels. If you are going to worry about pixelation issues, you might want to even consider making a Java plugin instead of a macro because this seemingly small issue can turn into a major project.

Rounding situations (coordinates are integers which can be problem for center, not a perfect curve, trig calculations will have to be rounded, imperfect diagonal lines, etc.).

Good luck!

flettster wrote
That is a great idea!

Thank you

Only thing i would be worried about would be that the area under the white lines would be outside of the segments? That would not be ideal, how thin could the lines be?

And i dont understand what the iterator is? is it a function in imagej?

I guess i would use getSelectionbounds to calculate the center of the circle = x+halfwidth,y+half height.(and the radius) - or is there a direct method?

And why am i adding 0?

And the instruction so far would draw just one line? I just need to figure out the other 5.

Thanks

Andy