Login  Register

Re: particle analysis - angle determination

Posted by Jarek Grodek on May 11, 2007; 8:42am
URL: http://imagej.273.s1.nabble.com/Fwd-particle-analysis-angle-determination-tp3699508p3699510.html

Hello Michael,

thanks for your help.
I don't know to much about ImageJ macro language and java... i tried to
combine your code but it doesn't work in a macro...

it is:

run("Set Measurements...", " area fit redirect=None decimal=9");
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Nothing display exclude record");
for (i=0; i<nResults; i++) {
    major = getResult("Major",i);
    minor = getResult("Minor",i);
    angle = getResult("Angle",i);
    area = getResult("Area",i);
    if (major > minor * 1.2 && (angle <45 || angle>135))
 {
      print ((i+1)+": area="+area+", angle="+angle);
    }
}

and what I receive is error message:

"(...) ')' expected in line 3.
<show>=Nothing display exclude record ");" (...)"


I realize that it's dummy, but I have to ask for help or information,
where can I find information about this problem.

The other thing what I was thinking of was how to prepare the macro which
will read width and height of image, and split it in 3 ROIs(upper
rectangle, middle one and bottom rectangle)and will carry detection of
horizontally oriented particles in each of ROI, and in results table it
will be indicated in which ROI particle was found? Images may have
different width and height.

Thanks in advance to you, Michael, and anyone who may be helpful.

Greetings,
Jarek



> Hi Jarek,
>
> just have a look at the Macro language documentation and see
> how the Macro Recorder (Plugins>Macros>Record) records the
> commands you need.
>
> Here is an example that you can use as a starting point:
>
> run("Set Measurements...", " area fit redirect=None decimal=9"); //
> whatever you want to record besides "fit"
> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
> show=Nothing display exclude record"); //whatever options you need
> for (i=0; i<nResults; i++) {
>    major = getResult("Major",i);
>    minor = getResult("Minor",i);
>    angle = getResult("Angle",i);
>    area = getResult("Area",i);
>    if (major > minor * 1.2 && (angle <45 || angle>135)) { //whatever
> kind of criterion you like
>      print ((i+1)+": area="+area+", angle="+angle);  //whatever
> results you are interested in
>    }
> }
>
> Instead of the fit ellipse you can also have a look at the
> bounding rectangle.
>
> Michael
> ________________________________________________________________
>
> On 10 May 2007, at 14:38, Jarek Grodek wrote:
>
>>
>> Hi all,
>>
>> i was wondering how to introduce "angle-tolerance" parameter? i
>> work with
>> binary image were particles are elongated and oriented horizontally
>> and
>> vertically. What i need is to measure only horizontally oriented
>> particles. Isn't it would be nice to introduce this parameter in
>> "Analyze
>> particle" menu where one can set direction of orientation and
>> tolerance of
>> angle?
>>
>> can anyone be so kind and prepare macro which can offer this
>> funcionality?
>> any help extremely appreciated.
>>
>> greetings,
>> jarek
>
>