NeoGeographyToolkit / StereoPipeline

The NASA Ames Stereo Pipeline is a suite of automated geodesy & stereogrammetry tools designed for processing planetary imagery captured from orbiting and landed robotic explorers on other planets.
Apache License 2.0
478 stars 168 forks source link

Error when implement "sfs" commond #365

Closed Caow9 closed 1 year ago

Caow9 commented 2 years ago

Describe the bug I have been studied sfs based on the shape-from-shading examples in the section 12.7 "SfS with multiple images in the presence of shadows". When I implement the sfs commands in page 162 in asp_book, there exist this message of error: "Found DEM nodata value: -3.40282e+38"


Here is the code and the related error: (asp) caowei@CAOs-MacBook-Pro test % sfs -i run_sub10/run-crop-DEM.tif A_crop_sub10.cub C_crop_sub10.cub D_crop_sub10.cub -o sfs_sub10_ref1/run --threads 4 --smoothness-weight 0.12 --initial-dem-constraint-weight 0.001 --reflectance-type 1 --use-approx-camera-models --max-iterations 5 --crop-input-images --bundle-adjust-prefix run_ba_sub10/run --blending-dist 10 --min-blend-size 20 --shadow-thresholds '0.00162484 0.0012166 0.000781663' --> Setting number of processing threads to: 4 Writing log info to: sfs_sub10_ref1/run-log-sfs-05-29-0810-80483.txt Shadow threshold and max valid value for A_crop_sub10.cub 0.00162484 3.40282e+38 Shadow threshold and max valid value for C_crop_sub10.cub 0.0012166 3.40282e+38 Shadow threshold and max valid value for D_crop_sub10.cub 0.000781663 3.40282e+38 Found DEM nodata value: -3.40282e+38 DEM cols and rows: 99 93 Found a no-data or NaN pixel in the DEM. Cannot continue. The dem_mosaic tool can be used to fill in holes. Then crop and use a clip from this DEM having only valid data.

My Environment is macOS Monterey version 12.4

Additional context I have used dem_mosaic, and check the previous steps carefully. However, the same problem happened.

rbeyer commented 2 years ago

The error is telling you everything you need to know. Your starting DEM has "nodata" values in it, and the sfs algorithm cannot "begin" from a DEM that has nodata values in it. The advice in the error message says to use dem_mosaic on your starting DEM to fill in the holes (by using a value for --hole-fill-length). If the "nodata" areas are large that may result in bad interpolation, and you may find that using dem_mosaic to mosaic a lower-resolution DEM into these larger holes is good. Or you can use any method you like to fill in the "missing" data in your DEM. Sometimes if the "nodata" pixels are at the edges, it is easier to just trim those pixels off.

Whatever you do, the DEM you give to sfs to start with must have no "nodata" pixels in it.

oleg-alexandrov commented 2 years ago

The message ""Found DEM nodata value: -3.40282e+38"" is not an error though. The following convention is followed. If your DEM has a hole, height values in that hole are assigned to this value so that they are not confused with valid heights.

The problem is with the message "Found a no-data or NaN pixel in the DEM. Cannot continue". What you need to do is open that DEM in stereo_gui, examine it, and select a region not having holes or missing data (which appear black). Then use gdal_translate to get a clip with no holes, and run SfS on it. There is more info here: https://stereopipeline.readthedocs.io/en/latest/sfs_usage.html#initial-dem-creation.

(I see that Ross got ahead of me, but apparently we say complementary things.)