Show2D#
- class quantem.widget.Show2D(**kwargs: Any)[source]#
Bases:
AnyWidgetStatic 2D image viewer with optional FFT and histogram analysis.
Display a single image or multiple images in a gallery layout. For interactive stack viewing with playback, use Show3D instead.
- Parameters:
data (array_like) – 2D array (height, width) for single image, or 3D array (N, height, width) for multiple images displayed as gallery.
labels (list of str, optional) – Labels for each image in gallery mode.
title (str, optional) – Title to display above the image(s).
cmap (str, default "inferno") – Colormap name (“magma”, “viridis”, “gray”, “inferno”, “plasma”).
pixel_size (float, optional) – Pixel size in angstroms for scale bar display.
show_fft (bool, default False) – Show FFT and histogram panels.
show_stats (bool, default True) – Show statistics (mean, min, max, std).
log_scale (bool, default False) – Use log scale for intensity mapping.
auto_contrast (bool, default False) – Use percentile-based contrast.
ncols (int, default 3) – Number of columns in gallery mode.
disabled_tools (list of str, optional) – Tool groups to lock while still showing controls. Supported:
"display","histogram","stats","navigation","view","export","roi","profile","all".disable_* (bool, optional) – Convenience flags (
disable_display,disable_histogram,disable_stats,disable_navigation,disable_view,disable_export,disable_roi,disable_profile,disable_all) equivalent to adding those keys todisabled_tools.hidden_tools (list of str, optional) – Tool groups to hide from the UI. Uses the same keys as
disabled_tools.hide_* (bool, optional) – Convenience flags mirroring
disable_*forhidden_tools.
Examples
>>> import numpy as np >>> from quantem.widget import Show2D >>> >>> # Single image with FFT >>> Show2D(image, title="HRTEM Image", show_fft=True, pixel_size=1.0) >>> >>> # Gallery of multiple images >>> labels = ["Raw", "Filtered", "FFT"] >>> Show2D([img1, img2, img3], labels=labels, ncols=3)
Key Methods
- Show2D.set_image(data, labels=None)[source]#
Replace the displayed image(s). Preserves all display settings.
- Show2D.save_image(path: str | Path, *, idx: int | None = None, format: str | None = None, dpi: int = 150) Path[source]#
Save current image as PNG or PDF.
- Parameters:
path (str or pathlib.Path) – Output file path.
idx (int, optional) – Image index in gallery mode. Defaults to current selected_idx.
format (str, optional) – ‘png’ or ‘pdf’. If omitted, inferred from file extension.
dpi (int, default 150) – Output DPI metadata.
- Returns:
The written file path.
- Return type:
Line Profile
- Show2D.set_profile(start: tuple, end: tuple)[source]#
Set a line profile between two points (image pixel coordinates).
ROI
State Persistence