Displaying scalar images

PyLorentz.visualize.show.show_im(image: numpy.ndarray, title: str | None = None, scale: float | None = None, simple: bool = False, save: str | None = None, cmap: str = 'gray', figax: Tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] | None = None, roi: dict | None = None, cbar_title: str | None = None, cbar: bool | None = None, intensity_range: str = 'minmax', origin: str = 'upper', **kwargs) None[source]

Display an image with optional features like colorbar, title, and scale.

Parameters:
  • image (np.ndarray) – 2D image to be displayed.

  • title (str, optional) – Title of the plot.

  • scale (float, optional) – Scale in nm/pixel for axis markers.

  • simple (bool) – Simplified display without colorbar and labels.

  • save (str, optional) – Path to save the figure.

  • cmap (str) – Colormap for displaying the image.

  • figax (tuple, optional) – Figure and axis to plot on.

  • roi (dict, optional) – Region of interest to highlight.

  • cbar_title (str, optional) – Title for the colorbar.

  • cbar (bool, optional) – Whether to display the colorbar.

  • intensity_range (str) – Method to set intensity range. ‘minmax’ or ‘ordered’.

  • origin (str) – Image origin (‘upper’ or ‘lower’).

  • **kwargs – Additional keyword arguments.

Returns:

None

PyLorentz.visualize.show.show_stack(images: List[numpy.ndarray], titles: List[str] | None = None, scale_each: bool = True, **kwargs) None[source]

Display a stack of images interactively using a slider.

Parameters:
  • images (list) – List of 2D numpy arrays representing the images.

  • titles (list, optional) – List of titles for each image.

  • scale_each (bool) – Scale each image individually or use the same scale.

Returns:

None

PyLorentz.visualize.show.show_sims(phi: numpy.ndarray, im_un: numpy.ndarray, im_in: numpy.ndarray, im_ov: numpy.ndarray, title: str | None = None, save: str | None = None) None[source]

Plot phase, underfocus, infocus, and overfocus images in one plot.

Parameters:
  • phi (np.ndarray) – Image of phase shift.

  • im_un (np.ndarray) – Underfocus image.

  • im_in (np.ndarray) – Infocus image.

  • im_ov (np.ndarray) – Overfocus image.

  • title (str, optional) – Title for the plot.

  • save (str, optional) – Path to save the figure.

Returns:

None

PyLorentz.visualize.show.show_im_peaks(im: numpy.ndarray | None = None, peaks: numpy.ndarray | None = None, peaks2: numpy.ndarray | None = None, title: str | None = None, cbar: bool = False, **kwargs) None[source]

Show image with overlaid peaks.

Parameters:
  • im (np.ndarray, optional) – Image to display.

  • peaks (np.ndarray, optional) – Peaks to overlay on the image.

  • peaks2 (np.ndarray, optional) – Second set of peaks to overlay.

  • title (str, optional) – Title for the plot.

  • cbar (bool) – Whether to display a colorbar.

Returns:

None

PyLorentz.visualize.show.tick_label_formatter(ticks: numpy.ndarray, fov: float, scale: float, scale_units: str = None) Tuple[List[str], str][source]

Format tick labels for display.

Parameters:
  • ticks (np.ndarray) – Tick positions.

  • fov (float) – Field of view.

  • scale (float) – Scale in nm/pixel.

  • scale_units (str, optional) – Units for the scale.

Returns:

Formatted labels and unit.

Return type:

Tuple[List[str], str]

PyLorentz.visualize.show.show_fft(fft: numpy.ndarray, **kwargs) None[source]

Display the FFT of an image with logarithmic scaling.

Parameters:
  • fft (np.ndarray) – FFT of the image.

  • **kwargs – Additional keyword arguments.

Returns:

None

PyLorentz.visualize.show.lineplot_im(image: numpy.ndarray, center: Tuple[int, int] | None = None, phi: float = 0, linewidth: int = 1, line_len: int = -1, show: bool = False, **kwargs) numpy.ndarray[source]

Generate a line plot through an image.

Parameters:
  • image (np.ndarray) – Image to analyze.

  • center (tuple, optional) – Center point for the line plot (cy, cx).

  • phi (float) – Angle for the line plot in degrees.

  • linewidth (int) – Line width for the plot.

  • line_len (int) – Length of the line plot.

  • show (bool) – Whether to display the plot.

  • **kwargs – Additional keyword arguments.

Returns:

Line plot data.

Return type:

np.ndarray