Re: generate ROIs around X,Y co-ordinate list
Posted by
Schebique on
Mar 27, 2009; 8:12am
URL: http://imagej.273.s1.nabble.com/Re-generate-ROIs-around-X-Y-co-ordinate-list-tp3693172p3693175.html
Hi.
may be you can find this code also usefull:
// This macro demonstrates how to add particle analyzer
// outlines to the ROI Manager. Note that doWand() may
// not work reliably unless the objects being traced
// have been highlighted in red using setThreshold().
requires("1.33f");
for (i=0; i<nResults; i++) {
x = getResult('XStart', i);
y = getResult('YStart', i);
doWand(x,y);
roiManager("add");
}
Damon Poburko napsal(a):
> Wayne Rasband wrote:
>>> Hi All,
>>>
>>> I am trying to automate segmentation of small fluorescence events.
>>> In the process, I was planing on using the Analyze particles to help
>>> with this job. So far so good. But I am wondering how I might go
>>> about using the centroid X.Y position from the particle analysis to
>>> then go back and create ROIs of a predetermined size around the list
>>> of centroid co-ordinates. In theory this shouldn't be hard, but I'm
>>> at a loss for how to code it (i.e. gather the XY list from the
>>> results table and hand it to the ROI manager or generate regions).
>>
>> You can do this using a macro that retrieves the X and Y coordinates
>> from the Results table and uses them to generate ROIs of a
>> predetermined size. This example runs the particle analyzer on the
>> blobs sample image and, for each particle found, generates a radius
>> 15 circular ROI and adds it to the ROI Manager.
>>
>> radius = 15;
>> run("Blobs (25K)");
>> setAutoThreshold();
>> run("Set Measurements...", "area mean centroid redirect=None");
>> run("Analyze Particles...", "size=0 circularity=0.00 display
>> exclude clear");
>> resetThreshold();
>> roiManager("reset");
>> for (i=0; i<nResults; i++) {
>> x = getResult("X", i);
>> y = getResult("Y", i);
>> makeOval(x-radius, y-radius, radius*2, radius*2);
>> run("Add to Manager ");
>> }
>> setOption("Show All",true);
>>
>> -wayne
> Wayne & Chris,
>
> Perfect. That was exactly what I was looking for. That saved me a lot
> of time.
>
> Many thanks,
> Damon
>