Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for transforming PDS3 image files to 16-bit output #15

Open
jordanpadams opened this issue Oct 30, 2019 · 2 comments
Open
Labels

Comments

@jordanpadams
Copy link
Member

Is your feature request related to a problem? Please describe.
Per user request, would like the capability to convert a 16bit PDS3 image to a 16bit output viewable image format.

Currently all images are output to 8bit formats.

@isenberg
Copy link

isenberg commented Aug 13, 2022

Same for PDS4.

I'd say the current processing is a bug where it just linearly scales for example the raw EDR files from Perseverance Rover SignedMSB2 (16 bit) to 8 bit PNG or 8 bit TIFF. The time of 8 bit numbers of image intensity is over for many years now.

Or does some other free software exist to convert the current Mars 2020 raw images on current macOS? NASAView for example isn't available anymore for current macOS.

Example: Download EDR pair of .IMG/.XML from the _raw directories of https://pds-imaging.jpl.nasa.gov/data/mars2020 and then run it:

% grep data_type SOME_ID.xml
        <data_type>SignedMSB2</data_type>

% /usr/libexec/java_home -v 1.8.0 --exec java -showversion \
  -Dcom.sun.media.jai.disableMediaLib=true \
  -Doverwrite.output=true -cp $HOME/git/transform/target/transform-*-SNAPSHOT-jar-with-dependencies.jar \
  gov.nasa.pds.transform.TransformLauncher -f png SOME_ID.xml

% file SOME_ID.png
SOME_ID.png: PNG image data, 1280 x 960, 8-bit/color RGB, non-interlaced

In case anyone is wondering about how to build the jar with dependencies here from source. Add the following lines in pom.xml after

               <goal>single</goal>
             </goals>
             <configuration>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>

With that a simple git clone and mvn package is needed to build it on OpenJDK 8.

@isenberg
Copy link

In case others want to give it a try:

I looked a bit into the code around src/main/java/gov/nasa/pds/transform/product/Pds4ImageTransformer.java and the 8 bit output appears to be caused by the JAI image writer outside of the PDS tools, but I'm not 100% sure yet. At least the used gov.nasa.pds.objectAccess.ImageExporter is producing internally 16 bit arrays (ElementArray.getDataType() returns SignedMSB2) though later that's reduced to 8.

Even enforcing with ((TwoDImageExporter)exporter).setTargetPixelDepth(16) didn't help. Still 8bit output.

Switching to the latest versions of the PDS loader libraries didn't help either. It's simple, just change in pom.xml:

     <dependency>
       <groupId>gov.nasa.pds</groupId>
       <artifactId>pds3-product-tools</artifactId>
-      <version>4.0.1</version>
+      <version>4.1.0</version>
       <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>gov.nasa.pds</groupId>
       <artifactId>pds4-jparser</artifactId>
-      <version>1.2.0</version>
+      <version>2.2.1</version>
       <scope>compile</scope>
     </dependency>
     <dependency>

If it's due to the old JAI, a solution may be to replace that by https://eclipse.github.io/imagen/migration which uses internally the newer javax.imageio.ImageIO. But even the old JAI already supported 32bit/channel images and at least 16bit/channel PNG writing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ToDo
Development

No branches or pull requests

2 participants