Login  Register

Re: Roi Manager headless mode

Posted by Michael Schmid on Jan 25, 2016; 1:32pm
URL: http://imagej.273.s1.nabble.com/Roi-Manager-headless-mode-tp5011750p5015451.html

Hi Robert,

using the 'Blobs' sample image with the default threshold, your macro for printing the coordinates works perfectly well.

Note that the particles are numbered, e.g. 1-60, which is the 'natural' numbering that a user would expect.
Nevertheless, the index 'blobs' runs from 0-59 (starting at 0 is the usual convention in Java and ImageJ; with the numbering stack slices in ImageJ being the only exception).
So it is fine that the particle displayed as '1' is addressed by activateSelection(0).
Simply use your macro's index + 1 to get the corresponding label in the image.

Michael
________________________________________________________________
On Jan 22, 2016, at 19:43, Robert Atwood wrote:

> .. and it seems that index flips from 0 to 1 at some point so activateSelection(0) refers to the particle numbered 1 on the overlay :(
>
> Oh well , back to the 'drawing' board .. and it's so close to what I want ..
>
>
>
>
>> -----Original Message-----
>> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
>> Herbie
>> Sent: 22 January 2016 16:01
>> To: [hidden email]
>> Subject: Re: Roi Manager headless mode
>>
>> Dear Robert,
>>
>> I'm not very familiar with "Analyze Particles..." but a quick test with a single
>> elliptic test particle revealed that
>>
>> Roi.getCoordinates(xp,yp);
>>
>> actually returns all co-ordinates of the enclosing contour.
>>
>> So I guess, in order to get the content of the ROI you have either to extract i.e.
>> copy it, or access the content values pixel by pixel wise according to the
>> contour co-ordinates.
>>
>> HTH
>>
>> Herbie
>>
>> :::::::::::::::::::::::::::::::::::::::::::
>> Am 22.01.16 um 14:36 schrieb robert atwood:
>>> Hi All
>>> I came across this thread when trying to extract the detected
>>> particles into a master program using headless mode to call Imagej ,
>>> and encountering the similar problem with the ROI manager.
>>>
>>> I have now tried to use Overlay instead as suggested by Wayne, and to
>>> some extent it works, but I cannot quite obtain the information I
>>> want, which is a list of the pixels in the detected particle.
>>>
>>>
>>> I have used the following:
>>>
>>> run("Analyze Particles...", "size=25-Infinity show=[Overlay Masks]
>>> include record ");
>>>
>>> nblobs=Overlay.size;
>>> print ("nblobs="+nblobs);
>>>
>>> for (blob=0;blob<nblobs;blob++){
>>>    Overlay.activateSelection(blob);
>>>     bname=Roi.getName;
>>>    Roi.getCoordinates(xp,yp);
>>>    for (i=0;i&lt;xp.length;i++){
>>>      print(blob,bname,xp[i],yp[i]);
>>>    }
>>> }
>>>
>>>
>>>
>>>
>>> This seems to behave, but the actual list returned does not make sense
>>> to me and doesn't seem to correspond to the overlay as observed in the
>>> image viewer. Is it actually a list of some other description of the
>>> particle rather than the coordinates, and the number somehow not
>>> correspond to the number printed in the overlay label output?
>>>
>>> For example, blob #39 is listed as follows, but the attached image (I
>>> hope) shows a blob that certainly has more than 4 pixels in it, and is
>>> not anywhere near co-ordinate 3214. Furthermore the co-ordinates
>>> listed do not form a connected object, it seems like the corners of a 5 pixel
>> square.
>>>  &lt;nabble_img src=&quot;imagej_blobnumber.jpg&quot;
>>> border=&quot;0&quot;/>
>>>
>>>
>>>  38  1095 55
>>>  38  1100 55
>>> *
>>>  39  3214 60
>>>  39  3207 60
>>>  39  3207 55
>>>  39  3214 55
>>> *
>>>  40  1729 57
>>>
>>>
>>> What I really want is a list of horizontal start- and end-points for
>>> each row passing through the blob. From a list of all pixels in each blob I
>> can
>>> generate this fairly simply   -- or is there another way to do that inside
>>> imagej already? -- but I want to do it headless on a cluster and use
>>> some quite nice and not so simple processing that is already available
>>> in ImageJ even before the particle analysis.
>>>
>>>
>>> Thanks
>>> Robert
>>>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html