Re: Fractional Pixels Origin? [message #47547] |
Thu, 16 February 2006 21:15  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Greg Hennessy writes:
> Well, Wayne is right in that FITS convention says [1,1] is the center
> of the pixel.
I must be the only one *reading* Wayne's article. :-(
Let me quote it again:
"I'll say that the FITS convention is
that [0,0] locates the center of the pixel."
This whole thing just get curiousier and curiousier. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Fractional Pixels Origin? [message #47548 is a reply to message #47547] |
Thu, 16 February 2006 20:20   |
Greg Hennessy
Messages: 45 Registered: November 2005
|
Member |
|
|
On 2006-02-17, David Fanning <davidf@dfanning.com> wrote:
> I thought Wayne was saying that the center of the first
> pixel was at [0,0], which would mean the pixel spanned
> the distance (on my ruler) of -0.5 to 0.5. JD seems to
> contradict this.
Well, Wayne is right in that FITS convention says [1,1] is the center
of the pixel. JD argues that saying [0.5,0.5] makes sense, and likens
it to a ruler.
It comes down to history. If you do arrays like Fortran, you say that
[1,1] is the center of the pixel. Fortran programmers say the new
millennium started in 2001.
C programers say the center of the pixel is [0.5,0.5], and that the
millennium started in 2000.
|
|
|
Re: Fractional Pixels Origin? [message #47549 is a reply to message #47548] |
Thu, 16 February 2006 16:02   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Wayne Landsman writes:
> I'll say that the FITS convention is that [0,0] locates
> the center of the pixel. (This differs from most other
> image processing standards where [0.,0.] defines the lower
> lefthand corner.)
Then, JD Smith writes:
> FITS does indeed use [0.0,0.0]. I'd urge those of you making the
> choice for your programs to save the world confusion, and adopt the
> "natural" choice: pixels centered on [a.5,b.5].
I'm confused. :-(
I thought Wayne was saying that the center of the first
pixel was at [0,0], which would mean the pixel spanned
the distance (on my ruler) of -0.5 to 0.5. JD seems to
contradict this.
I'm not sure when (if ever) I am going to *use* fractional
pixels, but I would like to understand it. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Fractional Pixels Origin? [message #47550 is a reply to message #47549] |
Thu, 16 February 2006 14:48   |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 15 Feb 2006 21:31:13 +0000, Wayne Landsman wrote:
>
> "CJCrockett" <ccrockett@astro.umd.edu> wrote in message
> news:1140036794.188403.185210@g14g2000cwa.googlegroups.com.. .
>> A quick question. Does anyone know, definitively, what origin IDL uses
>> when defining fractional pixels? Is (0.0,0.0) the center, bottom left,
>> or other, of the pixel?
>>
>>
> As David said, this is a convention which is set outside of IDL, but
> seeing that you have a "astro" E-mail address I'll say that the FITS
> convention is that [0,0] locates the center of the pixel. (This differs
> from most other image processing standards where [0.,0.] defines the lower
> lefthand corner.)
There are actually 3 conventions in common use, with the center of the
lower-left pixel at [0.0,0.0],[0.5,0.5], and [1.0,1.0]. In the first
case, you have negative fractional pixels as valid. In the last case,
[0.,0.] isn't valid.
Only the middle case gets it right in my opinion. I call this the
"ruler convention". I.e. if you had a ruler marked in pixels and
fractional pixels, you would lay it down on the screen or page, and
could directly read out the fractional pixel location.
FITS does indeed use [0.0,0.0]. I'd urge those of you making the
choice for your programs to save the world confusion, and adopt the
"natural" choice: pixels centered on [a.5,b.5].
JD
|
|
|
Re: Fractional Pixels Origin? [message #47560 is a reply to message #47550] |
Thu, 16 February 2006 06:24   |
rm
Messages: 4 Registered: June 2005
|
Junior Member |
|
|
How's about this
pro find_pixel_edge
window, xsize=20, ysize=20
count=intarr(1001)
for i=0, 1000 do begin
plots, [0.0, 0.01*i], [10,10], /device
bits=tvrd()
count(i)=total(bits ne 0)
endfor
print, where(count ne count(1:*))*0.01
end
I've tried on a couple of Linux platforms and versions of IDL and the
result I get is
0.490000 1.49000 2.49000 3.49000 4.49000
5.49000
6.49000 7.49000 8.49000 9.49000
So a new pixel starts at 0.5, 1.5 etc. which makes [0,0] the centre of
a pixel.
|
|
|
Re: Fractional Pixels Origin? [message #47572 is a reply to message #47560] |
Wed, 15 February 2006 14:28   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"CJCrockett" <ccrockett@astro.umd.edu> writes:
> A quick question. Does anyone know, definitively, what origin IDL uses
> when defining fractional pixels? Is (0.0,0.0) the center, bottom left,
> or other, of the pixel?
Greetings, fellow Terrapin! David is right, IDL treats graphics on
the *screen* as whole pixels.
The place where fractional pixels comes in is probably the
INTERPOLATE() routine. That routine definitely considers the place
where the pixel value is defined to be at the *lower left* corner of
the box.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: Fractional Pixels Origin? [message #47581 is a reply to message #47572] |
Wed, 15 February 2006 13:31   |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
"CJCrockett" <ccrockett@astro.umd.edu> wrote in message
news:1140036794.188403.185210@g14g2000cwa.googlegroups.com.. .
> A quick question. Does anyone know, definitively, what origin IDL uses
> when defining fractional pixels? Is (0.0,0.0) the center, bottom left,
> or other, of the pixel?
>
As David said, this is a convention which is set outside of IDL, but seeing
that you have a "astro" E-mail address I'll say that the FITS convention is
that [0,0] locates the center of the pixel. (This differs from most other
image processing standards where [0.,0.] defines the lower lefthand corner.)
--Wayne Landsman
|
|
|
Re: Fractional Pixels Origin? [message #47582 is a reply to message #47581] |
Wed, 15 February 2006 13:03   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
CJCrockett writes:
> A quick question. Does anyone know, definitively, what origin IDL uses
> when defining fractional pixels? Is (0.0,0.0) the center, bottom left,
> or other, of the pixel?
I don't think IDL *defines* fractional pixels, to
tell you the truth. I think somebody else must do
that. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Fractional Pixels Origin? [message #47629 is a reply to message #47549] |
Fri, 17 February 2006 13:25  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Thu, 16 Feb 2006 17:02:20 -0700, David Fanning wrote:
> Wayne Landsman writes:
>
>> I'll say that the FITS convention is that [0,0] locates the center of
>> the pixel. (This differs from most other image processing standards
>> where [0.,0.] defines the lower lefthand corner.)
>
>
> Then, JD Smith writes:
>
>> FITS does indeed use [0.0,0.0]. I'd urge those of you making the choice
>> for your programs to save the world confusion, and adopt the "natural"
>> choice: pixels centered on [a.5,b.5].
>
> I'm confused. :-(
Sorry, I had it backwards, FITS centers the first pixel at [1,1], and
the Nasa library uses [0,0] (which is called "IDL convention"). If
you have a choice, don't choose the FITS standard ([1,1]), or the "IDL
convention" ([0,0]), but the natural "I'm a tiny ant living on the
surface of your detector and measuring pixel positions from the edge
with my tiny little ruler": [0.5,0.5]. The only disadvantage is all
pixel centers are now fractional.
Wayne is very careful to document the convention in all of the NasaLib
routines, so if confused be sure to read the useful doc headers (as I
just did to remedy my confusion!).
JD
|
|
|
Re: Fractional Pixels Origin? [message #47637 is a reply to message #47549] |
Fri, 17 February 2006 05:36  |
mmiller3
Messages: 81 Registered: January 2002
|
Member |
|
|
>>>> > "David" == David Fanning <davidf@dfanning.com> writes:
> Then, JD Smith writes:
>> I'd urge those of you making the choice for your programs
>> to save the world confusion, and adopt the "natural"
>> choice: pixels centered on [a.5,b.5].
Here, here! JD - if you were running for office on that platform,
I'd vote for you!
> I'm not sure when (if ever) I am going to *use* fractional
> pixels, but I would like to understand it. :-)
I used to feel the same way, but then I started working on
multimodality medical image registration. In nut shell, I create
registration transformations for each image from pixel
cooridinates to space coordinates. When I want any image
intensity at any point in space, I use the inverse transforms to
take my space coordinates to pixel coordinates and then
interpolate the original data at those pixel coordinates. If I
use integer pixel coordinates, I natually get nearest neighbor
interpolation. If I want to use some other interpolation method,
I need to use fractional pixel coordinates.
Now my main problem is that every time I see a discussion like
this, I have an anxiety attack about whether or not my code
consistently does what I think it does!
Mike
|
|
|
Re: Fractional Pixels Origin? [message #47639 is a reply to message #47547] |
Fri, 17 February 2006 05:06  |
Greg Hennessy
Messages: 45 Registered: November 2005
|
Member |
|
|
On 2006-02-17, David Fanning <davidf@dfanning.com> wrote:
> Greg Hennessy writes:
>
>> Well, Wayne is right in that FITS convention says [1,1] is the center
>> of the pixel.
>
> I must be the only one *reading* Wayne's article. :-(
>
> Let me quote it again:
>
> "I'll say that the FITS convention is
> that [0,0] locates the center of the pixel."
Well, FITS starts counting at 1, not 0.
Fits has the center of the pixel being the integral value.
|
|
|
Re: Fractional Pixels Origin? [message #47642 is a reply to message #47547] |
Thu, 16 February 2006 23:50  |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
> I must be the only one *reading* Wayne's article. :-(
>
> Let me quote it again:
>
> "I'll say that the FITS convention is
> that [0,0] locates the center of the pixel."
>
> This whole thing just get curiousier and curiousier. :-)
Well, you must not take Wayne too literally. The correct statement is that
the FITS convention is that [1,1] locates the center of the pixel. My
conversion of the "first pixel is [1,1]" in FITS (or FORTRAN) to "first
pixel is [0,0]"
of IDL is so automatic that I hardly think about it, and I was just pointing
out that in FITS an integer value refers to the center of the pixel (whereas
in a "ruler" convention it refers to a corner of a pixel).
The main reason this matters in astronomy is for conversion between the X,Y
pixel centroid of a star to longitude, latitude. So I suppose the
poster's original question is also relevant for the MAP_PROJ_INVERSE,
MAP_PROJ_FORWARD routines in IDL.
--Wayne
|
|
|