【问题标题】:How to crop image for every element in the grid using ImageJ/FIJI如何使用 ImageJ/FIJI 裁剪网格中每个元素的图像
【发布时间】:2016-11-09 12:24:53
【问题描述】:

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

我想要做的是根据网格的每个元素裁剪上面的每个图像并将每个裁剪保存为文件。 我该怎么做?

以上文件之一可以下载here (160MB)。

【问题讨论】:

    标签: java image-processing tiff imagej imagej-macro


    【解决方案1】:

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

    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-09-18
      • 2023-03-09
      • 2019-10-18
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 2020-05-02
      相关资源
      最近更新 更多