superdsm.automation

superdsm.automation.create_config(pipeline, base_cfg, img)

Automatically configures hyperparameters based on the scale of objects in an image.

The scale of the objects is estimated automatically as described in Section 3.1 of Kostrykin and Rohr (TPAMI 2023). The current implementation determines values corresponding to object radii between 20 and 200 pixels. If, however, the hyperparameter AF_scale is set, then the scale \(\sigma\) is forced to its value and the automatic scale detection is not used. The hyperparameter AF_scale is not set by default.

>>> import superdsm, superdsm.automation, superdsm.config
>>> base_cfg = superdsm.config.Config(dict(AF_scale=40))
>>> pipeline = superdsm.pipeline.create_default_pipeline()
>>> cfg, _ = superdsm.automation.create_config(pipeline, base_cfg, None)
>>> print(cfg)
{
  "AF_scale": 40,
  "preprocess": {
    "AF_sigma2": 1.0,
    "sigma2": 40.0
  },
  "dsm": {
    "AF_alpha": 0.0005,
    "alpha": 0.8,
    "AF_smooth_amount": 0.2,
    "smooth_amount": 8,
    "AF_smooth_subsample": 0.4,
    "smooth_subsample": 16,
    "AF_background_margin": 0.4,
    "background_margin": 16
  },
  "c2f-region-analysis": {
    "AF_min_atom_radius": 0.33,
    "min_atom_radius": 18
  },
  "global-energy-minimization": {
    "AF_beta": 0.66,
    "beta": 1056.0,
    "AF_max_seed_distance": Infinity,
    "max_seed_distance": Infinity
  },
  "postprocess": {
    "AF_min_object_radius": 0.0,
    "min_object_radius": 0.0,
    "AF_max_object_radius": Infinity,
    "max_object_radius": Infinity,
    "AF_min_glare_radius": Infinity,
    "min_glare_radius": Infinity
  }
}
superdsm.automation.process_image(pipeline, base_cfg, g_raw, **kwargs)

Performs the segmentation of an image using hyperparameters automatically configured based on the scale of objects.

See the create_config() function and the process_image() pipeline method for details.

Parameters:
  • pipeline – The Pipeline object to be used for image segmentation.

  • base_cfgConfig object corresponding to custom hyperparameters.

  • g_raw – A numpy.ndarray object corresponding to the image which is to be processed.

  • kwargs – Additional keyword arguments passed to the process_image() pipeline method.

Returns:

The same tuple that is returned by the process_image() pipeline method.