comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Center of mess
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Center of mess [message #35980] Tue, 05 August 2003 06:45
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Thomas Launey wrote:
>
> In article <onwudshe4a.fsf@cow.physics.wisc.edu>,
> craigmnet@cow.physics.wisc.edu says...
>
>>
>> Hmm, the problem is that you are assigning pixel values with DINDGEN,
>> which by default will assign 0.0 to pixel 0, 1.0 to pixel 1, and so
>> on. You should add 0.5 to your pixel values, if you intend that the
>> left edge of the pixel is 0.0, the right edge is 1.0, and the center
>> is 0.5, etc.
>>
>> Y=Total(total(array,1,/double)*(dindgen(sizarr[1]) + 0.5))/totalarr
>>
>> and so on.
>>
>> Good luck,
>>
>> Craig
>>
> Actually, my solution was to add 0.5D to the returned X and Y. Still, I
> am concerned that this procedure (without the "+0.5") seems to be quite
> widespread in the IDL community to find centroid. Am I misunderstanding
> the meaning of the returned values ...

Yes. Craig explained the correct interpretation of the returned values.
It is, in a certain sense, the natural interpretation, because it's the
one that is produced by one of the simplest version of the algorithm.
One alternative that would appeal to someone from a Fortran background
would be to assign 1.0 to the center of the first row/column, rather
than 0.0.
Re: Center of mess [message #35982 is a reply to message #35980] Tue, 05 August 2003 02:43 Go to previous message
Thomas Launey is currently offline  Thomas Launey
Messages: 25
Registered: September 1999
Junior Member
In article <onwudshe4a.fsf@cow.physics.wisc.edu>,
craigmnet@cow.physics.wisc.edu says...

>
> Hmm, the problem is that you are assigning pixel values with DINDGEN,
> which by default will assign 0.0 to pixel 0, 1.0 to pixel 1, and so
> on. You should add 0.5 to your pixel values, if you intend that the
> left edge of the pixel is 0.0, the right edge is 1.0, and the center
> is 0.5, etc.
>
> Y=Total(total(array,1,/double)*(dindgen(sizarr[1]) + 0.5))/totalarr
>
> and so on.
>
> Good luck,
>
> Craig
>
Actually, my solution was to add 0.5D to the returned X and Y. Still, I
am concerned that this procedure (without the "+0.5") seems to be quite
widespread in the IDL community to find centroid. Am I misunderstanding
the meaning of the returned values or is it a bug in the procedure ?
Thanks,
Thomas
--
Thomas LAUNEY
Lab. Memory and Learning, RIKEN BSI
Re: Center of mess [message #35988 is a reply to message #35982] Mon, 04 August 2003 22:23 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Thomas Launey <t_launey@brain.riken.go.jp> writes:


> Hello,
> I am trying to calculate the centroid of a small object in an image.
> The procedure that I wrote is very standard; I found the same one in
> David Fannning's archive of this NG and in IDLastro. However, the result
> that I get does not seem right. In the code below, the central pixel of a
> 5x5 image is the peak so I would expect the centroid to be at (2.5,2.5)
> but the result is [2.0,2.0]. I agree that pixel "2" is the correct answer
> but I would expect that the correct coordinates should be the center of
> pixel "2" (I.e.: [2.5,2.5]). I am using this centroid function to refine
> peak coordinates in a 2D cross-correlation so I need this 0.5 pixel
> precision.
...
> ;*** collapse the array on Y axis
> Y=Total(total(array,1,/double)*(dindgen(sizarr[1])))/totalar r
> ;*** collapse the array on X axis
> X=Total(total(array,2,/double)*(dindgen(sizarr[0])))/totalar r

Hmm, the problem is that you are assigning pixel values with DINDGEN,
which by default will assign 0.0 to pixel 0, 1.0 to pixel 1, and so
on. You should add 0.5 to your pixel values, if you intend that the
left edge of the pixel is 0.0, the right edge is 1.0, and the center
is 0.5, etc.

Y=Total(total(array,1,/double)*(dindgen(sizarr[1]) + 0.5))/totalarr

and so on.

Good luck,

Craig
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 6 is available on RSI ftp site
Next Topic: Problems with MPEG

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:22:06 PDT 2025

Total time taken to generate the page: 0.00556 seconds