MISS3D / s2p

This repository is not maintained, please use https://github.com/centreborelli/s2p instead.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

creating constant fixed size for rectified_ref.tif and rectified_sec.tif

thedodo opened this issue · comments

Hi!

First of all great project and code I have been using it for a while now as a baseline for my own research!

Unfortunately I am am currently stuck with the following problem: I want to change the code so that all the resulting rectified images (reference and second, one large satellite image pair) of the tiles have always the same constant size. The best would be if the final size of the rectified_ref/rectified_sec.tif would be "tile_size x tile_size".

For now let's assume that the size of the AOI is divisible by the the tile_size (so no resize from adjust_tile_size ) and forget about the border problems of disparity maps (i.e. no margin) .
Then in s2plib/rectification.py in function rectify_pair:

  • You first find matches between ref and sec image using virtual rpc matches
  • Then the F matrix and the homography (H1, H2) is calculated using this matches
  • Then you calculate the max and min disparity range and set the horizontal margin to max(|disp_min|, |disp_max|, hmargin_config) AND compute a translation with the margins that you apply to the homopraphy matrices.

This is the part that I don't understand. Why is this necessary?

Afterwards you apply this homography to the points of the roi and calculate a bounding box? (comment compute output image size).

By try and error I found that if later in this function I write:

common.image_apply_homography(out1, im1, H1, tile_size, tile_size)

That the rectified images have the desired size but of course than when creating the point-cloud out of the disparity it fails (meaning that the tile is only have visible in the ply).

My best guess is that you do this enlargement of the image so that almost all the corresponding points are found in the pairs rather than needing huge overlapping areas. However it can create problems for instance if the AOI is very close to the sat. image border and this "resizing" does not work.

Hopefully I made my issue clear and someone can help me.

best regards