Hello,
I am new to imagej. I have the outline of a macro that I created, however would like it to do a few more simple functions that I cannot figure out how to program. I have a series of images that I will import in as a stack. For each image I will use the multipoint tool to make a series of clicks on different objects manually but the macro prints the coordinates of the points in the results table. However each "group/series" of points in each image (there will be 4-5 clusters of 10+ points) will need to be labeled differently in the results table (possibly through the slice??). It also would be helpful if after all the points have been measured on the image if I could print a label on the actual image or a text box (i.e. "Measure X") as a reminder to manually measure something. This is the macro I have created so far... macro "Macro 2" { getSelectionCoordinates(xCoordinates, yCoordinates); for(i=0; i<lengthOf(xCoordinates); i++) { setResult("X", i, xCoordinates[i]); setResult("Y", i, yCoordinates[i]); } updateResults(); print("Measure X"); run("Clear Results"); run("Measure"); saveAs("Results", getDirectory("home")+"points.csv"); } It works, except I cannot figure out how to label the different "groups/clusters" of points differently for each image and between images. I also cannot figure out how to print text on the image or how to have specific text pop up in a sequence. |
Hello Hannah,
In order to print text on your image and not just in a new text window, you need to take out the line of code that says print("Measure X"); and put in the following: setForegroundColor(255, 255, 255); setFont("SansSerif", 18, " antialiased"); drawString("Measure X", 4, 29); The first two lines of code will set the text color as white and then set the font, size and style. The drawString line will print the text on the image, with "Measure X" being the text to print and 4, 29 being the X and Y coordinates of the upper lefthand corner of the text box. You can change any of these parameters. As for the labeling, if I understand you correctly, you want to have the name of the image and/or slice number as part of the data table? To do this outside a macro, you would go into Analyze -> Set Measurements and check off the Display label box. If you record that and add it to your macro, you get this line of code: run("Set Measurements...", " mean display redirect=None decimal=0"); Which again, can be modified to fit your needs. This should print the title of your image, followed by a : and a number. The number will be the slice number within the stack. I hope this at least gets you going in the right direction. Best, Christine -------------------------------------------- Christine Labno, Ph.D. Asst. Technical Director Light Microscopy Core University of Chicago Office of Shared Research Facilities KCBD 1250 900 E. 57th St. (773) 834-9040 (phone) ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of Hannah S [[hidden email]] Sent: Monday, September 02, 2013 5:53 PM To: [hidden email] Subject: Macro Help Hello, I am new to imagej. I have the outline of a macro that I created, however would like it to do a few more simple functions that I cannot figure out how to program. I have a series of images that I will import in as a stack. For each image I will use the multipoint tool to make a series of clicks on different objects manually but the macro prints the coordinates of the points in the results table. However each "group/series" of points in each image (there will be 4-5 clusters of 10+ points) will need to be labeled differently in the results table (possibly through the slice??). It also would be helpful if after all the points have been measured on the image if I could print a label on the actual image or a text box (i.e. "Measure X") as a reminder to manually measure something. This is the macro I have created so far... macro "Macro 2" { getSelectionCoordinates(xCoordinates, yCoordinates); for(i=0; i<lengthOf(xCoordinates); i++) { setResult("X", i, xCoordinates[i]); setResult("Y", i, yCoordinates[i]); } updateResults(); print("Measure X"); run("Clear Results"); run("Measure"); saveAs("Results", getDirectory("home")+"points.csv"); } It works, except I cannot figure out how to label the different "groups/clusters" of points differently for each image and between images. I also cannot figure out how to print text on the image or how to have specific text pop up in a sequence. -- View this message in context: http://imagej.1557.x6.nabble.com/Macro-Help-tp5004625.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |