twocan.plot_cartoon_affine

twocan.plot_cartoon_affine(w1: float, h1: float, M: ndarray, w2: float, h2: float, ax: Axes | None = None, show_source: bool = False, source_color: str = 'green', target_color: str = 'purple') Tuple[Axes, List[Line2D]][source]

Plot a cartoon representation of an affine transformation.

Visualizes how a rectangle is transformed by an affine matrix, useful for understanding registration transformations.

Parameters:
  • w1 (float) – Width and height of source rectangle.

  • h1 (float) – Width and height of source rectangle.

  • M (np.ndarray) – 2x3 affine transformation matrix.

  • w2 (float) – Width and height of target rectangle.

  • h2 (float) – Width and height of target rectangle.

  • ax (Optional[Axes], default=None) – Matplotlib axes for plotting. If None, current axes will be used.

  • show_source (bool, default=False) – Whether to show the original source rectangle.

  • source_color (str, default='green') – Color for source rectangle and its transformation.

  • target_color (str, default='purple') – Color for target rectangle.

Returns:

The matplotlib axes object and list of plotted lines.

Return type:

Tuple[Axes, List[Line2D]]