1

我有 12 张图片。我正在使用ImageJ/FIJI进行处理。然后我为所有图像统一制作了大小为 2923779(即每点面积 __ 像素 ^2)的网格(使用分析 -> 工具 -> 网格)。它看起来像这样:

在此处输入图像描述

我想要做的是根据网格的每个元素裁剪上面的每个图像并将每个裁剪保存为文件。我怎样才能做到这一点?

可以在此处下载上述文件之一(160MB)。

4

1 回答 1

2

你必须了解 grid.java 的代码才能做你想做的事。在宏中:

dir = getDirectory("the directory with all your files");
files = getFileList(dir);
out = getDirectory ("Select output directory");
number = lengthOf(files); // normally 12 in your case
i=0;
while (i < number) {
    // write a function to extract the x and y coordinates, the width and the height of each rectangle of your grid. For that, you have to understand the code of grid.java to understand how you can have the coordinates of each rectangle.
    listcoordinates = yourfunction(files[i], 2923779);// return a vector of (x0, y0, width0, height0, x1, y1, etc...) => x= x coordinate on the top left of the square, y= y coordinate on the top left of the square
    for(j=0; j<lengthOf(listcoordinates); j+4) //foreach coordinate that you extract
     {
        makeRectangle(listcoordinates[j], listcoordinates[j+1], listcoordinates[j+2], listcoordinates[j+3]);
        run("Duplicate...", "title=blabla"+ i + j +".tif");
        saveAs("Tiff", out+ "blabla" + i + j + ".tif");
     }
}

祝你好运 ;)

于 2016-07-18T11:28:05.790 回答