// Original code by Vytas Bindokas; Oct 2006, Univ. of Chicago // https://digital.bsd.uchicago.edu/docs/imagej_macros/_graybalancetoROI.txt // This macro white balances RGB to a selected region (equal R,G,B =gray) // draw a region prior to running the macro // Code modified by Patrice Mascalchi, 2014, Univ. of Cambridge UK // Ask for region to be drawn / Check region existence / check RGB at start / compaction of code (loop) // chose the destination directory and create the destinations for amplitude and phase dest_dir=getDirectory("Choose the destination directory"); setTool(0); waitForUser("Draw a region over background"); run("Set Measurements...", " mean redirect=None decimal=3"); if (selectionType==-1) exit("you must draw a region first"); ti = getTitle; Stack.getDimensions(width, height, channels, slices, frames); print("width:",width," height:",height," channels:",channels," slices:",slices," frames:",frames); //newImage(ti+"_Corrected", "RGB", width, height, 0); for (k=1;k