Setting point on every image individually

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

Setting point on every image individually

perpetuum_mobile
Greetings,

i'm writing a plugin for spot detection (I'm aware that such a plugin already exists, however I'm trying a bit around by using different algorithms ;-) ). So far the algorithm returns a list with coordinates that represent the detected spots along the image stack.

The question now:
How can I implement in ImageJ to mark on each slice of the image stack the spot individually?. E.g. if I use via the GUI the point-tool, the point that I marked (let's say on slice 42) will also be marked on the next slice at the same coordinates, - how can I now set individually a mark on each slice with the coordinates of the spot determined by my algorithms?

Thank you in advance for any hints and

best regards

Dan
Reply | Threaded
Open this post in threaded view
|

Re: Setting point on every image individually

Rasband, Wayne (NIH/NIMH) [E]
On Jun 23, 2013, at 4:41 AM, perpetuum_mobile wrote:

> Greetings,
>
> i'm writing a plugin for spot detection (I'm aware that such a plugin
> already exists, however I'm trying a bit around by using different
> algorithms ;-) ). So far the algorithm returns a list with coordinates that
> represent the detected spots along the image stack.
>
> The question now:
> How can I implement in ImageJ to mark on each slice of the image stack the
> spot individually?. E.g. if I use via the GUI the point-tool, the point that
> I marked (let's say on slice 42) will also be marked on the next slice at
> the same coordinates, - how can I now set individually a mark on each slice
> with the coordinates of the spot determined by my algorithms?

Add the points to an overlay. Here is example JavaScript code that creates a stack with 10 slices and adds an overlay to it containing 10 points, each point associated with a different slice. There is also code that retrieves the 10 points from the overlay and displays their stack positions and locations.

  n = 10;
  imp = IJ.createImage("Untitled", "8-bit black", 500, 500, n);
  overlay = new Overlay();
  for (i=1; i<=n; i++) {
     point = new PointRoi(i*40, i*40);
     point.setPosition(i);
     overlay.add(point);
  }
  imp.setOverlay(overlay);
  imp.show();

  for (i=0; i<n; i++) {
     point = overlay.get(i);
     position = point.getPosition();
     bounds = point.getBounds();
     IJ.log(position+" "+bounds.x+" "+bounds.y);
  }

To use the GUI point tool, double click on the point tool icon and check "Auto-Next Slice" and "Add to ROI Manager". Now, when you click on a stack slice with the point tool, the point will be added to the ROI Manager, it will be associated with the slice you clicked on and the stack will advance to the next slice. Points will only be displayed on their associated slice as long as "Associate 'Show All' ROIs with Slices" is checked in the ROI Manager's More>>Options dialog box. Here is JavaScript code that shows how a plugin can retrieve the locations and stack positions of the points from the ROI Manager.

  manager = RoiManager.getInstance();
  points = manager.getRoisAsArray();
  for (i=0; i<points.length; i++) {
     position = points[i].getPosition();
     bounds = points[i].getBounds();
     IJ.log(i+" "+position+" "+bounds.x+" "+bounds.y);
  }

-wayne

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