This post was updated on .
I'm trying to make a macro that allows us to measure line lenghts and angles, based on the Delaunay Voronoi plugin.
Simply put, the idea is to have a results table with all the informations of every line. The problem is that the Delaunai Voronoi plugin outputs lines that are not measurable using the embedded ImageJ measure command. As a workaround, since this plugin generates a results table with all line coordinates, I have tried to parse every line and make new lines on the drawing with the drawLine command. But these lines are not measurable too. So the only line command that works is the makeLine, which limits the application to one line at a time. Can someone shed me some light on this? How is it possible to obtain a results table with all line lenghts without having to save and open a new results csv file over and over again? Cheers!! MACRO: run("Clear Results"); run("Close All"); open("C:\\Users\\User\\Desktop\\microperf2.tif"); //setTool("rectangle"); makeRectangle(0, 180, 640, 140); run("Crop"); run("8-bit"); //run("Brightness/Contrast..."); run("Enhance Contrast", "saturated=0.35"); run("Apply LUT"); run("Set Scale...", "distance=412 known=5.00 pixel=1 unit=mm global"); run("Set Measurements...", "area mean standard modal min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack display add redirect=None decimal=3"); run("Find Maxima...", "noise=95 output=[Single Points] exclude light"); run("Analyze Particles...", "size=1-Infinity pixel circularity=0.00-1.00 exclude clear"); run("Delaunay Voronoi", "mode=Delaunay make inferselectionfromparticles export"); for (i = 0; i < nResults; i++) { // You may need to change the "frame", etc strings to match your csv file. x1 = getResult("x1", i); y1 = getResult("y1", i); x2 = getResult("x2", i); y2 = getResult("y2", i); makeLine(x1, y1, x2, y2); run("Draw"); } IMAGE FILE: microperf2.tif |
Dear Nuno,
I think the code below does what you want. You did not do any measurements when you draw the lines so nothing was recorded. Besides that, ImageJ can only handle one Results table so the Voronoi results table has to be renamed before a measurement can be done and after that we have to switch between the two results tables by renaming them when we want to use them. The code will give as result a table called Results1 with the original results from the Voronoi plugin and a new Results table with the line angle and length. -------------------------------- Start code----------------------------- open("C:\\Users\\User\\Desktop\\microperf2.tif"); makeRectangle(0, 180, 640, 140); run("Crop"); run("8-bit"); //run("Brightness/Contrast..."); run("Enhance Contrast", "saturated=0.35"); run("Apply LUT"); run("Set Scale...", "distance=412 known=5.00 pixel=1 unit=mm global"); run("Set Measurements...", "area mean standard modal min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack display add redirect=None decimal=3"); run("Find Maxima...", "noise=95 output=[Single Points] exclude light"); run("Analyze Particles...", "size=1-Infinity pixel circularity=0.00-1.00 exclude clear"); run("Delaunay Voronoi", "mode=Delaunay make inferselectionfromparticles export"); for (i = 0; i < nResults; i++) { // You may need to change the "frame", etc strings to match your csv file. x1 = getResult("x1", i); y1 = getResult("y1", i); x2 = getResult("x2", i); y2 = getResult("y2", i); makeLine(x1, y1, x2, y2); run("Draw"); IJ.renameResults("Results","Results1"); run("Set Measurements...", " redirect=None decimal=3"); if (i>0) IJ.renameResults("Results_New","Results"); run("Measure"); IJ.renameResults("Results","Results_New"); IJ.renameResults("Results1","Results"); } IJ.renameResults("Results","Results1"); IJ.renameResults("Results_New","Results"); -------------------------------------------------- end code-------------------------------------------------- Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Nuno Mira Sent: 22 July 2015 18:41 To: [hidden email] Subject: Embedded maesure command not measuring Delaunay Voronai plugin lines I'm trying to make a macro that allows us to measure line lenghts and angles, based on the Delaunay Voronoi plugin. Simply put, the idea is to have a results table with all the informations of every line. The problem is that the Delaunai Voronoi plugin outputs lines that are not measurable using the embedded ImageJ measure command. As a workaround, since this plugin generates a results table with all line coordinates, I have tried to parse every line and make new lines on the drawing with the drawLine command. But these lines are not measurable too. So the only line command that works is the makeLine, which limits the appliaction to one line at a time. Can someone shed me some light on this? How is it possible to obtain a results table with all line lenghts without having to save and open a new results csv file over and over again? Cheers!! /run("Clear Results"); run("Close All"); open("C:\\Users\\User\\Desktop\\microperf2.tif"); //setTool("rectangle"); makeRectangle(0, 180, 640, 140); run("Crop"); run("8-bit"); //run("Brightness/Contrast..."); run("Enhance Contrast", "saturated=0.35"); run("Apply LUT"); run("Set Scale...", "distance=412 known=5.00 pixel=1 unit=mm global"); run("Set Measurements...", "area mean standard modal min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack display add redirect=None decimal=3"); run("Find Maxima...", "noise=95 output=[Single Points] exclude light"); run("Analyze Particles...", "size=1-Infinity pixel circularity=0.00-1.00 exclude clear"); run("Delaunay Voronoi", "mode=Delaunay make inferselectionfromparticles export"); for (i = 0; i < nResults; i++) { // You may need to change the "frame", etc strings to match your csv file. x1 = getResult("x1", i); y1 = getResult("y1", i); x2 = getResult("x2", i); y2 = getResult("y2", i); makeLine(x1, y1, x2, y2); run("Draw"); }/ microperf2.tif <http://imagej.1557.x6.nabble.com/file/n5013697/microperf2.tif> -- View this message in context: http://imagej.1557.x6.nabble.com/Embedded-maesure-command-not-measuring-Delaunay-Voronai-plugin-lines-tp5013697.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 |