Dear Group,
Can someone kindly explain how to cull results normally displayed in the Summary window and overlay them on the final image from within a macro? During particle counts, I would like to capture %area, ave. particle size, count and save them as variables. If max and min particle size is available, that is of interest as well. I would also like to devise a means of capturing the total area of the scaled image for particles/area quantification to compare images taken at different magnifications. Ultimately, I aim to paste this information to the final image after processing. Here is a manually-completed image illustrating my goal: https://drive.google.com/file/d/0B52y_sgs5kU9bXpHVUJrTWhMRGs/edit?usp=sharing I searched the archives finding question #0222896 similar, but I unfortunately could not find the response. Thank you, Ken -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Ken,
I had a play around and came up with the following solution (mostly because this is something I hadn't thought of, but know people who might ask me to do it future). Assuming you're using thresholding and the Analyse Particles function, what you request can be performed like so (probably other solutions too): run("Set Measurements...", "area limit redirect=None decimal=3"); run("Threshold..."); waitForUser("Adjust threshold"); //This is just for convenience with my test image, whatever processing you do to threshold can replace this run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Nothing display clear"); //adjust size and circularity as necessary count = nResults(); //Put the results into an array resultsArray=newArray(); for(i=0;i<count;i++){ resultsArray=Array.concat(resultsArray,getResult("Area",i)); }; run("Measure"); total_coverage = getResult("Area"); getStatistics(total_area); //Get the summary out and into variables; Array.getStatistics(resultsArray,min,max,avg,stDev); run("Flatten"); //if you want your threshold burned onto the image too xpos=300;ypos=300; //adjust these to move the caption around setFont("SansSerif", 12, "bold"); //adjust to change appearance of caption ("bold" can be removed and "SansSerif" can be changed to "Serif"); //Caption, I've left areas in pixels because my test image wasn't calibrated drawString("count = "+count +"\nAvg size = " +avg+" pixels \nmin \\ max ="+min+" \\ "+max +" pixels \n\% Area = "+100*total_coverage/total_area+"\%",xpos,ypos); //Scale bar run("Scale Bar...", "width=80 height=4 font=14 color=White background=None location=[Lower Right] bold"); This worked on a test image of mine that I just threshold to segment, but should work anywhere you run the analyse particles. Note that I didn't strictly answer your question of how to extract data from the summary table, but instead essentially created my own summary. Hope this helps, -Lachie ----- Original Message ----- From: "Ken George" <[hidden email]> To: [hidden email] Sent: Friday, 8 November, 2013 2:50:45 PM Subject: extacting data from the summarize table Dear Group, Can someone kindly explain how to cull results normally displayed in the Summary window and overlay them on the final image from within a macro? During particle counts, I would like to capture %area, ave. particle size, count and save them as variables. If max and min particle size is available, that is of interest as well. I would also like to devise a means of capturing the total area of the scaled image for particles/area quantification to compare images taken at different magnifications. Ultimately, I aim to paste this information to the final image after processing. Here is a manually-completed image illustrating my goal: https://drive.google.com/file/d/0B52y_sgs5kU9bXpHVUJrTWhMRGs/edit?usp=sharing I searched the archives finding question #0222896 similar, but I unfortunately could not find the response. Thank you, Ken -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html ______________________________________________________________________ The information in this email is confidential and intended solely for the addressee. You must not disclose, forward, print or use it without the permission of the sender. ______________________________________________________________________ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |