ij-macro-programming-workshop

Previous            Exercise            Next

Exercise 14.3 - Saving a result image.

Aim:

Modify your macro from exercise 14.02, so that the merged image is saved and closed in ImageJ. The image should be written to a folder out which is a subfolder of the input folder. The name of the result image should be the name of the dapi-input image without dapi.

For example:

The result image of merging “dapi 3.tif” and “rhod 3.tif” should have the name “3.tif”

You need the following commands:

Your code starts after this line

open();
path = File.directory;
imageDAPI = File.name;
File.mkdir(path + "out");
imageRHOD = replace(imageDAPI, "dapi", "rhod");
open(path + imageRHOD);
run("Merge Channels...", "c2=["+imageRHOD+"] c3=["+imageDAPI+"]");
save(path + "out/" + replace(imageDAPI, "dapi ", ""));
close();

Your code ends before this line

The code below is for automatically checking the result. Please ignore it!

ok = (nImages==0);
ok = (ok && File.exists(path+"/out"));
files = getFileList(path+"/out");
ok = (ok && files.length>0);
if (ok)
	showMessage("That's right. Great, you did it!");
else 
	showMessage("Your result is wrong! Please check your macro and try again!");


Previous            Exercise            Next