Subject: image orientation on the screen

From: Mike Newberry <mnewberry at axres.com>
Date: 13 Jan 1997 21:01:07 -0700

Since there is no hardwired spec and no keywords for this, I wonder if
there is a commonly adopted "standard":

Where should pixel (0,0) of a FITS file be displayed on the screen-- in
the upper left or lower left corner? And for which ever is correct,
should the screen image match the orientation (i.e., no mirror reversal)
of what the CCD saw?

Mike Newberry

---

From: bschlesinger at nssdca.gsfc.nasa.gov (Barry M. Schlesinger)
Date: 15 Jan 1997 12:13 EDT

In article <5bgjmp$3fe at noao.edu>, seaman at noao.edu (Rob Seaman) writes...
>Mike Newberry <mnewberry at axres.com> writes:
> 
>> ... I wonder if
>> the upper left or lower left corner?
> 
>Well, IRAF/Ximtool/SAOimage (and others) put the origin at the lower left.
>A FITS file is usually considered to be in fortran storage order, so the
>lines fill left to right before they fill bottom to top....
> 
>The computer graphics "standard" is to have the origin at the upper left.
>Many systems both in and out of astronomy allow the origin to be placed
>in any corner (either overtly, or via syntax that flips axes)....
> 
>> And for which ever is correct, should the screen image match the
>> orientation (i.e., no mirror reversal) of what the CCD saw?
> 
>... It isn't entirely clear how to interpret the orientation of what a
>detector array (not limited to CCDs, or physical detectors in general
>for that matter) "sees".  An orientation may only be defined at the
>point that the image is actually displayed to the user.
> 
>         [detailed discussion omitted]
> 
>Note that FITS WCS provides a (potentially) more rigorous mechanism to
>address these issues.  (FITS might also conceivably benefit from the
>experiences of the remote sensing/GIS communities.)
> 

The current draft of the World Coordinate Systems (WCS) proposal has 
some discussion on these points and can be found via
http://fits.cv.nrao.edu/documents/wcs/wcs/html

				Barry Schlesinger
				FITS Support Office
				GSFC/ADF

---

From: mnewberry at axres.com (Michael Newberry)
Date: 16 Jan 1997 02:19:01 -0700

On 14 Jan 1997 18:36:09 GMT, seaman at noao.edu (Rob Seaman) wrote:

>lines fill left to right before they fill bottom to top.  Data cubes and
>higher dimensional images provide further complications.
>
>in any corner (either overtly, or via syntax that flips axes).  Ximtool,
>for instance, provides buttons that flip the display along either axis.
>Transposing about diagonals requires outside operations.
>
>Depends.
>It isn't entirely clear how to interpret the orientation of what a
>To be less pedantic, note that a scientist and an engineer may want
>to view different orientations of the same field.  An engineer (or
>a paranoid scientist, for that matter) will want to view an array
>in "readout order" - the first pixel/line read out should be the
>first pixel/line displayed.  This allows unambiguous interpretation
>of any imaging defects - for just one example:  do defects precede
>or follow known bad pixels?
>
>A CCD, of course, may be mounted any which way on the telescope, and
>may be read out through any one of the corners.  Multiple readout CCDs
>complicate this further (half the pixels are shifted each way - or
>perhaps four different ways).  Mosaic detectors may have 8 or 16 readouts...
>
>On the other hand, an astronomer will often prefer to see the image
>"correct on the sky".  Note that "correct on the sky" is itself a rather
>fuzzy concept - only in one hemisphere might north be at the top and
>east to the left.  To get more pedantic again, note that the computer
>monitor is rarely placed in any correct orientation relative to the sky.
>
>Rob Seaman

Rob,

This confirms what I thought was the state of things. I have been
pretty close to FITS for some years in astronomy, but I was starting
to wonder if ther had been some improvement or convention that I
hadn't yet heard of.

First we would need to agree that pixel (0,0) or (1,1) goes in the
lower left corner. Then we need to find a way to avoid mirror
reversals of the image with respect to the sky, or the literal view
outside of astronomical imaging.  In TIFF and other pictorial
formats,there is header information that allows the reading software
to show the correct orientation even if there is no world coordinate
system attached to the image.  It is unfortunate that there is no
adopted protocol in the FITS world without going all the way to WCS
calibration.

It would be really useful if there were two keywords that would go
into an image header at the point of origin that could later be used
to give the correct display in the "mirror" sense. This would leave
only rotation as ambiguous but, since CCD's are usually mounted on
telescopes with North or South up, images could be displayed nearly
with East left and North up (or left left and up up).  Along the lines
of the keywords XOVRSCAN and YOVRSCAN, or X-ORIGIN, or X-BIN, etc., we
might use X-FLIP and Y-FLIP, X-MIRROR and Y-MIRROR, XREVERSE and
YREVERSE, or X-INVERT and Y-INVERT,  as logical (T/F) keywords. The
case of no reversals would be keywords not present or  XREVERSE = F
and YREVERSE = F.  We don't need to emend the FITS standard to do
this; some of us in the camera control software and image processing
software world just need to agree on the implementation of the
additional keywords.

Personally, I like XREVERSE and YREVERSE.

Mike Newberry

---

From: Doug Mink <dmink at cfa.harvard.edu>
Date: Fri, 17 Jan 1997 15:45:46 -0500

Mike Newberry <mnewberry at axres.com> writes:
> to give the correct display in the "mirror" sense.

In my world coordinate setting software, I have had to deal with image
rotation and mirroring on an image-by-image basis.  I, too, would
like to have some keywords to specify mirroring (XREVERSE and YREVERSE
sound like the right idea) and position angle of north (NORTHPA?)
standardized as either before or after mirroring.  For the ground-based
optical telescopes with which I have been dealing, these keyword values
stay constant for at least the duration of a run.

-Doug Mink
 Telescope Data Center
 Harvard-Smithsonian Center for Astrophysics

---

From: hodge at bowline.stsci.edu (Phil Hodge)
Date: 20 Jan 1997 18:34:44 GMT

Michael Newberry (mnewberry at axres.com) writes:

>	...

I don't think it's a good idea to create FITS keywords which depend
on the convention for displaying images.  A separate keyword for each
axis is also not very useful for images taken from spacecraft.  The
parity of an image is easily obtained from the sign of the determinant
of the CD matrix (or the PC matrix multiplied by the CDELTi, in Greisen
and Calabretta's notation).  The interpretation of the sign depends on
how you display the image, of course.  The sign is negative for images
that will be displayed correctly (i.e. without mirror reversal, but
possibly rotated) if the first pixel is at the lower left, with the
sample direction running from left to right.

						Phil

---

From: mnewberry at axres.com (Michael Newberry)
Date: 20 Jan 1997 16:29:02 -0700

On 20 Jan 1997 18:34:44 GMT, hodge at bowline.stsci.edu (Phil Hodge)

>sample direction running from left to right.

Phil,

You are right about using the signs of CRDELT1 and CRDELT2.  But you
are talking about World Coordinate keywords whereas I'm talking about
keywords that do not require an world coordinate calibration.  Most
CCD users do not WCS calibrate their images---all I want is North
almost up and East almost left for *display* purposes.

Mike Newberry.

---

From: forveill at gag.observ-gr.fr (Thierry Forveille)
Date: Sat, 25 Jan 1997 05:29:41 +0100

mnewberry at axres.com (Michael Newberry) writes
 > almost up and East almost left for *display* purposes.
If that's all you want, just set the signs of CDELT1 and CDELT2 right,
using either +1 or -1 as is fit for your orientation. That will leave
you with an image displayed with axes labelled in pixel units, and the 
(aproximately) right orientation. 

I'd personally argue for the value of inserting an aproximate value of 
the angular size of a pixel (which even amateur CCD users know to better
(and often much better) than 10%), and get your axes labelled in arc 
seconds. But if you don't want to do that, you don't have to.

Let's not add keywords where they are not needed....

Thierry Forveille
Observatoire de Grenoble
France

PS: Technically CDELTi, CRVALi and CRPIXi are not part of the WCS definitions,
which they predate by many years. They are defined in the original FITS
paper.
------- end -------

---

From: Mark Calabretta <mcalabre at atnf.csiro.au>
Date: Wed, 29 Jan 1997 14:45:15 +1100

On Mon 1997/01/20 16:29:02 PDT, Michael Newberry wrote
in a message to: fitsbits at fits.cv.nrao.edu

>almost up and East almost left for *display* purposes.

The default image orientation is independent of the coordinate system; that
is, the orientation is not determined by the sign of the CDELTn (e.g. you
could have secondary axis descriptions with conflicting signs).  While this
does not preclude a particular FITS viewer from transposing an image in order
to transpose the coordinate system, you couldn't expect all FITS viewers to
do the same thing, and in general I think it unreasonable to expect them to
intuit an orientation from curvilinear coordinate systems which need not be
parallel to the pixel axes, nor even orthogonal.  You were on safer ground
with your X/YREVERSE proposal.

The image orientation convention was added to the WCS proposal to formalize a
long-standing defacto FITS convention.  Strictly speaking it has nothing to
do with WCS (and is unrelated to the FORTRAN array storage convention).

Mark Calabretta
ATNF