/* Modify_Map_1e.txt https://sils.fnwi.uva.nl/bcb/objectj/examples/Coli-Inspector/utils/Modify_Map/ N. Vischer 22.01.20, 2:31 Features ======== From a sorted Map as created by Coli-Inspector, a duplicate is created by performing these steps: - 'newWidth' is used to scale horizontally using (down-)averaging - 'newHeight' is used to crop excessive black space at top and bottom - displays upper and lower hull as white overlay lines - applies individual heat map color LUTs to channels 2 and 3 - optionally makes upper and lower half symmetrical - optionally creates a high-resolution image More tips: ========== - You can use manual horizontal smoothing via: Process>Filters>Convolve with single line containing an odd number of '1 's - change color appearance per channel by choosing ImageJ>Lookup Tables... - change color appearance per channel by choosing Image>Adjust>Brightness and Contrast - Optionally, choose Analyze>Tools>Calibration Bar.. - choose Plugins>Utilities>Capture Image to create an RGB image of current appearance (honors zoom but image must be fully inside screen) - alternatively, choose channel 1 (to avoid ImageJ bug before version 1.52t24) and choose: Image>Overlay>Flatten to create an RGB image or stack (ignores zoom) - "Modified_Map" will first be closed unless it was renamed (Image>Rename...) - Note that 'newWidth' expands or shrinks the map horizontally, it does not create a sub-poulation */ macro "Modify Sorted Map"{ newWidth = 300;//proposal lut2 = "Green Fire Blue"; lut3 = "Orange Hot"; hullColor = "white"; lineWidth = 1; //hull line width, can be < 1 setSlice(1); if(bitDepth != 32 || getPixel(1,0) >= 0)//negative ID expected exit("Image '" + getTitle + "' is no Coli-Inspector Map"); Overlay.remove; height = getHeight; len = getWidth-1; xHi = newArray(len);//upper hull yHi = newArray(len); xLo = newArray(len);//lower hull yLo = newArray(len); yHi[0] =getPixel(1, 1); yLo[0] =getPixel(1, 1) + getPixel(1, 2) ; cntHi = 0; cntLo = 0; for(x = 2; x < getWidth; x++){ up =getPixel(x, 1); lo =up + getPixel(x, 2); if(up < yHi[cntHi]){//get smooth upper hull cntHi++; yHi[cntHi] = up; xHi[cntHi] = x; } if(lo > yLo[cntLo]){//get smooth lower hull cntLo++; yLo[cntLo] = lo; xLo[cntLo] = x; } } yHi = Array.trim(yHi, cntHi); yLo = Array.trim(yLo, cntLo); xHi = Array.trim(xHi, cntHi); xLo = Array.trim(xLo, cntLo); maxHeight = getHeight - 6; newHeight = getPixel(getWidth-1,2); Dialog.create("Modified Map Size"); Dialog.addNumber("New Width [pixels]:" , newWidth); Dialog.addNumber("New Height [pixels]:", newHeight); Dialog.addNumber("High-Resolution factor (1..4):", 1); msg3 = "Number of cells = " + (getWidth - 1); msg3 += "\nLongest cell [pixels] = " + getPixel(getWidth-1,2); msg3 += "\nMax height [pixels] =" + maxHeight; Dialog.addMessage(msg3, 12, "gray"); Dialog.addCheckbox("Make symmetrical", false); Dialog.show; newWidth = Dialog.getNumber; newHeight = Dialog.getNumber; highResFactor = Dialog.getNumber; symmetrical = Dialog.getCheckbox; close("Modified_Map"); run("Select All"); newTop = round((getHeight - newHeight)/2); if(newTop < 3) showMessage("NewHeight must be <= " + maxHeight); xFactor = newWidth/(getWidth-1) * highResFactor; yFactor = highResFactor; makeRectangle(1, newTop, getWidth - 1, newHeight); ID = getImageID; run("Scale...", "x=&xFactor y=&highResFactor interpolation=Bilinear average create"); rename("Modified_Map"); selectImage(ID); run("Select None"); selectImage("Modified_Map"); for(jj = 0; jj 1) run("Set... ", "zoom=200"); if(nSlices >=3){ setSlice(3); run(lut3); } if(nSlices >=2){ setSlice(2); run(lut2); } }