Illustration generated with AI; not experimental data.¶
Feature Extraction¶
A “feature map” is a new image, the same size as the original, where each
pixel’s value describes something about that spot — like how sharp an
edge is there, or how much texture surrounds it — instead of its raw
brightness. Feature extraction is a built-in capability of
SPICEData, reached through its features property.
spice.features.extract() computes several such feature maps from
spice.data — Gaussian, Sobel, Gabor, entropy, Local Binary Pattern
(LBP), and more — and returns them as a new SPICEData,
sharing the same history as the object you called it on.
spice.features¶
No separate function call with an explicit spice argument is needed —
spice.features is accessed directly on any loaded
SPICEData:
from juspice.io import load_data
spice = load_data('image.tif')
feature_spice = spice.features.extract()
Unlike juspice.preprocess_module.PreprocessingAccessor, which
mutates spice.data in place and returns spice itself,
extract() returns
a derived object — the feature stack has a different shape than the
source image — so the original spice is left untouched:
feature_spice = spice.features.extract(feature_names='sobel_magnitude')
feature_spice is spice # False — a new SPICEData
feature_spice.history is spice.history # True — shared lineage
The call is recorded automatically into spice.history using the actual
runtime argument values — no manual tracking calls are needed.
Methods
extract()— compute a feature-map stack and return it as a newSPICEData. Acceptsfeature_names=None(all features), a single feature name, or a list of names.maps()— read-only: return all feature maps as adict(not recorded into history).stack()— read-only: return the full feature-map stack as an(H, W, N)array.dict()— read-only: scalar summaries (mean of each feature map).vector()— read-only: scalar summary vector in canonicalFEATURE_MAP_NAMESorder.
Available feature channels
Gaussian smoothed at multiple scales,
Sobel, Scharr, and Laplace edge/gradient response,
Hessian, Frangi, Meijering, and Sato ridge/vesselness response,
Gabor filter bank responses,
Local Binary Patterns (LBP),
Canny edges,
Shannon entropy (sliding window),
Structure-tensor coherence.
See FEATURE_MAP_NAMES for the full,
ordered list of 16 feature names.
Saving feature results¶
Use save_feature_results() to write the
feature array and its provenance:
from juspice.feature_extract import save_feature_results
save_feature_results(feature_spice)
This calls save_data() internally and writes
<stem>.npy, <stem>.json, and <stem>_history.py to the
auto-detected output location.
Reproducibility¶
Operations applied through spice.features are recorded into
DatasetHistory as features.extract entries,
using the actual runtime argument values. They appear in the <stem>.json
sidecar and reconstruct as
feature_spice = spice.features.extract(...) in
to_lines() and
to_script().
When used inside a Tracker recording block, every
call is additionally captured verbatim in the session-level _history.py.
See also
juspice.feature_extract — full API reference
Feature Extraction — domain background