RyanBalfanz/PyPDS

Support MER 16 bit decompanded 8 bit images.

Opened this issue · 2 comments

A special case of 16 bit images is a decompanded 8 bit image as in this case:

http://pds-imaging.jpl.nasa.gov/data/mer/spirit/mer2po_0xxx/data/sol0770/edr/2p194722334esfapbcp2592r1m1.img

Which was provided as an example for Issue #11 .

The specific image provided in this sample is indeed a 16 bit storage format but the data itself is still 8 bit. This is indicated by the SAMPLE_BIT_MASK '2#0000000011111111#' and if you hexdump the image you'll confirm this when you see the data is entirely '0099 009A 0097 ...'. To properly display this image you would need to expand or "DECOMPAND" this image back to its original 12 bits (again stored in 16 bits) using LUT3 as indicated by the label: SAMPLE_BIT_MODE_ID = "LUT3" and then linearly scale it back to 8 bits.

The LUTs are publicly available at ftp://pdsimage2.wr.usgs.gov/cdroms/Mars_Exploration_Rover/Spirit/mer2mw_0xxx/document/pancam_users_guide.pdf

I have this fix in progress and have already extracted the LUTs into CSV.

@godber, cool. If you can submit a pull request I'll happily take a look at it.