Configuration
All segmentation and morphology knobs live in a single dataclass,
SegConfig. Construct it directly or via the signal-aware factory:
from SegSpy import SegConfig
config = SegConfig.from_signal(signal, min_area=200, threshold_method="otsu")
Auto-detecting TEM/SEM
from_signal inspects HyperSpy metadata: if an Acquisition_instrument.SEM
block is present the microscope type is set to SEM, otherwise TEM (the
default). This selects sensible preprocessing defaults; override
microscope_type explicitly if your metadata is absent or non-standard.
Key tuning fields
Field |
Default |
Purpose |
|---|---|---|
|
|
Drop particles whose contour area (px) is below this |
|
|
|
|
|
CLAHE contrast strength / tile grid |
|
|
Black-hat morphological kernel size (px) |
|
|
Pre-segmentation noise filter |
|
|
Refine masks with GrabCut (traditional backend) |
SAM-only fields
When backend = "sam", these control the Auto-Mask Generator and post-filter:
Field |
Default |
Purpose |
|---|---|---|
|
|
SAM model variant |
|
|
Path to the SAM checkpoint |
|
|
Device ( |
|
|
Grid density of prompt points |
|
|
Minimum predicted mask quality |
|
|
Mask stability threshold |
|
|
Drop masks outside this fraction of the image |
|
|
Foreground-intensity consistency gate |
|
|
Drop masks touching the image border (px) |
For the full field list, see the API reference.