Posted by
Michael Schmid on
Dec 04, 2008; 7:04pm
URL: http://imagej.273.s1.nabble.com/radial-distribution-function-tp3694338p3694339.html
Hi Roger,
you could try the macro below.
DISCLAIMER: I have compared its results with a direct analysis for
very few cases only, so I can't guarantee that the results are
correct (I found some unexpected behaviour of "FFT Math" a while ago,
so this may affect it). Qualitatively, all the RDFs obtained so far
look reasonable to me.
Iif someone knows the exact RDF for a non-trivial image and can
compare it with my macro, this would be highly welcome!
Mind possible line breaks insered by the mailer.
Michael
________________________________________________________________
// 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");
________________________________________________________________
On 4 Dec 2008, at 11:39, Roger Kemp wrote:
> Hi,
>
> I am just wondering if its possible to get the radial distribution
> function
> of circular objects from an image.
>
> I have 8bit greyscale images; by using >imge >adjust >threshold to
> give the
> particles in black on a white background. is it possible to use
> this image
> to calculate the radial distribution function of the particle
> centres using
> ImageJ.
>
> Thanks in advance,
> Roger