SlidingRadial
- class xaitk_saliency.impls.perturb_image.sliding_radial.SlidingRadial(radius: tuple[float, float] = (50, 50), stride: tuple[int, int] = (20, 20), sigma: tuple[float, float] | None = None)
Produce perturbation matrices generated by sliding a radial occlusion area with configured radius over the area of an image. When the two radius values are the same, circular masks are generated; otherwise, elliptical masks are generated. Passing sigma values will apply a Gaussian filter to the mask, blurring it. This results in a smooth transition from full occlusion in the center of the radial to no occlusion at the edge.
Due to the geometry of sliding radials, if the stride given does not evenly divide the radial size along the applicable axis, then the result plane of values when summing the generated masks will not be even.
Related, if the stride is set to be larger than the radial diameter, the resulting plane of summed values will also not be even, as there be increasingly long valleys of unperturbed space between masked regions.
The generated masks are boolean if no blurring is used, otherwise the masks will be of floating-point type in the [0, 1] range.
Methods
from_config
Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
Get the configuration dictionary of the SlidingRadial instance.
Returns the default configuration for the SlidingRadial.
get_impls
Discover and return a set of classes that implement the calling class.
is_usable
Check whether this class is available for use.
Produce a mask based on a radial occlusion area with configured radius over the area of an image
- __init__(radius: tuple[float, float] = (50, 50), stride: tuple[int, int] = (20, 20), sigma: tuple[float, float] | None = None) None
Produce perturbation matrices generated by sliding a radial occlusion area with configured radius over the area of an image.
- Parameters:
radius – The radius of the occlusion area in pixels as a tuple with format (radius_y, radius_x).
stride – The striding step in pixels for the center of the radial as a tuple with format (height_step, width_step).
sigma – The sigma values for the Gaussian filter applied to masks in pixels as a tuple with format (sigma_y, sigma_x).
- get_config() dict[str, Any]
Get the configuration dictionary of the SlidingRadial instance.
- Returns:
dict[str, Any]: Configuration dictionary.
- classmethod get_default_config() dict[str, Any]
Returns the default configuration for the SlidingRadial.
This method provides a default configuration dictionary, specifying default values for key parameters in the factory. It can be used to create an instance of the factory with preset configurations.
- Returns:
dict[str, Any]: A dictionary containing default configuration parameters.
- perturb(ref_image: ndarray) ndarray
Produce a mask based on a radial occlusion area with configured radius over the area of an image
- Parameters:
ref_image – Reference image to generate perturbations from.
- Returns:
Mask matrix with shape [nMasks x Height x Width].