def compute_tiles_coordinates(rx, ry, rw, rh, tw, th, z=1): """ """ out = [] neighborhood_dict = dict() for y in np.arange(ry, ry + rh, th): h = min(th, ry + rh - y) for x in np.arange(rx, rx + rw, tw): w = min(tw, rx + rw - x) # ensure that tile coordinates are multiples of the zoom factor x, y, w, h = common.round_roi_to_nearest_multiple(z, x, y, w, h) out.append((x, y, w, h)) # get coordinates of tiles from neighborhood out2 = [] for y2 in [y - th, y, y + th]: h2 = min(th, ry + rh - y2) for x2 in [x - tw, x, x + tw]: w2 = min(tw, rx + rw - x2) if rx + rw > x2 >= rx: if ry + rh > y2 >= ry: x2, y2, w2, h2 = common.round_roi_to_nearest_multiple( z, x2, y2, w2, h2) out2.append((x2, y2, w2, h2)) neighborhood_dict[str((x, y, w, h))] = out2 return out, neighborhood_dict
def compute_tiles_coordinates(rx, ry, rw, rh, tw, th, z=1): """ """ out = [] neighborhood_dict = dict() for y in np.arange(ry, ry + rh, th): h = min(th, ry + rh - y) for x in np.arange(rx, rx + rw, tw): w = min(tw, rx + rw - x) # ensure that tile coordinates are multiples of the zoom factor x, y, w, h = common.round_roi_to_nearest_multiple(z, x, y, w, h) out.append((x, y, w, h)) # get coordinates of tiles from neighborhood out2 = [] for y2 in [y - th, y, y + th]: h2 = min(th, ry + rh - y2) for x2 in [x - tw, x, x + tw]: w2 = min(tw, rx + rw - x2) if rx + rw > x2 >= rx: if ry + rh > y2 >= ry: x2, y2, w2, h2 = common.round_roi_to_nearest_multiple(z, x2, y2, w2, h2) out2.append((x2, y2, w2, h2)) neighborhood_dict[str((x, y, w, h))] = out2 return out, neighborhood_dict
def build_cfg(user_cfg): """ Populate a dictionary containing the s2p parameters from a user config file. This dictionary is contained in the global variable 'cfg' of the config module. Args: user_cfg: user config dictionary """ # check that all the mandatory arguments are defined check_parameters(user_cfg) # fill the config module: updates the content of the config.cfg dictionary # with the content of the user_cfg dictionary cfg.update(user_cfg) # sets keys 'clr', 'cld' and 'roi' of the reference image to None if they # are not already defined. The default values of these optional arguments # can not be defined directly in the config.py module. They would be # overwritten by the previous update, because they are in a nested dict. cfg['images'][0].setdefault('clr') cfg['images'][0].setdefault('cld') cfg['images'][0].setdefault('roi') cfg['images'][0].setdefault('wat') # Make sure that input data have absolute paths for i in range(0, len(cfg['images'])): for d in ['clr', 'cld', 'roi', 'wat', 'img', 'rpc']: if d in cfg['images'][i] and cfg['images'][i][d] is not None: cfg['images'][i][d] = os.path.abspath(cfg['images'][i][d]) # check the zoom factor z = cfg['subsampling_factor'] assert (z > 0 and z == np.floor(z)) # ensure that the coordinates of the ROI are multiples of the zoom factor, # to avoid bad registration of tiles due to rounding problems. x = cfg['roi']['x'] y = cfg['roi']['y'] w = cfg['roi']['w'] h = cfg['roi']['h'] x, y, w, h = common.round_roi_to_nearest_multiple(z, x, y, w, h) cfg['roi'] = {'x': x, 'y': y, 'w': w, 'h': h} # if srtm is disabled set disparity range method to sift if 'disable_srtm' in cfg and cfg['disable_srtm']: cfg['disp_range_method'] = 'sift' # get utm zone if 'utm_zone' not in cfg or cfg['utm_zone'] is None: cfg['utm_zone'] = rpc_utils.utm_zone(cfg['images'][0]['rpc'], x, y, w, h)
def build_cfg(user_cfg): """ Populate a dictionary containing the s2p parameters from a user config file. This dictionary is contained in the global variable 'cfg' of the config module. Args: user_cfg: user config dictionary """ # check that all the mandatory arguments are defined check_parameters(user_cfg) # fill the config module: updates the content of the config.cfg dictionary # with the content of the user_cfg dictionary cfg.update(user_cfg) # sets keys 'clr', 'cld' and 'roi' of the reference image to None if they # are not already defined. The default values of these optional arguments # can not be defined directly in the config.py module. They would be # overwritten by the previous update, because they are in a nested dict. cfg['images'][0].setdefault('clr') cfg['images'][0].setdefault('cld') cfg['images'][0].setdefault('roi') cfg['images'][0].setdefault('wat') # Make sure that input data have absolute paths for i in range(0,len(cfg['images'])): for d in ['clr','cld','roi','wat','img','rpc']: if d in cfg['images'][i] and cfg['images'][i][d] is not None: cfg['images'][i][d] = os.path.abspath(cfg['images'][i][d]) # check the zoom factor z = cfg['subsampling_factor'] assert(z > 0 and z == np.floor(z)) # ensure that the coordinates of the ROI are multiples of the zoom factor, # to avoid bad registration of tiles due to rounding problems. x = cfg['roi']['x'] y = cfg['roi']['y'] w = cfg['roi']['w'] h = cfg['roi']['h'] x, y, w, h = common.round_roi_to_nearest_multiple(z, x,y, w, h) cfg['roi'] = {'x': x, 'y': y, 'w': w, 'h': h} # if srtm is disabled set disparity range method to sift if 'disable_srtm' in cfg and cfg['disable_srtm']: cfg['disp_range_method'] = 'sift' # get utm zone if 'utm_zone' not in cfg or cfg['utm_zone'] is None: cfg['utm_zone'] = rpc_utils.utm_zone(cfg['images'][0]['rpc'], x, y, w, h)
def compute_tiles_coordinates(rx, ry, rw, rh, tw, th, z=1): """ """ out = [] for y in np.arange(ry, ry + rh, th): h = min(th, ry + rh - y) for x in np.arange(rx, rx + rw, tw): w = min(tw, rx + rw - x) # ensure that tile coordinates are multiples of the zoom factor x, y, w, h = common.round_roi_to_nearest_multiple(z, x, y, w, h) out.append((x, y, w, h)) return out