Super new to writing macros and have learned a bunch from this forum already. I am trying to perform the following workflow on a folder of images:
- Open Original
- Copy Original, make new, identical image.
- Change threshold on New Image.
- Convert to Mask.
- Divide by 255.
- Use Image Calculator to multiply ORIGINAL image times NEW IMAGE.
- Save "Result of " image in new folder.
Below are the commands I have from the recorder tool (with the original image already open):
open("ORIGINAL.tif"); selectWindow("ORIGINAL.tif"); run("Select All"); run("Copy"); newImage("NEW IMAGE", "8-bit black", 1360, 1024, 1); run("Paste"); setThreshold(20, 255); setOption("BlackBackground", false); run("Convert to Mask"); run("Divide...", "value=255"); selectWindow("ORIGINAL.tif"); imageCalculator("Multiply create", "ORIGINAL.tif","NEW IMAGE"); selectWindow("Result of ORIGINAL.tif"); saveAs("Tiff", "C:\\Users\\Result of ORIGINAL.tif"); close();
Is this workflow straightforward enough to use the batch processing tool? If so, how do I go about making generic file names in the code so it can perform the necessary operations within each loop? I’ve read the “How_to_apply_a_common_operation_to_a_complete_directory” article and have been unsuccessful so far. I would need to change the file name at every line where ORIGINAL currently is, in addition to making ImageJ save the result with a filename specific to the original (right now it spits it out as “Result of ORIGINAL” just using the given filename and it would be great to keep this convention).
Is it better to use the Script Editor with the provided Process Folder template? If so, what are the correct changes to the code to properly process the folder? The folder contains 75 images and their filenames are all identical save for a sequential number change (Original1, Original2, Original3, etc).
Thank you so much!