radial distribution function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

radial distribution function

Roger Kemp
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
Reply | Threaded
Open this post in threaded view
|

Problems with the ROIs and mask

Jose Luis Asensio
Hi,

I have just realized that the ROIs behave in a very strange way the  
first time they are created when they are not rectangular.

Debugging the code and working with the Z_Profiler plugin, when a ROI  
is created the first time, the ROI is Wx pixels width and Hy pixels  
height, so the number of pixels in the rectangle is Wx*Hy. But when a  
ROI with a mask is used (Oval ROI for example), the first time the roi  
is created, the mask is not this size so when the Z_Profiler sets the  
ROI to calculate the mean value of the roi for the ImageProcessor and  
shows the Z axis, it does not use the mask because of this size  
diference.

So, the very first time the roi is created and until the size of the  
roi is modified (once one property is modified the mask cache is  
erased and calculated again this time correctly), every roi works as a  
rectangular roi, with mask equal to null.

As anyone relizes this problem? is there a way to avoid this problem?

You can see it in the ImageProcessor class, in the setRoi(ij.gui.Roi  
roi) method afther the mask is stored, the boundary rectangle is  
stored and due to size diferences when the rectangle is stored the  
mask is erased.

Thanks a lot.
Jose Luis


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Reply | Threaded
Open this post in threaded view
|

Re: radial distribution function

Michael Schmid
In reply to this post by Roger Kemp
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