NASA-PDS / transform

Transforms PDS3 and PDS4 product labels and data into various formats.
https://nasa-pds.github.io/transform/
Apache License 2.0
14 stars 1 forks source link

As a user, I would like to scale the brightness of an image for conversion to enable more usable output. #24

Open msbentley opened 3 years ago

msbentley commented 3 years ago

Is your feature request related to a problem? Please describe. transform doesn't appear to do any kind of image value scaling when converting a PDS4 image to a bitmap. This means that for many images the result is not usable (e.g. all black, all white). This is particularly apparent when trying to transform an Array_2D_Image using float values (e.g. IEEE754LSBSingle).

Describe the solution you'd like To add options to scale/stretch the brightness/pixel values to cover the range allowed by the output format. Many software packages offer simple linear scaling from min to max values - I would consider this a good default.

The options used by the DS9 FITS viewer are described here: https://www.mn.uio.no/astro/english/services/it/help/visualization/saoimage-ds9/ds9/mscale.html and other modes could also be implemented.

PDS4 Tools also offers linear/log/square root/squared scaling, and two choices for the histogram limits (min/max and zscale).

Describe alternatives you've considered Using python PDS4 Tools + matplotlib.

jordanpadams commented 3 years ago

+1 @msbentley we will add this to our list

jordanpadams commented 3 years ago

@msbentley some other alternatives off the top of my head are imagemagick, gdal, or VICAR, but not sure how/if they will work well with the product. although the main issue there is those can only scale the pixels after the fact. (VICAR should work well with VICAR/PDS Image products as long as they have an attached ODL label in the header.)

msbentley commented 3 years ago

Thanks @jordanpadams to give a specific example for testing:

ftp://psa.esac.esa.int/pub/mirror/ExoMars2016/em16_tgo_cas/data_calibrated/Science_Phase/Orbit_Range_8400_8499/Orbit_8454/Science/554197692/PAN/cas_cal_sc_20191016T004323-20191016T004327-8454-48-PAN-554197692-0-0.xml ftp://psa.esac.esa.int/pub/mirror/ExoMars2016/em16_tgo_cas/data_calibrated/Science_Phase/Orbit_Range_8400_8499/Orbit_8454/Science/554197692/PAN/cas_cal_sc_20191016T004323-20191016T004327-8454-48-PAN-554197692-0-0.dat

If I look at this in the SBN python viewer:

image

as you can see in the scale the range of values is small, and the values are low. When I convert to a TIF I get just a black rectangle :)

This is not a problem for me now - I just suggested to somebody that they used transform to perform this task, and then tried it myself and realised I could not. But obviously there are many ways to do this having read in the data to e.g. matplotlib/PIL.

jordanpadams commented 3 years ago

@msbentley 100% agree. we will use this data to test if it works in PDSView as well