nasa-jpl / autoRIFT

A Python module of a fast and intelligent algorithm for finding the pixel displacement between two images
Apache License 2.0
218 stars 53 forks source link

Rings of high values on the boundary #15

Closed ShashankBice closed 3 years ago

ShashankBice commented 3 years ago

Hi @leiyangleon and all , Thanks for releasing and maintaining the autoRIFT package. The package is really impressive and some of the functions are really unique. @whyjz and I have been exploring the package for computing displacement maps from optical imagery. We followed the sample test_autoRIFT.py script to implement a similar workflow. We used laplacian filter for preprocessing and converted the datasets to uniform data type. Then we defined a grid using a the recipe in the test_autoRIFT.py script as:

# create the grid if it does not exist (from test_autoRIFT.py)
m,n = obj.I1.shape
xGrid = np.arange(obj.SkipSampleX+10,n-obj.SkipSampleX,obj.SkipSampleX)
yGrid = np.arange(obj.SkipSampleY+10,m-obj.SkipSampleY,obj.SkipSampleY)
nd = xGrid.__len__()
md = yGrid.__len__()
obj.xGrid = np.int32(np.dot(np.ones((md,1)),np.reshape(xGrid,(1,xGrid.__len__()))))
obj.yGrid = np.int32(np.dot(np.reshape(yGrid,(yGrid.__len__(),1)),np.ones((1,nd))))
noDataMask = np.logical_not(obj.xGrid)

The results look great, but we observed that the output has pixels with anomalously high values (~25 pixels in contrast to the actual displacement distribution varying between -2 to 2 px) along the left and upper boundaries. image

Zoomed onto the left and upper portion: image

The right and lower portion appear to be fine: image

We speculate that this might be due to incorrect handling of no-data or due to the feathering operations when merging results with progressively larger chip sizes maybe due to definition of the grid. Can you guide us on how this error is introduced, and ways to avoid it ? A simple fix can just be using a magnitude threshold, but would be good to get to the base of things :)

Thanks, Shashank

leiyangleon commented 3 years ago

@ShashankBice thanks for the interests and feedback in using autoRIFT. This is a margin problem related to geocoded optical imagery in particular and we have seen this for our optical imagery (Landsat-8) test. That is why we adopted a margin cropping routine in testautoRIFT.py, see here. You can apply the same thing after autoRIFT is executed. Magnitude threshold is not recommended as it may bias real signals.

ShashankBice commented 3 years ago

Thanks @leiyangleon ! This works well :) I am closing the issue.