MarsRaw / mars-raw-utils

Utilities for working with publicly available raw MSL & Mars2020 images
MIT License
45 stars 10 forks source link

M20 ECAM Tile Reassembly #7

Closed kmgill closed 1 year ago

kmgill commented 3 years ago

Reassemble the full resolution ECAM tiles into the full frame image.

Requested by Simeon Schmauß

kmgill commented 3 years ago

In progress. Implementation is in m20_ecam_assemble

sschmaus commented 3 years ago

I tried to test this and updated my local repository and recompiled it, but my installation isn't working for me now. Everytime I try to use one of the calibration or assembly commands, I get the following error: image Running WSL2 (ubuntu) and it was working before I recompiled it today.

Maybe I'm missing something, I'm not very used to Linux.

kmgill commented 3 years ago

I tried to test this and updated my local repository and recompiled it, but my installation isn't working for me now. Everytime I try to use one of the calibration or assembly commands, I get the following error: image Running WSL2 (ubuntu) and it was working before I recompiled it today.

Maybe I'm missing something, I'm not very used to Linux.

Which sol & images were you using so I can try to recreate it? The code is still pretty weak so i'm not surprised it crashed, but I am surprised that scale_factor was missing for the NavCam or HazCam images (which this is intended for)

sschmaus commented 3 years ago

I tested with a few images from sol108, but the error also gets displayed when I try to calibrate Ingenuity Navcam images: image Either an issue with my installation that I don't understand, or larger bug in the code

kmgill commented 3 years ago

The tool only works for the Percy's navcams, not for the helicopter. I'll be documenting this, but when the rover takes Navcam images, it chops them into 4x4 tiles and transmits those back to Earth as separate images, which then get individually stretched. My program attempts to reassemble and color match them back together. It crashes for me on a non-downsamples 4x4 reassembly, so there's still work to be done. I hope to get to it eventually, but the helicopter navcam images will take a lot more work in the camera model and pointing to reproject and assemble those into a working map.

sschmaus commented 3 years ago

I'm sorry for the confusion, maybe I need to explain myself a little more clear. I understand what the m20_ecam_assemble command is intended to do. I initially requested this feature on twitter. Yesterday I wanted to test it and updated my local repository with the latest changes and recompiled it.

Since then I am running in the following issue, that regardless of the image calibration/assemble command I am using for the corresponding instrument, I get the same scale_factor error: 1) Trying to calibrate RTE images:

user@DESKTOP-SIMEON:/mnt/e/3DScans/Mars/rawutils/Ingenuity/RTE$ m20_hrte_calibrate -i HSF_0069_0673066081_646ECM_N0040001HELI00001_000085J01.png
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `scale_factor`", line: 39, column: 1)', src/metadata.rs:142:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

2) Trying to calibrate a SUPERCAM image from Sol 107:

user@DESKTOP-SIMEON:/mnt/e/3DScans/Mars/rawutils/SUPERCAM$ m20_scam_calibrate -i LRF_0107_0676441256_160EBY_N0040592SCAM01107_0010I9J01.png
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `scale_factor`", line: 39, column: 1)', src/metadata.rs:142:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

3) Trying to assemble these four NAVCAM images NLF_0108_0676532429_682ECM_N0040738NCAM03108_01_195J01.png NLF_0108_0676532429_682ECM_N0040738NCAM03108_04_195J01.png NLF_0108_0676532429_682ECM_N0040738NCAM03108_07_195J01.png NLF_0108_0676532429_682ECM_N0040738NCAM03108_10_195J01.png from Sol 108, that are located in the same folder:

user@DESKTOP-SIMEON:/mnt/e/3DScans/Mars/rawutils/NAVCAM/test$ m20_ecam_assemble -i *.png -o NLF_0108_0676532429_682ECM_N0040738NCAM03108_assembled.png
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `scale_factor`", line: 39, column: 1)', src/metadata.rs:142:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I assume this is a bug somewhere in your code, the scale_factor value is present in every corresponding .json file, either with a value of "UNK" or "1" for the non ECAM images, or "2" for the images I tried to assemble.

In case this is an issue with my local installation, I already deleted the whole repository, cloned it and recompiled it again. I don't know if and how I have to remove the previous installation, so maybe that is my issue.

I probably should have opened a new issue, instead of commenting under this one. That might have caused less confusion.

sschmaus commented 3 years ago

Ok, I have an update to my issue.

Only found out today that you changed the .json metadata file structure. The reason my commands failed was due to me using files that were fetched with the old installation, therefore the scale_factor value was at a different location in the file and could not be read by the program.

I tried it again with newly fetched files and the assembly was carried out. Unfortunately the color matching had a few issues, especially with the upper right corner:

NLF_0137_0679105239_661ECM_N0051812NCAM03137

NLF_0137_0679104759_995ECM_N0051812NCAM03137

The second one also has extremely clipped highlights, maybe that can be avoided.

kmgill commented 1 year ago

Completed