2016-07-07 12 views
1

У меня 12 изображений. Я обрабатываю ImageJ/FIJI. Затем я сделал сетку (используя Analyze -> Tools -> Grid) размером 2923779 (т. Е. Площадь за точку __ пикселей^2) для всех изображений равномерно. Это выглядит следующим образом:Как обрезать изображение для каждого элемента сетки с помощью ImageJ/FIJI

enter image description here

То, что я хочу сделать, это обрезать каждый из изображения выше по каждому элементу сетки и сохранить каждый урожай в виде файла. Как я могу это сделать?

Один из вышеуказанных файлов можно загрузить here (160MB).

ответ

2

Вам нужно понять код 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"); 
    } 
} 

Удачи;)