Align2D#
- class quantem.widget.Align2D(**kwargs: Any)[source]#
Bases:
AnyWidgetInteractive alignment of two 2D images.
- Parameters:
image_a (array_like) – First 2D image (reference, stays fixed).
image_b (array_like) – Second 2D image (draggable).
title (str, optional) – Title displayed above the viewer.
label_a (str, default "Image A") – Label for the first image.
label_b (str, default "Image B") – Label for the second image.
cmap (str, default "gray") – Colormap name.
opacity (float, default 0.5) – Blend ratio (0 = only A, 1 = only B).
padding (float, default 0.2) – Fractional padding on each side. Adjustable from the frontend.
pixel_size (float, default 0.0) – Pixel size in Å for scale bar (0 = uncalibrated).
canvas_size (int, default 300) – Initial canvas size in CSS pixels for each column.
auto_align (bool, default True) – Automatically compute initial alignment via cross-correlation.
max_shift (float, default 0.0) – Maximum allowed shift in pixels (0 = unlimited, constrained by padding).
rotation (float, default 0.0) – Initial rotation angle of image B in degrees.
hist_source (str, default "a") – Which image to show in the histogram (“a” or “b”).
Examples
>>> import numpy as np >>> from quantem.widget import Align2D >>> a = np.random.rand(64, 64).astype(np.float32) >>> b = np.random.rand(64, 64).astype(np.float32) >>> Align2D(a, b, title="Alignment")
Key Methods
- Align2D.set_images(image_a, image_b, auto_align=True)[source]#
Replace both images. Preserves display settings, recomputes alignment.
State Persistence