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

Crop image and save modified RPCs #434

Closed druidance closed 1 month ago

druidance commented 1 month ago

Is your feature request related to a problem? Please describe. Before creating and deploying a pipeline to the PROD, I need to assess intermediate stages on smaller patches of images (I have limited infrastructure capabilities for this purpose). To refine the assessment process, I want to:

  1. cut out small patches out of images with adapted RPCs
  2. perform bundle_adjust
  3. mapproject the resulting images
  4. run parallel_stereo

While mapproject already works with projwin option, it creates orthorectified images which I can't use in my assessment process.

Describe the solution you'd like A command-line tool that allows to crop image while saving modified RPCs in a separate file. Something like: crop -t rpc image.tif ~/output/

Once the process is finished, ~/output/ contains two files:

Describe alternatives you've considered Unfortunately, I didn't find any other solutions to my problem.

Additional context Thank you for such a powerful tool :bow:. When I first found it, I couldn't believe my eyes it has so many cool features :star:.

oleg-alexandrov commented 1 month ago

I think the tool cam2rpc should already be doing this. https://stereopipeline.readthedocs.io/en/latest/tools/cam2rpc.html

See if it works for you.

druidance commented 1 month ago

@oleg-alexandrov, thank you! I think this tool is exactly what I need.

However, I encountered a few issues while testing it. If I may ask, could you suggest a way to:

  1. calculate the --height-range values (in terms of WGS84 as an example) in case no DEM is provided?
  2. make sure the resulting image has the same BBOX as provided through --lon-lat-range in case DEM is provided? Even though I specify the range, the output has a bigger BBOX (please, see the image below). image
oleg-alexandrov commented 1 month ago

The height range is something you can figure approximately. It roughly correlates with the height above sea level. If you are not sure, use 0 to 4000 or so.

The image that comes out has to be produced via a crop, so it cannot be in any other shape than a box with sides parallel to the original sides.

These are usually not a limitation. Having both the image and range of elevations be a little more than desired does not prevent one from testing small areas. You just get more than what you bargained for. :)

On Fri, May 17, 2024 at 1:49 AM druidance @.***> wrote:

@oleg-alexandrov https://github.com/oleg-alexandrov, thank you! I think this tool is exactly what I need.

However, I encountered a few issues while testing it. If I may ask, could you suggest a way to:

  1. calculate the --height-range values (in terms of WGS84 as an example) in case no DEM is provided?
  2. make sure the resulting image has the same BBOX as provided through --lon-lat-range in case DEM is provided? Even though I specify the range, the output has a bigger BBOX (please, see the image below). image.png (view on web) https://github.com/NeoGeographyToolkit/StereoPipeline/assets/160344534/6805e104-9159-42cb-b41d-504d0f8aeecb

— Reply to this email directly, view it on GitHub https://github.com/NeoGeographyToolkit/StereoPipeline/issues/434#issuecomment-2117063628, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKDU3F3U6QR5TBMSYNRC7TZCXACTAVCNFSM6AAAAABH2C3UG6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJXGA3DGNRSHA . You are receiving this because you were mentioned.Message ID: @.***>

druidance commented 1 month ago

@oleg-alexandrov, thank you for clarifying things out for me. I really appreciate your time and effort.

I think the community would benefit from this info being added to the official docs as it explains the orientation of the resulting image:

The image that comes out has to be produced via a crop, so it cannot be in any other shape than a box with sides parallel to the original sides.