Classical segmentation¶
SoFTg.segment_solar_granules accepts a two-dimensional intensity image and its plate scale in km per pixel. It returns three integer arrays with the input shape.
from WaLSAlib import SoFTg
labels, seeds, skeleton = SoFTg.segment_solar_granules(
continuum_image,
plate_scale=plate_scale_km_per_pixel,
k=0.165,
lane_width_km=150,
reconnect_ratio=4.0,
lane_intensity_fraction=0.4,
)
Here, continuum_image is the prepared intensity image and plate_scale_km_per_pixel is its spatial sampling.
Processing stages¶
The function removes small bright points, calculates a local dynamic threshold, cleans and reconnects a lane mask, prunes detections, extracts and prunes a lane skeleton, places distance-transform seeds, and applies watershed segmentation.
Prepare the input image before segmentation. The prediction workflow includes additional contrast-enhancement options.
Parameters¶
| Argument | Default | Meaning |
|---|---|---|
sample_img |
Required | Finite, two-dimensional intensity array |
plate_scale |
Required | Positive spatial scale in km/pixel |
k |
0.165 |
Local threshold control |
lane_width_km |
150 |
Expected lane width used in morphology |
reconnect_ratio |
4.0 |
Morphological reconnection control |
lane_intensity_fraction |
0.4 |
Intensity fraction used in the watershed stage |
Start with the defaults and inspect results on representative images before tuning. Convert angular plate scales to km/pixel using the observing geometry.
Return values¶
labels: integer watershed granule labels; zero is background.seeds: labelled starting regions from which the watershed algorithm grows granules.skeleton: a thin map of lane boundaries, containing zeros and ones.
Labels identify granules within each image. Following granules through a sequence requires a separate association step.
Check the result¶
Plot the intensity alongside labelled boundaries and the lane skeleton. Examine granules at image edges, bright points, low-contrast areas, and complex or splitting structures. Compare against hand-labelled regions or independent measurements at the same resolution. Retain the plate scale and all morphology settings with the output.
The API reference includes the exact source signature and selected lower-level helpers.