Last active
March 27, 2023 17:21
-
-
Save T4mmi/6c37de32adcd67d46e3d1e7b7b966ba1 to your computer and use it in GitHub Desktop.
Batch rotate image AND ImageJ markers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro "Batch rotate images and annotations" { | |
/* Read images in a chosen directory and rotate them along | |
with the annotations (points) and store them inplace */ | |
source_dir = getDirectory("Choose an input Directory "); // window to select the input directory | |
dest_dir = getDirectory("Choose an output Directory "); // window to select the output directory | |
list = getFileList(source_dir); // list files in it | |
angle = getNumber("choose the clockwise rotation angle", 90); | |
setBatchMode(true); // activate batch process | |
for (i=0; i<list.length; i++) { // loop over files | |
showProgress(i, list.length); // update progressbar | |
file_name = list[i]; | |
if (endsWith(file_name, ".tif")) { | |
file_path = source_dir + file_name; | |
new_path = dest_dir + file_name; | |
open(file_path); // open the current image | |
run("Rotate...", "rotate angle=" + angle); | |
run("Rotate... ", "angle=" + angle + " grid=1 interpolation=None"); | |
save(new_path); | |
close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment