Login  Register

Macro for beginners

Posted by Toufic El Arnaout on Nov 05, 2014; 7:36pm
URL: http://imagej.273.s1.nabble.com/Macro-for-beginners-tp5010322.html

Hello everyone,I am new to ImageJ and Fiji. I know well now how to use basic macro for batch mode for all basic analysis functions, but cases with variables to read and save. Please help me correct the macro below in red (sorry for the long email).. it will be needed for now and future similar ones.
a- I have images in let's say folder A in C:.b- I want those images to have their background removed using image "background.tif".c- Then have the output image for each saved in folder B in C:.d- I might be wrong in some cases, but the setBatchMode was probably added below in a wrong way because I found it in tutorials. I may also have the input and output entries wrongly placed. In addition, I may not need the images to be all opened after processing...e- The sixth line entry, called action is wrong as the software says (I also found it here: http://fiji.sc/How_to_apply_a_common_operation_to_a_complete_directory)
Furthermore, let me know how to call the files in this macro. I think this macro assumes that the file name is 0, and next one is 1, 2, 3 etc? What if the file name in stupid cases for example is 1_2014-10-31-153821-0200? and the next one is *-0201, etc (because otherwise, simply renaming 1000 files in Windows by selecting all will make them called 1, 1 (2), 1 (3), etc.... and I assume will be complicated for me to understand for i, i + 1, i + 2 rule...toufic


input = "C:\\A\\";output = "C:\\B\\";
setBatchMode(true);list = getFileList(input);for (i = 0; i < list.length; i++) action(input, output, list[i]);
open(input + filename);open("C:\\background.tif");selectWindow(filename);run("Subtract Background...", "rolling=40 light");imageCalculator("Subtract create", "background.tif", input);selectWindow("Result of background.tif");saveAs("jpeg", output);
setBatchMode(false);
         
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html