radioviz.geometry.mask

Module for creating masks from matplotlib selectors.

This module provides functionality to generate 2D masks starting from a geometry description.

Functions

axes_pixel_grid(shape)

Generate X, Y arrays of pixel centers in data coordinates.

ellipse_mask(geometry, image_shape)

Create a boolean mask for an elliptical selection.

geometry_to_mask(region_type, geometry, ...)

Convert geometry to a boolean mask based on region type.

polygon_mask(geometry, image_shape)

Create a boolean mask for a polygonal selection.

rectangle_mask(geometry, image_shape)

Create a boolean mask for a rectangular selection.

radioviz.geometry.mask.axes_pixel_grid(shape: tuple[int, int]) tuple[ndarray[tuple[Any, ...], dtype[Any]], ndarray[tuple[Any, ...], dtype[Any]]][source]

Generate X, Y arrays of pixel centers in data coordinates.

Creates coordinate grids for pixel centers based on the given image shape. These coordinates are useful for generating masks that correspond to specific regions of interest.

Parameters:

shape (tuple[int, int]) – The shape of the image as (height, width)

Returns:

Tuple of X and Y coordinate arrays

Return type:

tuple[numpy.ndarray, numpy.ndarray]

radioviz.geometry.mask.ellipse_mask(geometry: dict[str, Any], image_shape: tuple[int, int]) ndarray[tuple[Any, ...], dtype[bool]][source]

Create a boolean mask for an elliptical selection.

Generates a boolean mask representing the area defined by a rotated ellipse.

Parameters:
  • geometry (dict[str, Any]) – Dictionary containing ellipse extents and rotation angle

  • image_shape (tuple[int, int]) – The shape of the image as (height, width)

Returns:

Boolean mask where True represents pixels within the ellipse

Return type:

numpy.ndarray

radioviz.geometry.mask.geometry_to_mask(region_type: ROIType, geometry: dict[str, Any], image_shape: tuple[int, int]) ndarray[tuple[Any, ...], dtype[bool]][source]

Convert geometry to a boolean mask based on region type.

Maps a region type to its corresponding mask generation function and returns the mask for the given geometry.

Parameters:
  • region_type (ROIType) – The type of region (e.g., RECTANGLE, ELLIPSE)

  • geometry (dict[str, Any]) – Dictionary containing geometry data

  • image_shape (tuple[int, int]) – The shape of the image as (height, width)

Returns:

Boolean mask for the specified region type

Return type:

numpy.ndarray

radioviz.geometry.mask.polygon_mask(geometry: dict[str, Any], image_shape: tuple[int, int]) ndarray[tuple[Any, ...], dtype[bool]][source]

Create a boolean mask for a polygonal selection.

Generates a boolean mask representing the area defined by a polygon.

Parameters:
  • geometry (dict[str, Any]) – Dictionary containing polygon vertices

  • image_shape (tuple[int, int]) – The shape of the image as (height, width)

Returns:

Boolean mask where True represents pixels within the polygon

Return type:

numpy.ndarray

radioviz.geometry.mask.rectangle_mask(geometry: dict[str, Any], image_shape: tuple[int, int]) ndarray[tuple[Any, ...], dtype[bool]][source]

Create a boolean mask for a rectangular selection.

Generates a boolean mask representing the area defined by a rotated rectangle.

Parameters:
  • geometry (dict[str, Any]) – Dictionary containing rectangle extents and rotation angle

  • image_shape (tuple[int, int]) – The shape of the image as (height, width)

Returns:

Boolean mask where True represents pixels within the rectangle

Return type:

numpy.ndarray