cds-astro / aladin-lite

An astronomical HiPS visualizer in the browser
https://aladin.cds.unistra.fr/AladinLite/
GNU General Public License v3.0
98 stars 40 forks source link

Add support for PNG/JPEG images with WCS #173

Closed tboch closed 1 month ago

tboch commented 2 months ago

In a similar manner to support of FITS images, it would be great to be able to visualize PNG/JPEG images with astrometry information. In the long term, we might want to support astrometry serialized as AVM tags inside the PNG/JPEG, but to start with, we could have a new method allowing one to display a PNG/JPEG, passing the astrometry as a separate WCS JS dictionary.

bmatthieu3 commented 1 month ago

I took some time to develop this API-like thing:

let aladin = A.aladin('#aladin-lite-div', {fov: 30, survey: "CDS/P/GALEXGR6/AIS/FUV", target: "280 +0", projection: "AIT"});

aladin.setOverlayImageLayer(
  A.image(
    "https://nova.astrometry.net/image/25038473?filename=M61.jpg",
    {
        name: "M61",
        imgFormat: 'jpeg',
        wcs: {
            NAXIS: 0, // Minimal header
            CTYPE1: 'RA---TAN', // TAN (gnomic) projection + SIP distortions
            CTYPE2: 'DEC--TAN', // TAN (gnomic) projection + SIP distortions
            EQUINOX: 2000.0, // Equatorial coordinates definition (yr)
            LONPOLE: 180.0, // no comment
            LATPOLE: 0.0, // no comment
            CRVAL1: 185.445488837, // RA of reference point
            CRVAL2: 4.47896032431, // DEC of reference point
            CRPIX1: 588.995094299, // X reference pixel
            CRPIX2: 308.307905197, // Y reference pixel
            CUNIT1: 'deg', // X pixel scale units
            CUNIT2: 'deg', // Y pixel scale units
            CD1_1: -0.000223666022989, // Transformation matrix
            CD1_2: 0.000296578064584, // no comment
            CD2_1: -0.000296427555509, // no comment
            CD2_2: -0.000223774308964, // no comment
            NAXIS1: 1080, // Image width, in pixels.
            NAXIS2: 705 // Image height, in pixels.
        },
        successCallback: (ra, dec, fov, image) => {
            aladin.gotoRaDec(ra, dec);
            aladin.setFoV(fov)
        }
    },
));

and the result

image

The WCS comes from astrometry.net. I removed the SIP corrections keywords as it is currently not yet supported by wcs-rs lib.