ImageJ常用Macro

发布于 2022-10-12  515 次阅读


Please refresh the page if equations are not rendered correctly.
---------------------------------------------------------------

加载图片并打开ROI选区管理器

// loadImage.ijm

run("Image Sequence...", "open = Path/220000.tif sort");

//run("Brightness/Contrast...");

run("Enhance Contrast", "saturated=0.35");
run("Apply LUT", "stack");

//run("Flip Vertically", "stack");

run("ROI Manager...");

遍历ROI管理器中的选区并反选填充

for(i = 0; i < 704; i++){
    roiManager("Select", i);
    run("Make Inverse");
    run("Fill", "slice");
}

ROI_rename (选区改名)

run("Select None");//Remove all the selections
length_ROI = 176
image_roi = getTitle();


for(i = 0; i < length_ROI; i++){
  roiManager("Select", i);
  rName = Roi.getName();
  roiManager("Rename", rName + "-0000-0000");

}

遍历选区并填充或删除选区

roi_name = "warp_26.zip";
n_slice = 96;
open("C:/Users/AQ84510/Desktop/roi/bg.tif");
roiManager("Open", "C:/Users/AQ84510/Desktop/roi/warp/" + roi_name );

setForegroundColor(255, 255, 255);
setBackgroundColor(0, 0, 0);
for (i = 0; i < n_slice ; i++){
roiManager("Select", i);
roiManager("Fill");
}

roiManager("Deselect");

run("Rotate... ", "angle=180 grid=1 interpolation=Bilinear stack");

for (i = 0; i < n_slice ; i++){
roiManager("Select", 0);
run("Create Selection");
run("Make Inverse");
roiManager("Add");
roiManager("Select", 0);
roiManager("Delete");
}

roiManager("Sort");

setForegroundColor(0, 0, 0);
setBackgroundColor(255, 255, 255);
run("Select All");
roiManager("Fill");

roiManager("Save", "C:/Users/AQ84510/Desktop/roi/" + roi_name);
//roiManager("Delete");

close();

平移选区

rgb = 0;


for(index = 56; index < 70; index++){

xTranslate = 10;
yTranslate= -112;

roiManager("Open", "C:/Users/AQ84510/Desktop/roi/weft/weft_" + index + ".zip");

count = roiManager("count");

array = newArray(count);

for (i=0; i<array.length; i++) {
  array[i] = i;
  roiManager("Select", i);
  run("Translate... ", "x=xTranslate y=yTranslate");
  roiManager("Update");

  xTranslate = xTranslate - 9 / count;
  yTranslate = yTranslate - 0 / count;
}

roiManager("select", array);

roiManager("Sort");
roiManager("Interpolate ROIs");

count = roiManager("count");

array = newArray(count);
  for (i=0; i<array.length; i++) {
      array[i] = i;
  }

roiManager("select", array);

setForegroundColor(rgb, rgb, rgb);
roiManager("Fill"); 
roiManager("Deselect");
roiManager("Save", "C:/Users/AQ84510/Desktop/roi/weft_" + index + ".zip");
roiManager("Delete");

rgb = rgb + 0;

}
届ける言葉を今は育ててる
最后更新于 2023-12-17