Visualization
Diagnostic plotting for synthetic image optimization.
Generates side-by-side comparisons of real and synthetic microscope images with intensity histograms and region-specific quality metrics (SSIM, PSNR, histogram distance).
- extract_masked_region(image: ndarray, mask: ndarray, region: str) ndarray
Extract foreground or background region from image using mask.
- Parameters:
image (np.ndarray) – Input image (float [0,1]).
mask (np.ndarray) – Segmentation mask (2D or 3D).
region (str) – Region to extract: ‘foreground’ or ‘background’.
- Returns:
Image with the non-selected region zeroed out.
- Return type:
np.ndarray
- generate_detailed_plots(image_pairs: List[Tuple[Path, Path]], params: Dict, per_image_metrics: List[Dict], output_dir: Path, n_vertices: int) None
Generate detailed per-image plots with region-specific analysis.
Creates one plot per image pair showing full, background, and foreground histogram comparisons along with image and mask visualizations.
- Parameters:
image_pairs (List[Tuple[Path, Path]]) – List of (image_path, mask_path) tuples.
params (Dict) – Optimized synthetic parameters (bg_base_brightness, etc.).
per_image_metrics (List[Dict]) – Per-image metrics from compute_final_metrics().
output_dir (Path) – Output directory for saving plots.
n_vertices (int) – Number of vertices for cell shape extraction.
- generate_comparison_plot(image_pairs: List[Tuple[Path, Path]], params: Dict, output_dir: Path, n_vertices: int, num_examples: int = 3)
Generate comparison plot showing original vs synthetic for example images.
Creates a single figure with histogram comparisons and side-by-side image views for a sample of image pairs.
- Parameters:
image_pairs (List[Tuple[Path, Path]]) – List of (image_path, mask_path) tuples.
params (Dict) – Optimized synthetic parameters (bg_base_brightness, etc.).
output_dir (Path) – Output directory for saving the plot.
n_vertices (int) – Number of vertices for cell shape extraction.
num_examples (int) – Number of example images to show.