Login  Register

Re: Radial distribution function

Posted by Michael Schmid on Mar 14, 2016; 10:28am
URL: http://imagej.273.s1.nabble.com/Radial-distribution-function-tp5015874p5015881.html

Hi Serhiy,

below is a RDF macro (not the very latest version, I fear). Note that it is for 2D RDFs; if you are interested in 3D RDFs you need a correction that depends on the size of the particles.

You need the "Radial Profile" plugin,
  http://rsb.info.nih.gov/ij/plugins/radial-profile.html

An alternative would be finding the centroids with "Analyze Particles" and running a loop that determines all the difference vectors between pairs of particles.

Michael
________________________________________________________________
On Mar 13, 2016, at 22:57, Serhiy Malynych wrote:

> Hi,
>
> I need to determine radial distribution function of nanoparticles from SEM
> image. There are references in the Internet  at imagejdocu.tudor.lu regarding
> macro by Michael Schmid, but the link seems to be old and doesn't open. I
> did install Radial Profile Plot plugin from ImageJ web-site but I'm not
> sure this is exactly what  I need. Can anyone help on that matter.
>
> Thanks,
> Serhiy
________________________________________________________________

// ImageJ macro to calculate the Radial Distribution Function (RDF)
//
// Use with a binary input image having black particles on white background
// Needs the "Radial Profile" plugin, http://rsb.info.nih.gov/ij/plugins/radial-profile.html
//
// Limitations:
// - Particle positions are rounded to nearest full pixel.
// - Distance is in pixels, irrespective of any spatial calibration of the image
//
// Version: 2008-Dec-04 Michael Schmid
//
setBatchMode(true);
width=getWidth;
height=getHeight;
//maxRadius may be modified, should not be larger than 0.3*minOf(width, height);
maxRadius=0.3*minOf(width, height);
minFFTsize=1.3*maxOf(width, height);
title=getTitle();
//make autocorrelation of particle positions
size=4;
while(size<minFFTsize) size*=2;
run("Find Maxima...", "noise=10 output=[Single Points] light exclude");
tempID=getImageID();
tempTitle="temp-"+random();
rename(tempTitle);
run("Canvas Size...", "width="+ size+" height="+ size+" position=Center zero");
run("FD Math...", "image1=["+tempTitle+"] operation=Correlate image2=["+tempTitle+"] result=AutoCorrelation do");
psID=getImageID();
selectImage(tempID);
close();

//make autocorrelation reference to correct finite image size effects
newImage("frame", "8-bit White", width, height, 1);
run("Set...", "value=255");
tempID=getImageID();
rename(tempTitle);
run("Canvas Size...", "width="+ size+" height="+ size+" position=Center zero");
run("FD Math...", "image1=["+tempTitle+"] operation=Correlate image2=["+tempTitle+"] result=AutoCorrReference do");
refID=getImageID();
imageCalculator("Divide", psID,refID);
selectImage(refID);
close();
selectImage(tempID);
close();

//prepare normalized power spectrum for radial averaging
selectImage(psID);
makeRectangle(size/2, size/2, 1, 1);
run("Set...", "value=0");
run("Select None");
circleSize=2*floor(maxRadius)+1;
run("Specify...", "width="+circleSize+" height="+circleSize+" x="+(size/2+0.5)+" y="+(size/2+0.5)+" oval centered");
getRawStatistics(nPixels, mean);
run("Select None");
run("Divide...", "value="+mean);
run("Specify...", "width="+circleSize+" height="+circleSize+" x="+(size/2+0.5)+" y="+(size/2+0.5)+" oval centered");
run("Radial Profile", "x="+(size/2+0.5)+" y="+(size/2+0.5)+" radius="+floor(maxRadius)-1);
rename("RDF of "+title);
selectImage(psID);
close();
setBatchMode("exit and display");

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html