Commit 7002fc05 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

COREG_LOCAL: target image is now warped prior to tie point grid computation ->...

COREG_LOCAL: target image is now warped prior to tie point grid computation -> saves 30-40% of total runtime

components.CoReg.COREG:
- added equalize_pixGrids()
- _get_image_windows_to_match(): warping is now only executed if pixel grids are really different

components.CoReg.COREG_LOCAL:
- __init__(): edited docstring

components.Geom_Quality_Grid.Geom_Quality_Grid:
- __init__(): edited docstring
- get_CoRegPoints_table(): included equalization of pixel grids prior to computation of tie point grid -> saves 30-40% of total runtime

- updated __version__
parent 3aef0c73
......@@ -9,7 +9,7 @@ from .components import utilities
from .components import geometry
__author__ = 'Daniel Scheffler'
__version__= '2016-11-24_01'
__version__= '2016-11-25_01'
__all__=['COREG',
'COREG_LOCAL',
......
......@@ -369,6 +369,15 @@ class COREG(object):
%(get_proj4info(proj=self.ref.prj), get_proj4info(proj=self.shift.prj))
def equalize_pixGrids(self):
"""
Equalize image grids and projections of reference and target image (align target to reference).
"""
if not (prj_equal(self.ref.prj, self.shift.prj) and self.ref.xygrid_specs==self.shift.xygrid_specs):
self.shift.arr = self.shift[self.shift.band4match]
self.shift.reproject_to_new_grid(prototype=self.ref)
def show_image_footprints(self):
"""This method is intended to be called from Jupyter Notebook and shows a web map containing the calculated
footprints of the input images as well as the corresponding overlap area."""
......@@ -676,16 +685,20 @@ class COREG(object):
# (in order to make each image show the same window with the same coordinates)
# TODO replace cubic resampling by PSF resampling - average resampling leads to sinus like distortions in the fft image that make a precise coregistration impossible. Thats why there is currently no way around cubic resampling.
tgt_xmin,tgt_xmax,tgt_ymin,tgt_ymax = self.matchBox.boundsMap
self.otherWin.arr, self.otherWin.gt = warp_ndarray(self.otherWin.arr,
self.otherWin.gt,
self.otherWin.prj,
self.matchWin.prj,
out_gsd = (self.imfft_gsd, self.imfft_gsd),
out_bounds = ([tgt_xmin, tgt_ymin, tgt_xmax, tgt_ymax]),
rspAlg = _dict_rspAlg_rsp_Int[self.rspAlg_calc],
in_nodata = self.otherWin.nodata,
CPUs = None if self.mp else 1,
progress = False) [:2]
# equalize pixel grids and projection of matchWin and otherWin (ONLY if grids are really different)
if not(self.matchWin.xygrid_specs==self.otherWin.xygrid_specs and
prj_equal(self.matchWin.prj, self.otherWin.prj)):
self.otherWin.arr, self.otherWin.gt = warp_ndarray(self.otherWin.arr,
self.otherWin.gt,
self.otherWin.prj,
self.matchWin.prj,
out_gsd = (self.imfft_gsd, self.imfft_gsd),
out_bounds = ([tgt_xmin, tgt_ymin, tgt_xmax, tgt_ymax]),
rspAlg = _dict_rspAlg_rsp_Int[self.rspAlg_calc],
in_nodata = self.otherWin.nodata,
CPUs = None if self.mp else 1,
progress = False) [:2]
if self.matchWin.shape != self.otherWin.shape:
self.tracked_errors.append(
......
......@@ -39,7 +39,7 @@ class COREG_LOCAL(object):
:param im_ref(str, GeoArray): source path of reference image (any GDAL compatible image format is supported)
:param im_tgt(str, GeoArray): source path of image to be shifted (any GDAL compatible image format is supported)
:param grid_res: quality grid resolution in pixels of the target image
:param grid_res: quality grid resolution in pixels of the target image (x-direction)
:param max_points(int): maximum number of points used to find coregistration tie points
NOTE: Points are selected randomly from the given point grid (specified by
'grid_res'). If the point does not provide enough points, all available points
......
......@@ -44,7 +44,7 @@ class Geom_Quality_Grid(object):
Thus 'Geom_Quality_Grid' can be used to correct for locally varying geometric distortions of the target image.
:param COREG_obj(object): an instance of COREG class
:param grid_res: grid resolution in pixels of the target image
:param grid_res: grid resolution in pixels of the target image (x-direction)
:param max_points(int): maximum number of points used to find coregistration tie points
NOTE: Points are selected randomly from the given point grid (specified by
'grid_res'). If the point does not provide enough points, all available points
......@@ -239,6 +239,10 @@ class Geom_Quality_Grid(object):
if self.max_points:
GDF = GDF.sample(self.max_points).copy()
# equalize pixel grids in order to save warping time
if len(GDF)>100:
self.COREG_obj.equalize_pixGrids() # NOTE: actually grid res should be also changed here because self.shift.xgsd changes and grid res is connected to that
# declare global variables needed for self._get_spatial_shifts()
global global_shared_imref,global_shared_im2shift
assert self.ref .footprint_poly # this also checks for mask_nodata and nodata value
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment