Export area around point in ImageJ


I have a TIFF image which is annotated with the point tool in ImageJ. I would like to export the area (x pixels by x pixels) around the points, creating multiple images.

How can I proceed to do so?

Thanks for the assistance.

Hello Pierre -

I believe that you will need a script or macro to do this.

The point tool produces PointRois on your image. Let’s
assume that you have added these PointRois to the ROI
Manager. You can then build square Rois from the PointRois
in the ROI Manager and use them to crop your image.

The following jython (python) script illustrates this with the
“Clown (14K)” sample image:

from ij import IJ
from ij.gui import PointRoi
from ij.gui import Roi
from ij.plugin.frame import RoiManager

# create example PointRois and add to ROI Manager
rm = RoiManager()
rm.addRoi (PointRoi (85, 45))
rm.addRoi (PointRoi (195, 45))
rm.addRoi (PointRoi (45, 110))

# open example image
IJ.run ('Clown (14K)')
imp = IJ.getImage()

lCrop = 30   # crop square with side of 30 pixels

# use this if you have opened the ROI Manager manually
# rm = RoiManager.getInstance()

# create cropped images and save
# (could save as 'TIFF' -- 'PNG' used for forum convenience)
# assumes that our Rois are all PointRois containing exactly one point
for  i in range (rm.getCount()):
	pt = rm.getRoi (i).getContainedPoints()[0]
	imp.setRoi (Roi (pt.x - lCrop / 2, pt.y - lCrop / 2, lCrop, lCrop))
	impCrop = imp.crop()
	IJ.saveAs (impCrop, 'PNG', 'crop-' + str (i + 1))

Here are the resulting cropped images:




Thanks, mm