Radius of Gyration for 2D/3D Image analysis?
ilavsky
Hello,
occasionally I need to do image analysis on 2D and 3D data, very similar to blobs in Image Processing Tutorial.
However, I need to calculate for each feature Radius of Gyration (Rg, radius of gyration is the root mean square distance from center of mass of particle) and then do statistical analysis on these Rgs. Is the Igor function which allows me to calculate these Rg values for particles identified in thresholded images like in Image Processing Tutorial?
This code snippet for a radial profile might be of use as a starting point. If I understand correctly, the Rg value would be calculated as a normalized summation of the squares of the values in one of the return waves from the code.
This will only do 2-D grayscale images.
When you are interested, I can send the control panel version of the code development. Contact me off-line.
May 10, 2020 at 01:28 pm - Permalink
Thanks for the suggestion. But that code is for one greyscale particle. I can have hundreds of particles, but binary image. I wonder if anyone already developed this feature in some package - or if there is some way to get for each of these Rg using some existing Igor functions. ImageAnalyzeParticles or some other function. I need to identify all particles - that is easily available from ImageAnalyzeParticles. But then I need for each identify center of mass and calculate sum of root mean square distacne of all voxels belonging to this particle. That is the part where I wonder if anyone knows about some elegant shortcut one could take. I am scratching my head and think that the values in M_rawMoments should let me calculate it directly somehow. High school math is so complicated ;-)
May 10, 2020 at 07:46 pm - Permalink
Can you post a picture of the particles and "hand draw" what you are trying to find? I still have this nagging feeling that an approach using the radial profiler code would do what you need. What is tripping me up here is that you keep mentioning a need for an analysis in VOXELS. I am thinking about the radial analysis on one 2-D grayscale (or binary) image using a pre-specified center point. That is not voxels as far as I understand.
May 12, 2020 at 02:47 pm - Permalink
Not sure if picture is necessary. Example from Image analysis of porous solid: I have Emmental cheese with voids in it, I take random cut through it. I see surface with some voids. I take image. I threshold the image to make it binary - one color for cheese and one for void. Typically, I would calculate the voids total area and related that to total porosity of the cheese. Or I would do histogram on voids areas and relate that to size distribution of the pores. ImageAnalyzeParticles does all of that already, 2D and 3D, and very quickly.
But in my case I sometimes need characterization - of each void - which is not there, at least not obviously. I need to calculate Radius of gyration of each void and do statistics on those. Radius of gyration is (for this simple case of homogeneous materials) simply square root of sum of squares of distances of all pixels(voxels for 3D) in a void from the center of mass of each void. If the void would be represented as three pixels in line, I need to calculate sqrt(1^2+0^2+1^2) as center of mass is in the center pixel. Converting pixel to real dimension is trivial scaling by resolution.
All I wonder if anyone knows some existing package which would do that. I need it rarely and do not want to spend time on making this happen. But, unluckily, the small-angle scattering sees nature through this weird lense so when I want to bit simplistically link my results with microstructure, this analysis would be - sometimes - helpful. If not, I can do more complicated analysis on my data and link results to distribution of sizes, which, as I said, is available in Igor directly through ImageAnalyzeParticles.
The "crickets" response suggests, that I did not miss any obvious Image analysis package in Igor which would calculate Rg for each particle. I'll look if someone wrote it for something like ImageJ or some other platform...
May 12, 2020 at 05:06 pm - Permalink
Hello Jan,
You can call me to discuss this problem. The usual number.
AG
May 13, 2020 at 08:38 am - Permalink
In reply to Not sure if picture is… by ilavsky
I think I went through the algebra correctly and arrived at the following function for caclulating Rg from info provided by
Wave M_RawMoments
Wave W_ImageObjArea
Variable nRg
Variable nSumX2
Variable nSumY2
Variable nSumX
Variable nSumY
Variable nNumPoints
nNumPoints = W_ImageObjArea[0]
nSumX = M_RawMoments[0][0]
nSumY = M_RawMoments[0][1]
nSumX2 = M_RawMoments[0][2]
nSumY2 = M_RawMoments[0][3]
nRg = sqrt( ((nSumX2 + nSumY2 - ((nSumX)^2)/nNumPoints - ((nSumY)^2)/nNumPoints ) / nNumPoints))
return nRg
End
This gives a reasonably correct answer for my simple test case of a circular disc.
I will leave it to you to expand this to multiple particles. Also note that Rg is in pixels.
May 13, 2020 at 11:43 am - Permalink
Hello Jeff,
that is impressive algebra skills. Obviously, you remember algebra! I was hoping there may be some direct way of getting this from these values, but got lost in it somewhere while trying to derive this myself. I'll try to go through the derivations again tomorrow...
I tested few examples I could generate quickly and results indeed match expectations. I'll test more soon and extend as needed. Once more - thanks a lot. I am humbled, so elegant formula...
May 13, 2020 at 07:51 pm - Permalink
In reply to Hello Jeff, that is… by ilavsky
Jan,
Glad to be of help. I spent a few hours messing around on the problem yesterday morning. It was interesting and fun to work on... and the crickets were getting noisey. All the better for having a successful conclusion. And it's not everyday that my work is described as elegant.
Thanks,
Jeff
May 14, 2020 at 08:55 am - Permalink