Dear all, I have an image with many particles, distributed randomly. I'm trying to get the average distance between a particle with all its closest neighbors but not all of the particles on the image. Is there an easy way to do or an existing plugin that allows such measurement? Many thanks, France France E. Girault Geological Institute CAB E-62 ETH Zürich Universitätstrasse 6 8092 Zürich Private phone: ++4178/726.99.20 Office phone: ++4144/632 84 16 Fax: +4144/632 10 80 [hidden email] <mailto:[hidden email]> http://www.geology.ethz.ch/people/PhDStudents/giraultf/index <http://www.geology.ethz.ch/people/PhDStudents/giraultf/index> |
Hi France,
one method that I sometimes use is the following: - Create one single point per particle, e.g. using Process>Binary>FindMaxima. - Run an Autocorrelation (Process>FFT>FT Math correlate, do inverse) - Use the Radial Profile Plot http://rsb.info.nih.gov/ij/plugins/radial-profile.html This gives you the radial distribution function. Ignore the peak at zero distance. There will be also a minimum next to zero distance because you cannot have two isolated points touching each other. This tells you nothing important about the particle distribution. If the particles are really randomly distributed, apart from these two effect and statistical noise, the radial distribution function should be flat. Michael ________________________________________________________________ On 9 May 2007, at 22:12, Girault France wrote: > Dear all, > I have an image with many particles, distributed randomly. I'm > trying to get the average distance between a particle with all its > closest neighbors but not all of the particles on the image. > Is there an easy way to do or an existing plugin that allows such > measurement? > > Many thanks, > > France |
In reply to this post by Girault France
Typically the neighbors of points under a Delaunay triangulation are
what can be considered as the 'closest neighbors'. There is a plugin to generate the Delaunay triangulation from selected points (http:// wbgn013.biozentrum.uni-wuerzburg.de/ImageJ/delaunay.html). Possibly the author knows how to extract the neighbors for each point including the distance! from the plugin. In fact it would be a nice extension to graph operations in ImageJ. Regards Karsten Am 09.05.2007 um 22:12 schrieb Girault France: > > Dear all, > I have an image with many particles, distributed randomly. I'm > trying to get the average distance between a particle with all its > closest neighbors but not all of the particles on the image. > Is there an easy way to do or an existing plugin that allows such > measurement? > > Many thanks, > > France > France E. Girault > Geological Institute > CAB E-62 > ETH Zürich > Universitätstrasse 6 > 8092 Zürich > Private phone: ++4178/726.99.20 > Office phone: ++4144/632 84 16 > Fax: +4144/632 10 80 > > [hidden email] <mailto:[hidden email]> > http://www.geology.ethz.ch/people/PhDStudents/giraultf/index > <http://www.geology.ethz.ch/people/PhDStudents/giraultf/index> > |
In reply to this post by Michael Schmid
On Wednesday 09 May 2007 21:30:10 Michael Schmid wrote:
> > I have an image with many particles, distributed randomly. I'm > > trying to get the average distance between a particle with all its > > closest neighbors but not all of the particles on the image. > > Is there an easy way to do or an existing plugin that allows such > > measurement? To do this using brute-force would be quite easy with a macro: get the coordinates of all the points or centroids in arrays x() and y(), for each point calculate using pythagoras, the distance to all other points and keep the shortest one in another array. Now look at the distribution of shortest distances. Cheers, G. |
In reply to this post by karo03
On Wednesday 09 May 2007 22:16:41 Karsten Rodenacker wrote:
> Typically the neighbors of points under a Delaunay triangulation are > what can be considered as the 'closest neighbors'. You are right, the nearest-neighbour graph is a subgraph of the delaunay triangulation, but I think it is easier to calculate the nearest neighbours in the way I mentioned earlier because for the delaunay graph one has to get the points and distances to all the other points anyway. Regards, Gabriel |
In reply to this post by Girault France
An alternative to a strict "nearest neighbor" is to generate the pair-wise
distances from each centroid to every other centroid in the image. Compile these into a "pair-wise difference histogram" of distances. This is the equivalent of a 1D autocorrelation function. You will see a peak at the mean nearest neighbor distance. ~ Will -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Girault France Sent: Wednesday, May 09, 2007 4:13 PM To: [hidden email] Subject: distance between adjacent particles Dear all, I have an image with many particles, distributed randomly. I'm trying to get the average distance between a particle with all its closest neighbors but not all of the particles on the image. Is there an easy way to do or an existing plugin that allows such measurement? Many thanks, France France E. Girault Geological Institute CAB E-62 ETH Zürich Universitätstrasse 6 8092 Zürich Private phone: ++4178/726.99.20 Office phone: ++4144/632 84 16 Fax: +4144/632 10 80 [hidden email] <mailto:[hidden email]> http://www.geology.ethz.ch/people/PhDStudents/giraultf/index <http://www.geology.ethz.ch/people/PhDStudents/giraultf/index> |
In reply to this post by Gabriel Landini
Hi, Gabriel
Just for clarification: The set of closest neighbored points is something more than NNG (nearest-neighbour graph). It has something to do with our visual behavior, how we relate neighbored objects. One result of DT (Delaunay triangulation) could be the list of neighbors per point. From which easily an 'arrangement parameter' (mean of distances) could be deduced. This again is of course highly related to the mean area of Voronoi polygones of one point or the watershed bassins neighbored to a region. Regards Karsten Am 09.05.2007 um 23:57 schrieb Gabriel Landini: > On Wednesday 09 May 2007 22:16:41 Karsten Rodenacker wrote: >> Typically the neighbors of points under a Delaunay triangulation are >> what can be considered as the 'closest neighbors'. > > You are right, the nearest-neighbour graph is a subgraph of the > delaunay > triangulation, but I think it is easier to calculate the nearest > neighbours > in the way I mentioned earlier because for the delaunay graph one > has to get > the points and distances to all the other points anyway. > > Regards, > > Gabriel |
In reply to this post by Gabriel Landini
Ok. If you're not really looking for "closest neighbor" distance
but the "average distance among the closest neighbors"... You'll need to decide how many of the closest neighbors you want to include in the average. Depending on what you expect the distribution might be like, you could use from 3-6 neighbors. Then, you could do the "brute force" calculation suggested below, except instead of keeping the shortest distance in an array, you would keep the "n" shortest distances in an array. When you were done scanning all of the points, you would find the average of those "n" points. I like using "6" points, because that's how many neighbors an object would have if it was in a tightly packed hexagonal pattern. In other applications, I've been interested finding areas of different "densities" of objects and I've used the following steps: - threshold the objects - reduce the objects to their ultimate center points - run a large scale blur (scale dependent on how far away you want to include neighbors) - this image will have it's highest intensities in the areas where you have the closest packing of objects This represents more of a "texture" measure. The advantage of this technique is that it doesn't require any extra java programming, just image processing steps. The problem with this technique is that it's a lot harder to try to describe what the results mean. good luck, Jeff Gabriel Landini <[hidden email]> Sent by: ImageJ Interest Group <[hidden email]> 05/09/2007 05:36 PM Please respond to ImageJ Interest Group <[hidden email]> To [hidden email] cc Subject Re: distance between adjacent particles On Wednesday 09 May 2007 21:30:10 Michael Schmid wrote: > > I have an image with many particles, distributed randomly. I'm > > trying to get the average distance between a particle with all its > > closest neighbors but not all of the particles on the image. > > Is there an easy way to do or an existing plugin that allows such > > measurement? To do this using brute-force would be quite easy with a macro: get the coordinates of all the points or centroids in arrays x() and y(), for each point calculate using pythagoras, the distance to all other points and keep the shortest one in another array. Now look at the distribution of shortest distances. Cheers, G. |
Dear all,
Thanks for all the replies, Following your advices, I've been trying some techniques to get distances between particles. Here I try to get the shortest distance between each particle and its closest neightbor as suggested by G. Landini. First I have to assess the distance between the particle and each of the other particle, avoiding the value "0" for the distance: (see below) With this macro I still get the value 0 in some cases and I don't know how to get rid of it. Maybe there also is an easier way to get those values? Secondly I just saw the last reply about taking 6 closest neighbors which would exactly fit with I want to do (4 closest neighbors rather than 6), but I don't really see how I can get this right now with what I've done. Any ideas on how to do this? Creating a second array and store the 4 smallest values and average them at the end? Many thanks, France var dist1; var dist; for (i=0; i<nResults; i++) { XM=getResult("XM", i); YM=getResult("YM",i); a=nResults; a1 = newArray(a); for (b=0; b<nResults; b++){ XM2=getResult("XM", b); YM2=getResult("YM",b); dist1=dist; dist=sqrt(((XM2-XM)*(XM2-XM))+((YM2-YM)*(YM2-YM))); a1[b] = dist; } for (b=0;b<a;b++){ dist=a1[b]; if(dist==0){dist=10000;} if (dist>dist1) {dist=dist1;} dist1=dist; } print(dist1); setResult("shortest_dist", i, dist1); } updateResults(); -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jeffrey C Hanson Sent: jeudi, 10. mai 2007 17:13 To: [hidden email] Subject: Re: distance between adjacent particles Ok. If you're not really looking for "closest neighbor" distance but the "average distance among the closest neighbors"... You'll need to decide how many of the closest neighbors you want to include in the average. Depending on what you expect the distribution might be like, you could use from 3-6 neighbors. Then, you could do the "brute force" calculation suggested below, except instead of keeping the shortest distance in an array, you would keep the "n" shortest distances in an array. When you were done scanning all of the points, you would find the average of those "n" points. I like using "6" points, because that's how many neighbors an object would have if it was in a tightly packed hexagonal pattern. In other applications, I've been interested finding areas of different "densities" of objects and I've used the following steps: - threshold the objects - reduce the objects to their ultimate center points - run a large scale blur (scale dependent on how far away you want to include neighbors) - this image will have it's highest intensities in the areas where you have the closest packing of objects This represents more of a "texture" measure. The advantage of this technique is that it doesn't require any extra java programming, just image processing steps. The problem with this technique is that it's a lot harder to try to describe what the results mean. good luck, Jeff Gabriel Landini <[hidden email]> Sent by: ImageJ Interest Group <[hidden email]> 05/09/2007 05:36 PM Please respond to ImageJ Interest Group <[hidden email]> To [hidden email] cc Subject Re: distance between adjacent particles On Wednesday 09 May 2007 21:30:10 Michael Schmid wrote: > > I have an image with many particles, distributed randomly. I'm > > trying to get the average distance between a particle with all its > > closest neighbors but not all of the particles on the image. > > Is there an easy way to do or an existing plugin that allows such > > measurement? To do this using brute-force would be quite easy with a macro: get the coordinates of all the points or centroids in arrays x() and y(), for each point calculate using pythagoras, the distance to all other points and keep the shortest one in another array. Now look at the distribution of shortest distances. Cheers, G. |
France -
It looks like you initialize the value of "dist1" inside the for loop where you're calculating all of the distances. You should just initialize it to a large value outside of the for loop. Try this, instead: var dist1; var dist; for (i=0; i<nResults; i++) { XM=getResult("XM", i); YM=getResult("YM",i); a=nResults; a1 = newArray(a); for (b=0; b<nResults; b++){ XM2=getResult("XM", b); YM2=getResult("YM",b); dist=sqrt(((XM2-XM)*(XM2-XM))+((YM2-YM)*(YM2-YM))); a1[b] = dist; } dist1=10000; for (b=0;b<a;b++){ dist=a1[b]; if(dist==0){dist=10000;} if (dist>dist1) {dist=dist1;} dist1=dist; } print(dist1); setResult("shortest_dist", i, dist1); } updateResults(); Jeff Senior Imaging Analyst [hidden email] |
On Thursday 10 May 2007 18:48:09 Jeffrey C Hanson wrote:
> It looks like you initialize the value of "dist1" inside the for > loop where you're calculating all of the distances. You should just > initialize it to a large value outside of the for loop. Try this, > instead: [...] > dist=sqrt(((XM2-XM)*(XM2-XM))+((YM2-YM)*(YM2-YM))); A handy trick. You can save some time by not doing the sqrt and comparing the squares instead. Then do the sqrt at the end only on the values you kept. I hope it helps. Cheers, G. |
In reply to this post by Girault France
Some concepts that may be thought provoking, "moves to crowding" and
"distance to regularity", attributed to J. N. Perry & M. Hewitt (1991) and R. Alston (1994), are described in a document deposited here: http://www.rothamsted.ac.uk/pie/sadie/reprints/perry1995a_jae.pdf Dan Batzel, PhD Research Scientist Gentex Corporation Carbondale, PA -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Girault France Sent: Thursday, May 10, 2007 11:30 AM To: [hidden email] Subject: Re: distance between adjacent particles Dear all, Thanks for all the replies, Following your advices, I've been trying some techniques to get distances between particles. Here I try to get the shortest distance between each particle and its closest neightbor as suggested by G. Landini. First I have to assess the distance between the particle and each of the other particle, avoiding the value "0" for the distance: (see below) With this macro I still get the value 0 in some cases and I don't know how to get rid of it. Maybe there also is an easier way to get those values? Secondly I just saw the last reply about taking 6 closest neighbors which would exactly fit with I want to do (4 closest neighbors rather than 6), but I don't really see how I can get this right now with what I've done. Any ideas on how to do this? Creating a second array and store the 4 smallest values and average them at the end? Many thanks, France var dist1; var dist; for (i=0; i<nResults; i++) { XM=getResult("XM", i); YM=getResult("YM",i); a=nResults; a1 = newArray(a); for (b=0; b<nResults; b++){ XM2=getResult("XM", b); YM2=getResult("YM",b); dist1=dist; dist=sqrt(((XM2-XM)*(XM2-XM))+((YM2-YM)*(YM2-YM))); a1[b] = dist; } for (b=0;b<a;b++){ dist=a1[b]; if(dist==0){dist=10000;} if (dist>dist1) {dist=dist1;} dist1=dist; } print(dist1); setResult("shortest_dist", i, dist1); } updateResults(); -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jeffrey C Hanson Sent: jeudi, 10. mai 2007 17:13 To: [hidden email] Subject: Re: distance between adjacent particles Ok. If you're not really looking for "closest neighbor" distance but the "average distance among the closest neighbors"... You'll need to decide how many of the closest neighbors you want to include in the average. Depending on what you expect the distribution might be like, you could use from 3-6 neighbors. Then, you could do the "brute force" calculation suggested below, except instead of keeping the shortest distance in an array, you would keep the "n" shortest distances in an array. When you were done scanning all of the points, you would find the average of those "n" points. I like using "6" points, because that's how many neighbors an object would have if it was in a tightly packed hexagonal pattern. In other applications, I've been interested finding areas of different "densities" of objects and I've used the following steps: - threshold the objects - reduce the objects to their ultimate center points - run a large scale blur (scale dependent on how far away you want to include neighbors) - this image will have it's highest intensities in the areas where you have the closest packing of objects This represents more of a "texture" measure. The advantage of this technique is that it doesn't require any extra java programming, just image processing steps. The problem with this technique is that it's a lot harder to try to describe what the results mean. good luck, Jeff Gabriel Landini <[hidden email]> Sent by: ImageJ Interest Group <[hidden email]> 05/09/2007 05:36 PM Please respond to ImageJ Interest Group <[hidden email]> To [hidden email] cc Subject Re: distance between adjacent particles On Wednesday 09 May 2007 21:30:10 Michael Schmid wrote: > > I have an image with many particles, distributed randomly. I'm > > trying to get the average distance between a particle with all its > > closest neighbors but not all of the particles on the image. > > Is there an easy way to do or an existing plugin that allows such > > measurement? To do this using brute-force would be quite easy with a macro: get the coordinates of all the points or centroids in arrays x() and y(), for each point calculate using pythagoras, the distance to all other points and keep the shortest one in another array. Now look at the distribution of shortest distances. Cheers, G. |
In reply to this post by jchanson
This is a very useful macro and almost takes me to where I want to get - is there a way to find the values for XM2 and YM2 and add these to the results table? Also, could someone briefly describe the logic behind the notion: "initialize it to a large value outside of the for loop"?
Thanks, Len Dobens |
Hi Len,
That's quite an old thread in Nabble. I'm not sure if it will help you, but you could try http://rsb.info.nih.gov/ij/plugins/graph/index.html There may be newer tools available that I am not familiar with. Ben > On May 22, 2016, at 4:06 PM, dobensl <[hidden email]> wrote: > > This is a very useful macro and almost takes me to where I want to get - is > there a way to find the values for XM2 and YM2 and add these to the results > table? Also, could someone briefly describe the logic behind the notion: > "initialize it to a large value outside of the for loop"? > > Thanks, > > Len Dobens > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/distance-between-adjacent-particles-tp3699485p5016492.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 |
Curious if anyone thinks this would be useful. It may only need a few lines of code to list the pairs of points and the distances. I wrote it just because I felt like it but no one has brought me a problem to apply it to.
http://microscopynotes.com/imagej/macros/shortest_distances_and_clustering/index.html ========================================================================= Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical Center Cell: 914-309-3270 ** Office: Skirball 2nd Floor main office, back right ** http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/ -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Ben Tupper Sent: Monday, May 23, 2016 1:08 PM To: [hidden email] Subject: Re: distance between adjacent particles Hi Len, That's quite an old thread in Nabble. I'm not sure if it will help you, but you could try https://urldefense.proofpoint.com/v2/url?u=http-3A__rsb.info.nih.gov_ij_plugins_graph_index.html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVUnIlg2qHZVtrhy_1M&s=njt95X9CC5z1_RlTbXErpNZ8qshIp4aaCxkviC1GaJI&e= There may be newer tools available that I am not familiar with. Ben > On May 22, 2016, at 4:06 PM, dobensl <[hidden email]> wrote: > > This is a very useful macro and almost takes me to where I want to get > - is there a way to find the values for XM2 and YM2 and add these to > the results table? Also, could someone briefly describe the logic behind the notion: > "initialize it to a large value outside of the for loop"? > > Thanks, > > Len Dobens > > > > -- > View this message in context: > https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nab > ble.com_distance-2Dbetween-2Dadjacent-2Dparticles-2Dtp3699485p5016492. > html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05Lzt > NstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVUnIlg2 > qHZVtrhy_1M&s=SFCtTsIXuwdtQq58bn7D7GiNgO3u5XcXK5w8iufElds&e= > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: > https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_ > list.html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_ > 05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVU > nIlg2qHZVtrhy_1M&s=A6W4FamOmzV5A4xjupQZMH0LP7G2kO3EEK6U_jH8mbI&e= -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVUnIlg2qHZVtrhy_1M&s=A6W4FamOmzV5A4xjupQZMH0LP7G2kO3EEK6U_jH8mbI&e= ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Girault France
This is very relevant to what I am doing at moment, I would like to measure the average the distance of 6 neighboring particles in an array of particles. Does anybody have a plug-in for this?
Thanks. Mor |
Hi all,
While trying out the Script Parameters available, I used this question to make a simple K-Nearest Neighbo(u)rs implementation in Jython You can find the script here https://gist.github.com/lacan/2643f2ce7e33d1bb07adafde9ff94101 You need an open image with a multipoint selection to make it work. The script then asks you for the number of neighbors you want to have and returns a table with the average distance for each point. It also creates an overlay on the image with lines connecting the neighbors and circles whose radii represent the average distance. Works with calibrated and uncalibrated images. > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > mortimus > Sent: mardi, 12 juillet 2016 09:03 > To: [hidden email] > Subject: Re: distance between adjacent particles > > This is very relevant to what I am doing at moment, I would like to measure the > average the distance of 6 neighboring particles in an array of particles. Does > anybody have a plug-in for this? > > Thanks. > Mor > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/distance- > between-adjacent-particles-tp3699485p5016864.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 |
In reply to this post by Cammer, Michael
this code turns out to be very useful to me - it nicely draws lines between neighboring particles (see below) - I am trying to extend it and measure the Feret’s Angle of that nearest neighbor and, if it is different, wand outline and color that “divergent" nearest neighbor (code below). From my code, when I “wand” the nearest neighbor (Wand(x[shortest1],y[shortest1]);), the value is just the original particle (Wand(x,y)) and no coloring occurs.
Here is the practice image with particles linked by colored lines (very cool to see in action): [cid:DF89240B-4F5D-409F-9F32-AD1CD5A6BA98] Here is the code run("8-bit"); setOption("BlackBackground", true); run("Make Binary"); run("RGB Color"); /* Next step is to save all 1st and 2nd shortest pairs with their distances. If distance greater than certain criteria, such as 15% longer than avg dist, then sever it. Then sort into clusters and do convex hull. Michael Cammer 20150707 for ImageJ 1.50a */ var shortestColor1 = "yellow"; var shortestColor2 = "red"; var shortestColor3 = "blue"; var shortestColor4 = "green"; macro "shortest and 2nd shortest [q]" { run("Select None"); // This part of the macro gets the XY locations of the points. It could // be replaced with some other method such as opening a text file or measuring // centroids of objects by some other method. run("Clear Results"); run("Set Measurements...", "centroid redirect=None decimal=3"); run("Find Maxima...", "noise=10 output=List"); x = newArray(nResults()); y = newArray(nResults()); for(row=0; row<nResults(); row++) { x[row] = getResult("X", row); y[row] = getResult("Y", row); } // for row to get XY locations // calculate shortest and 2nd shortest run("Remove Overlay"); dist = newArray(x.length); for(i=0; i<x.length; i++) { for(k=0; k<x.length; k++) { dist[k] = sqrt(((y[i] - y[k]) * (y[i] - y[k])) + ((x[i] - x[k]) * (x[i] - x[k]))); } // for k inside loop ranking = Array.rankPositions(dist); shortest1 = ranking[1]; // ranking[0] will always give the position of 0 in the distance array shortest2 = ranking[2]; shortest3 = ranking[3]; // uncomment next three lines to show method // Array.print(dist); // Array.print(ranking); // print(""); makeLine(x[i],y[i], x[shortest1],y[shortest1], 1); Overlay.addSelection(shortestColor1); makeLine(x[i]+2,y[i]+2, x[shortest2]+2,y[shortest2]+2, 1); // offset to help show when there are shortest & 2nd shortest Overlay.addSelection(shortestColor2); makeLine(x[i]-2,y[i]-2, x[shortest3]-2,y[shortest3]-2, 1); // offset to help show when there are shortest & 2nd shortest Overlay.addSelection(shortestColor3); /* here are my sad efforts */ a1 = newArray(nResults); a2 = newArray(nResults); doWand(x[i],y[i]); roiManager("add"); run("Set Measurements...", "centroid center feret's redirect=None decimal=3"); run("Measure"); wait(200); a1 = getResult("FeretAngle",i); doWand(x[shortest1],y[shortest1]); roiManager("add"); run("Set Measurements...", "centroid center feret's redirect=None decimal=3"); run("Measure"); wait(200); a2 = getResult("FeretAngle",i); if (a1 != a2) { doWand(x[i],y[i]); run("Add Selection...", "stroke=none width=0 fill=red"); } } On May 23, 2016, at 1:05 PM, Cammer, Michael <[hidden email]<mailto:[hidden email]>> wrote: Curious if anyone thinks this would be useful. It may only need a few lines of code to list the pairs of points and the distances. I wrote it just because I felt like it but no one has brought me a problem to apply it to. http://microscopynotes.com/imagej/macros/shortest_distances_and_clustering/index.html ========================================================================= Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical Center Cell: 914-309-3270 ** Office: Skirball 2nd Floor main office, back right ** http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/ -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Ben Tupper Sent: Monday, May 23, 2016 1:08 PM To: [hidden email] Subject: Re: distance between adjacent particles Hi Len, That's quite an old thread in Nabble. I'm not sure if it will help you, but you could try https://urldefense.proofpoint.com/v2/url?u=http-3A__rsb.info.nih.gov_ij_plugins_graph_index.html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVUnIlg2qHZVtrhy_1M&s=njt95X9CC5z1_RlTbXErpNZ8qshIp4aaCxkviC1GaJI&e= There may be newer tools available that I am not familiar with. Ben On May 22, 2016, at 4:06 PM, dobensl <[hidden email]> wrote: This is a very useful macro and almost takes me to where I want to get - is there a way to find the values for XM2 and YM2 and add these to the results table? Also, could someone briefly describe the logic behind the notion: "initialize it to a large value outside of the for loop"? Thanks, Len Dobens -- View this message in context: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nab ble.com_distance-2Dbetween-2Dadjacent-2Dparticles-2Dtp3699485p5016492. html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05Lzt NstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVUnIlg2 qHZVtrhy_1M&s=SFCtTsIXuwdtQq58bn7D7GiNgO3u5XcXK5w8iufElds&e= Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_ list.html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_ 05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVU nIlg2qHZVtrhy_1M&s=A6W4FamOmzV5A4xjupQZMH0LP7G2kO3EEK6U_jH8mbI&e= -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=CwIFAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=UoPrt3a6dSRFDTVKNKhxQxr9hVUnIlg2qHZVtrhy_1M&s=A6W4FamOmzV5A4xjupQZMH0LP7G2kO3EEK6U_jH8mbI&e= ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html Leonard Dobens, PhD Professor of Molecular Biology and Biochemistry SCB312 School of Biological Sciences University of Missouri-Kansas City 5007 Rockhill Road Kansas City, MO 64110 8162356272 [hidden email]<mailto:[hidden email]> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html !!test6-1.jpeg (57K) Download Attachment |
Free forum by Nabble | Edit this page |