Posted by
Karel Jansseune-2 on
Apr 20, 2009; 10:59am
URL: http://imagej.273.s1.nabble.com/combine-particles-in-ROI-manager-automatically-tp3692844p3692847.html
thank you a lot,
This might be exactely what I need. I already tried it and it looks quite
promising.
regards,
Karel Jansseune
On Mon, 20 Apr 2009 10:05:42 +0000, Tiago Ferreira <
[hidden email]>
wrote:
>Karel Jansseune <karel.jansseune@...> writes:
>
>>
>> For our research we are making images of Arabidopsis plants growing in
>> plates andwe try to measure the area of each plant automatically. In
this
>> way we try to obtain the growth rate of each plant in the plate
>> We successfully made a macro to do the analysis of a folder of images
and
>> return the results in a text file, but now we sometimes have the problem
>> that one plant is divided into two during automatic analysis.
>>
>> Now I was wondering if it is possible to write a macro to instruct
ImageJ
>> to combine the ROIÂs found within a certain distance of each other.
(let
>> say, if the 2 ROIÂs are less than 2mm apart, they should be combined).
>>
>>
>Don't know if this helps, but maybe you could try something like this:
>
>//macro code:
>roiManager("Reset");
>run("Blobs (25K)");
>setAutoThreshold();
>run("Set Measurements...", " centroid");
>run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show="+
>"Nothing display clear");
>minDx=getNumber("Minimum distance between ROIs", 50);
>n=roiManager("count");
>Mlabel="Distance to previous";
>setResult(Mlabel, 0, NaN);
>for(i=0; i<nResults-1; i++) {
> x1= getResult('X', i); y1=getResult('Y', i);
> x2= getResult('X', i+1); y2=getResult('Y', i+1);
> distance= sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
> setResult(Mlabel, i+1, distance);
>}
>updateResults;
>
>for(i=2; i<nResults; i++) {
> distance=getResult(Mlabel, i);
> x1= getResult('X', i-1); y1=getResult('Y', i-1);
> x2= getResult('X', i); y2=getResult('Y', i);
> if(distance<= minDx) {
> doWand(x1,y1);
> setKeyDown("shift");
> doWand(x2,y2);
> roiManager("Add")}
>}
>resetThreshold;
>setOption("Show All", true);
>
>// end
>T.
>=========================================================================