/* * Inverted grayscale panels can enhance dim features. * This macro enables the user to invert the grayscale channels of a montage * Idea is to 1) make a montage, 2) add ROI zooms, 3) do inversion, 4) compile montages * http://github.com/quantixed/imagej-macros/ */ macro "Invert Montage Panels" { if (nImages > 1) exit ("Use a single image or single montage"); if (nImages == 0) exit("No image open"); imageID = getImageID(); title = getTitle(); dir1 = getDirectory("image"); newName = "invert_" + title; run("Select None"); getDimensions(w, h, c, numSlices, nFrames); // deal with multiple frames or slices nShots = maxOf(numSlices,nFrames); if (numSlices > 1 && nFrames > 1) exit("Number of slices and frames is greater than one"); if (numSlices == 1) sliceOrFrame = 0; if (numSlices > 1) sliceOrFrame = 1; if (nFrames > 1) sliceOrFrame = 2; // work out grout size if (w == h) { nCol = 1; nRow = 1; grout = 0; nPanel = 1; vChoice = ""; } else if (w > h) { nCol = floor(w/h); nRow = 1; grout = (w - (nCol * h)) / (nCol - 1); nPanel = nCol; vChoice = ""; ww = h; hh = h; } else { nCol = 1; nRow = floor(h/w); grout = (h - (nRow * w)) / (nRow - 1); nPanel = nRow; vChoice = "vert"; ww = w; hh = w; } // dialog for choices labels = newArray(nPanel); defaults = newArray(nPanel); panelDecisions = newArray(nPanel); for (i=0; i 20 * grout && grout > 0) exit("Use a smaller stroke size"); setBatchMode(true); // border will be black if colorChoice is True if (colorChoice) { if (bitDepth() == 8) setColor(0); if (bitDepth() == 24) setColor(0,0,0); if (bitDepth() == 16) setColor(0); } for (i=0; i