|
Re: finding the center of gravity of an irregularly shaped roi within a 2d array [message #81256 is a reply to message #81253] |
Mon, 03 September 2012 09:26  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
>
> ian.j.ashpole@googlemail.com writes:
>
>> If i can ask, as i am unable to find this in the code as a relative novice, how does your program actually calculate the centroid coordinates?
>
> Each pixel in the ROI is assigned a "weight" of 1, then
> a simple center-of-mass calculation is done:
>
> totalMass = Total(array)
> xcm = Total( Total(array, 2) * Indgen(arrayXSize) * scale[0] ) $
> / totalMass
> ycm = Total( Total(array, 1) * Indgen(arrayYSize) * scale[1] ) $
> / totalMass
> center = [xcm, ycm]
Sorry, I meant to include a link to additional information about
center-of-mass calculations:
http://www.idlcoyote.com/tips/centroid.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: finding the center of gravity of an irregularly shaped roi within a 2d array [message #81257 is a reply to message #81256] |
Mon, 03 September 2012 09:24  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
ian.j.ashpole@googlemail.com writes:
> If i can ask, as i am unable to find this in the code as a relative novice, how does your program actually calculate the centroid coordinates?
Each pixel in the ROI is assigned a "weight" of 1, then
a simple center-of-mass calculation is done:
totalMass = Total(array)
xcm = Total( Total(array, 2) * Indgen(arrayXSize) * scale[0] ) $
/ totalMass
ycm = Total( Total(array, 1) * Indgen(arrayYSize) * scale[1] ) $
/ totalMass
center = [xcm, ycm]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
|