/** Select a calibration bar and convert it to a LUT, which gets stored * in the ImageJ/LUTS directory */ macro "Calibration Bar to LUT" { if (bitDepth() != 24) exit("RGB image required"); if (selectionType() != 0) exit("Error:\nCalibration bar must be selected with the Rectangle Tool"); run("Duplicate...", "title=scaleBar-tmp"); selectWindow("scaleBar-tmp"); if (getHeight() > getWidth()) run("Rotate 90 Degrees Right"); run("Size...", "width=256 height=1 average interpolation=Bilinear"); makeRectangle(0, 0, 3, 1); getStatistics(area, meanLeft); makeRectangle(253, 0, 3, 1); getStatistics(area, meanRight); run("Select None"); if (meanLeft-100 >meanRight) run("Flip Horizontally", "stack"); tmpID = getImageID(); run("RGB Stack"); filename = getString("Name for the LUT", ""); if (! endsWith(filename, ".lut")) filename = filename + ".lut"; path = getDirectory("luts")+filename; saveAs("Raw Data", path); selectImage(tmpID); close(); }