Generating DEM from KH4B

14 views
Skip to first unread message

Tirthankar Ghosh

unread,
Apr 10, 2026, 1:35:27 AM (8 days ago) Apr 10
to Ames Stereo Pipeline Support
Hi, I was trying to generate DEM from KH4B stereo pairs, and was stuck with an error at the stage of cam_gen. I am getting a very weird projection errors. See below- 

Loading camera model: /Users/tirthankar/work/Declassified/output/forward/forward_mosaic.tif 
/Users/tirthankar/work/Declassified/raw/forward/sample_obc.tsaiUsing datum: Geodetic Datum --> Name: WGS_1984  Spheroid: WGS 84  Semi-major axis: 6378137  Semi-minor axis: 6356752.3142451793  Meridian: Greenwich at 0  Proj4 Str: +proj=longlat +datum=WGS84 +no_defs
Using nodata value: -3.4028234663852886e+38
Median pixel projection error in the coarse camera: 1212.3152072831451
Median pixel projection error in the refined camera: 72.249027870971219
Output camera center lon, lat, and height above datum: Vector3(75.777207236936221,34.075820949932677,163053.62472574398)

I am using the sample camera setting given in the tutorial here and the sample codes in the tutorial. I am not sure if it is the initial camera model that is creating the problem, also not very sure what will be the parameter values for my case in the camera file. 

Would be grateful if someone can help me identify the mistakes. 

Thanks, 
Tirthankar 

Oleg Alexandrov

unread,
Apr 10, 2026, 1:45:11 AM (8 days ago) Apr 10
to Tirthankar Ghosh, Ames Stereo Pipeline Support
Based on only what you wrote:

Median pixel projection error in the coarse camera: 1212.3152072831451
Median pixel projection error in the refined camera: 72.249027870971219
Output camera center lon, lat, and height above datum: Vector3(75.777207236936221,34.075820949932677,163053.62472574398)

it appears that the camera you get is very rough, which is quite expected for a first pass for KH4B.

I am not sure what you mean by weird projection error. The lon and lat appear legit. The height is 163 km above ground, which is wild. The median pixel reprojection error of 72 pixels is not bad at all at this stage as we do a lot of guessing.

I guess you can check first with the DEM, if the heights are in meters. Then can see if there is any mix up in the order of lon and lat and order of corners. Then you can see if modifying the focal length for the camera (say by 0.5x - 2x or in smaller increments) makes any difference.

You can also try mapprojecting the image with the produced camera onto the DEM. If you at least get the right orientation, that means the corners are good. Then you can play more with focal length or optical center. Otherwise, there can be a mix-up with lon and lat or order, especially if you get a flipped result.

Note that our very latest tutorial for historical images is here: https://stereopipeline.readthedocs.io/en/latest/examples/historical.html#declassified-satellite-images-kh-9. This requires a very recent build, likely the last official release would do.  

It is advised that it is quite tricky to get this right. I think after following the latest doc mentioned above you may end up with a plausible solution, but going from there to a very good solution will not be easy. I also don't know now how differnt KH-4B is different from panoramic KH-9 which we tested a lot more. 

Historical images require a lot of guesswork, have warping, mechanical camera model, etc, which can be quite complicated.




Oleg Alexandrov

unread,
Apr 10, 2026, 1:50:04 AM (8 days ago) Apr 10
to Tirthankar Ghosh, Ames Stereo Pipeline Support
To add, actually a 163 km above ground camera height is corect, that is about the height at which the satellite was. So your pixel error on the ground is too high, which likely suggesets either accuracy in input lon and lat, or the focal length may be off. Or subsequent refinement of the camera model can bring this down. 


Reply all
Reply to author
Forward
0 new messages