Save the grid as seperate images on ImageJ

Hi all,
I’m using Grid plugin on ImageJ.After the grid selection is there any way to save all the areas as seperate images?

Thanks in advance for any information

Here is a adaptable script which creates rectangular ROI’s in the ROI Manager and saves the Manager ROI’s as individual images.
For a speedup remove the comment of setBatchMode(true) in the first line.

For the execution an image has to be loaded first.

Please adjust the values for your image and the save path location!

x = 0; //the x-start coordinate
y = 0; //the y-start coordinate
width = 50; //the width of the rectangle
height = 50; //the height of the rectangle
spacing = 0; //spacing between the rectangles
numRow = 5; //how many rows
numCol = 5; //how many columns

/*Create the selections and add them to the ROI Manager!*/
for (i = 0; i < numRow; i++) {
    for (j = 0; j < numCol; j++) {
        xOffset = j * (width + spacing);
        yOffset = i * (height + spacing);
        /*Create a rectangular selection!*/
        makeRectangle(x + xOffset, y + yOffset, width, height);
        /*Add the selection to the ROI Manager!*/
/*Show all selections in the image with (mouse) selectable labels!*/
roiManager("Show All with labels");
for (u = 0; u < roiManager("count"); ++u) {
    run("Duplicate...", "title=crop");
    roiManager("Select", u);
    saveAs("Tiff", "I:/GridSections/" + "Grid_Section_" + (u + 1) + ".tif");
    //Next round!

Exactly what I needed,works smoothly!
Thank you very much for your quick reply!

Best regards

Another quick question.How can I save the images with the specific names given in the region of interest?

Thanks a lot in advance.

You can use:

Returns the selection name or an empty string if the selection does not have a name.