Login  Register

Re: Moment of inertia calculations

Posted by Liu, Dongfang (NIH/NIAID) [F] on Feb 23, 2006; 1:52pm
URL: http://imagej.273.s1.nabble.com/Moment-of-inertia-calculations-tp3703568p3703573.html

Dear Bob,
 
Thank you for the macro that calculate the center of mass.
Could you tell me how to calculate the "center of Grey"?
Thank you very much.

Best regards
df

> ----------
> From: Robert Dougherty
> Reply To: List IMAGEJ
> Sent: Wednesday, February 22, 2006 7:48 PM
> To: List IMAGEJ
> Subject: Re: Moment of inertia calculations
>
> This macro might be a start.  It uses the center of mass as the axis of
> rotation, assumed perpendicular to the image.  (The conversion for a
> different axis appears to be to add Md^2 according to the "parallel axis
> theorem for moments of inertia," where M is the total mass and d is the
> displacement to the new axis.)  The macro presumably needs to be calibrated
> to convert pixels into length units and image levels into mass.
>
> Bob
>
> Robert P. Dougherty, Ph.D.
> President, OptiNav, Inc.
> Phone (425) 467-1118
> Fax (425) 467-1119
> www.optinav.com
>  
>
> // Find the center of mass
>
>      getBoundingRect(x1, y1, width, height);
>      xSum = 0;
>      ySum = 0;
>      sum = 0;
>      x2 = x1 + width;
>      y2 = y1 + height;    
>      for (x=x1; x<x2; x++) {
>         for (y=y1; y<y2; y++) {
>             v = getPixel(x, y);
>             xSum += v*x;
>             ySum += v*y;
>             sum += v;
>           }
>      }
>      x0 = xSum/sum;
>      y0 = ySum/sum;
>
> // Find the moment of inertia about the center of mass
>
>      moment = 0;
>      for (x=x1; x<x2; x++) {
>          for (y=y1; y<y2; y++) {
>              v = getPixel(x, y);
>              rSq = (x-x0)*(x-x0) + (y-y0)*(y-y0);
>              moment = moment + v*rSq;
>          }
>      }
>      print(x0+" "+y0+" "+moment);
>
>
>
>
> > -----Original Message-----
> > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> > Debra K Schneider
> > Sent: Wednesday, February 22, 2006 8:18 AM
> > To: [hidden email]
> > Subject: Moment of inertia calculations
> >
> > Hi
> > I am interested in measuring the moment of inertia of a bone slice.
> > Can this be done in ImageJ?
> > Thank you
> > Debby Schneider
>
>