What I am trying to do
Using DTM files(IMG file extension) from HiRise dataset(https://hirise.lpl.arizona.edu/), I would like to align overlapping terrains into one large terrain. The idea is that I want to automate this process through batch files and scripting so that i can dynamically create a large 3D terrain map based bounding box set by GPS coordinates of Mars. I do understand that completely automating this process will make it very difficult/impossible to get 100% accuracy on aligning these DTMs. Let's assume this is acceptable for now. See photos below
The above images are displayed using blender, this is not relevant other than the resulting combined images need to be in a format that can be imported into blender as a mesh
What I have tried
I tried using gdalwarp and this was the result.
gdalwarp does not support creating files in PDS4 format so this was created in ISIS2 format and then converted to ISIS3 format using pds2isis
I have also tried the various ISIS3 utilities and walkthroughs on USGS site and keep getting various errors which i did not save but can recreate if needed.
I have some requirements that restrict software i can use
1. Software must be opensource(GPL)
2. Software must have a command line options for all utilities
Sorry if i am misusing any terms. From what i have read this is a mosaic but if it is a merge please let me know and i will update question.