// Tree_Rings counting tool // This tool mimics a straight line tool // Maxima along the selected line are counted and marked // When the mouse is released. var colors=newArray("blue","red","green","magenta","orange","pink","yellow"); macro "max Tool - C000O00ffO3399O6633L00ff" { getCursorLoc(x0,y0,z,mod); while (mod&16==16) { getCursorLoc(x1,y1,z,mod); makeLine(x0,y0,x1,y1); } n = findMaxima(x0,y0,x1,y1); print (n,"maxima found"); // Overlay discovered maxima color=colors[n%colors.length]; run("Add Selection...", "stroke="+color); run("Select None"); } function findMaxima(x0,y0,x1,y1) { if (selectionType!=5) exit(); pixels = getProfile(); setBatchMode(true); newImage("profile", "8-bit", pixels.length, 1, 1); idtemp= getImageID; for (i=0;i