Powered by Meta SAM2

DIC Mask Generator

Professional Mask Generation for DIC & ROI Analysis

Transform Meta's Segment Anything Model 2 into a powerful desktop tool. From annotation to segmentation to post-processing — complete workflow with zero code.

DIC Mask Generator
Scroll to explore

Core Features

Everything you need for professional mask generation, built into a single desktop application.

Interactive Annotation

Point-based foreground/background marking with full undo/redo history. Toggle modes with a single keystroke.

Mid-Sequence Correction

Fix inaccurate masks on any frame and auto-propagate changes forward. No need to reprocess the entire sequence.

28-Parameter Preprocessing

Tone adjustment, smoothing, binarization, morphology, and anisotropic diffusion — with 7 built-in presets including DIC Microscopy.

Smart Post-Processing

Perona-Malik spatial smoothing and 3D Gaussian temporal smoothing with smart chaining and live mask comparison.

GPU Accelerated

CUDA auto-detection for NVIDIA GPUs delivers ~100x speedup over CPU processing. Real-time VRAM monitoring in status bar.

Project & Export

Save complete workspaces as .s2proj files. Batch processing support. Export masks as TIFF/PNG and contours as PNG/SVG.

See It In Action

Watch the complete workflow — from interactive annotation to SAM2 mask propagation across all frames.

Full Application Demo

How It Works

Five simple steps from raw images to publication-ready masks.

1

Setup

Select input image folder and output directory

2

Annotate

Place foreground & background points on the first frame

3

Process

SAM2 propagates masks across all frames automatically

4

Review

Browse results and fix masks on any frame if needed

5

Export

Apply post-processing and export final masks

Get Started

Up and running in under 5 minutes.

1

Install PyTorch with CUDA

Check your NVIDIA driver version with nvidia-smi, then install the matching PyTorch:

bash
# CUDA 12.8 (driver >= 570)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128

# CPU only (no GPU)
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
2

Install Dependencies

bash
git clone https://github.com/zachtong/DIC-ROI-mask-generator.git
cd DIC-ROI-mask-generator
pip install -r requirements.txt
3

Download SAM2 Checkpoints

Download model weights from facebookresearch/sam2 and place in checkpoints/:

directory
checkpoints/
├── sam2.1_hiera_large.pt      # Best quality (~900 MB)
├── sam2.1_hiera_base_plus.pt  # Balanced
├── sam2.1_hiera_small.pt      # Faster
└── sam2.1_hiera_tiny.pt       # Fastest (~150 MB)

You only need one checkpoint to get started. hiera_large for best quality, hiera_tiny for quick tests.

4

Launch

bash
python main.py

Citation

If you use DIC Mask Generator in your research, please cite our paper.

View Paper on Research Square
BibTeX
@article{leu2026machine,
  title     = {Machine Learning-Aided Spatial Adaptation for Improved
               Digital Image Correlation Analysis of Complex Geometries},
  author    = {Leu, Jeffrey and Tong, Zixiang and Doty, Andrew and
               Tsimpoukis, Solon and Deng, Bolei and Yang, Jin},
  journal   = {Strain},
  volume    = {62},
  number    = {1},
  pages     = {e70022},
  year      = {2026},
  publisher = {Wiley Online Library}
}