def delta_range_filter_handler(config): current_filter = config.matcher.delta_range_filter append = False print "Current delta range filter:", current_filter if current_filter is not None: append = sh.askbool("Do you want to add a new delta range filter to the existing one?") region = None if sh.askbool("Restrict delta range filter to a region?"): region_filename = uiutils.open_file() try: region = imgutils.Region(region_filename) except: print "Warning: opening region file failed" if region is not None: print "Delta range filter for region:", region.get_name() str2vector = lambda s: [float(k) for k in re.findall("[-0-9.]+", s)] check_vector = lambda s: len(str2vector(s)) == 2 unit = u.Unit(sh.ask("Velocity unit:")) direction = str2vector(sh.ask("Direction vector (default=[1,0]):", check_fct=check_vector, default="1,0")) vx = str2vector(sh.ask("Velocity range in X direction:", check_fct=check_vector)) vy = str2vector(sh.ask("Velocity range in Y direction:", check_fct=check_vector)) range_filter = wise.DeltaRangeFilter(vxrange=vx, vyrange=vy, unit=unit, pix_limit=4, x_dir=direction) if region is not None: range_filter = wise.DeltaRegionFilter(wise.RegionFilter(region), range_filter) if append: range_filter = current_filter & range_filter print "Setting delta_range_filter to:", range_filter config.matcher.delta_range_filter = range_filter
def main(): sh.init(libwise.get_version(), USAGE) args = sh.get_args(min_nargs=1) config = actions.get_config(True) ctx = wise.AnalysisContext(config) actions.select_files(ctx, args) if len(ctx.files) == 0: sys.exit(0) wise.tasks.detection_all(ctx) str2vector = lambda s: [float(k) for k in re.findall("[-0-9.]+", s)] check = lambda s: len( wise.tasks._get_scales(str2vector(s), ctx.result.get_scales())) > 0 txt = "View scales (available: %s) (press enter to leave):" % ctx.result.get_scales( ) while True: scales = sh.ask(txt, check_fct=check, default=[]) if len(scales) == 0: break wise.tasks.view_wds(ctx, scales=str2vector(scales)) save = sh.askbool("Save the result ?") if save: name = str(sh.ask("Name (default=result):", default='result')) wise.tasks.save(ctx, name)
def main(): sh.init(libwise.get_version(), USAGE) args = sh.get_args(min_nargs=1) config = actions.get_config(True) ctx = wise.AnalysisContext(config) actions.select_files(ctx, args) if len(ctx.files) == 0: sys.exit(0) wise.tasks.detection_all(ctx) str2vector = lambda s: [float(k) for k in re.findall("[-0-9.]+", s)] check = lambda s: len(wise.tasks._get_scales(str2vector(s), ctx.result.get_scales())) > 0 txt ="View scales (available: %s) (press enter to leave):" % ctx.result.get_scales() while True: scales = sh.ask(txt, check_fct=check, default=[]) if len(scales) == 0: break wise.tasks.view_wds(ctx, scales=str2vector(scales)) save = sh.askbool("Save the result ?") if save: name = str(sh.ask("Name (default=result):", default='result')) wise.tasks.save(ctx, name)
def main(): sh.init(libwise.get_version(), USAGE) args = sh.get_args(min_nargs=1) config = actions.get_config(True) ctx = wise.AnalysisContext(config) actions.select_files(ctx, args) if len(ctx.files) == 0: sys.exit(0) wise.tasks.match_all(ctx) check = lambda s: nputils.is_str_number(s) and float( s) in ctx.result.get_scales() txt = "View scales (available: %s) (press enter to leave):" % ctx.result.get_scales( ) while True: scale = float(sh.ask(txt, check_fct=check, default=0)) if scale == 0: break wise.tasks.view_displacements(ctx, scale) save = sh.askbool("Save the result ?") if save: name = str(sh.ask("Name (default=result):", default='result')) wise.tasks.save(ctx, name)
def main(): sh.init(libwise.get_version(), USAGE) args = sh.get_args(min_nargs=1) config = actions.get_config(True) ctx = wise.AnalysisContext(config) actions.select_files(ctx, args) if len(ctx.files) == 0: sys.exit(0) wise.tasks.match_all(ctx) check = lambda s: nputils.is_str_number(s) and float(s) in ctx.result.get_scales() txt ="View scales (available: %s) (press enter to leave):" % ctx.result.get_scales() while True: scale = float(sh.ask(txt, check_fct=check, default=0)) if scale == 0: break wise.tasks.view_displacements(ctx, scale) save = sh.askbool("Save the result ?") if save: name = str(sh.ask("Name (default=result):", default='result')) wise.tasks.save(ctx, name)
def delta_range_filter_handler(config): current_filter = config.matcher.delta_range_filter append = False print "Current delta range filter:", current_filter if current_filter is not None: append = sh.askbool( "Do you want to add a new delta range filter to the existing one?") region = None if sh.askbool("Restrict delta range filter to a region?"): region_filename = uiutils.open_file() try: region = imgutils.Region(region_filename) except: print "Warning: opening region file failed" if region is not None: print "Delta range filter for region:", region.get_name() str2vector = lambda s: [float(k) for k in re.findall("[-0-9.]+", s)] check_vector = lambda s: len(str2vector(s)) == 2 unit = u.Unit(sh.ask("Velocity unit:")) direction = str2vector( sh.ask("Direction vector (default=[1,0]):", check_fct=check_vector, default="1,0")) vx = str2vector( sh.ask("Velocity range in X direction:", check_fct=check_vector)) vy = str2vector( sh.ask("Velocity range in Y direction:", check_fct=check_vector)) range_filter = wise.DeltaRangeFilter(vxrange=vx, vyrange=vy, unit=unit, pix_limit=4, x_dir=direction) if region is not None: range_filter = wise.DeltaRegionFilter(wise.RegionFilter(region), range_filter) if append: range_filter = current_filter & range_filter print "Setting delta_range_filter to:", range_filter config.matcher.delta_range_filter = range_filter