API reference
Convenience interface
SourceExtraction.find_sources — Function
find_sources(A; kwargs...) -> xs, ysDetect sources in a single 2-D image and return their x and y coordinates.
This is the simple one-shot API. For repeated processing of many images, use SourceExtractor and extract_sources! to reuse prepared buffers.
Example
xs, ys = find_sources(image)SourceExtraction.find_sources! — Function
find_sources!(extractor, A) -> xs, ysRun a prepared SourceExtractor and return x/y coordinates.
This method reuses the extractor's prepared buffers.
Prepared pipeline
SourceExtraction.SourceExtractor — Type
SourceExtractorPrepared high-level source-extraction pipeline.
A SourceExtractor owns all reusable state required for:
- DoG filtering
- local-maximum source detection
- optional ROI extraction
The extractor is prepared for the size and backend of the array used to construct it. Repeated calls to extract_sources! reuse the same buffers.
If roi_size === nothing, no ROI storage is allocated and only source indices and scores are produced.
SourceExtraction.SourceExtractionResult — Type
SourceExtractionResultResult returned by extract_sources!.
The result references storage owned by its SourceExtractor. A subsequent call to extract_sources! using the same extractor may overwrite the data.
Use copy(source_indices(result)), copy(source_scores(result)), or copy(source_rois(result)) if the data must persist independently.
SourceExtraction.extract_sources! — Function
extract_sources!(extractor, A)Run the complete prepared source-extraction pipeline.
The operation consists of:
- DoG filtering
- local-maximum detection
- optional ROI extraction from the original input array
The returned SourceExtractionResult references the extractor's reusable buffers and is overwritten by subsequent calls using the same extractor.
For CUDA arrays, obtaining the source count requires a small device-to-host synchronization before ROI extraction.
SourceExtraction.source_count — Function
source_count(result)Return the number of detected sources.
SourceExtraction.source_indices — Function
source_indices(result)Return a view containing the valid detected source indices.
SourceExtraction.source_scores — Function
source_scores(result)Return a view containing the valid source scores.
SourceExtraction.source_rois — Function
source_rois(result)Return a view containing the valid extracted ROIs.
Returns nothing if the SourceExtractor was constructed without roi_size.
Detection
SourceExtraction.LocalMaximaDetector — Type
LocalMaximaDetector(threshold; radius=1, strict=true)Detector for identifying local maxima above threshold.
A candidate pixel must be greater than all pixels inside a (2radius + 1) × (2radius + 1) neighborhood when strict=true.
The detection radius is encoded in the detector type so that small fixed neighborhoods can be specialized by the compiler.
SourceExtraction.DetectionWorkspace — Type
DetectionWorkspacePreallocated storage for detected source positions, scores, and count.
The underlying storage may reside on the CPU or another backend such as CUDA.
SourceExtraction.detect_sources! — Function
detect_sources!(
indices,
scores,
A,
detector;
border=radius(detector),
)Detect local maxima in the 2-D array A.
Detected source positions are written into the preallocated indices array and their corresponding image values into scores.
Returns the number of detected sources.
No allocations are required when the supplied output buffers have sufficient capacity.
detect_sources!(indices, scores, A::AbstractArray{T,3}, detector)Detect sources independently in every frame of an x × y × frame array.
Local-maxima comparisons are performed only within each frame.
Difference-of-Gaussians filtering
SourceExtraction.DoG — Type
DoG(sigma1, sigma2)Difference-of-Gaussians filter specification.
sigma1 is the width of the narrower Gaussian and sigma2 the width of the broader Gaussian.
SourceExtraction.prepare_dog — Function
prepare_dog(array_type, size, dog)Prepare the separable Gaussian components of a Difference-of-Gaussians filter for a given array type and size.
This operation may allocate. The returned object is intended to be reused.
SourceExtraction.dog_kernel! — Function
dog_kernel!(dst, prepared)Materialize a prepared Difference-of-Gaussians kernel into dst.
SourceExtraction.prepare_filter — Function
prepare_filter(A, dog)Prepare an FFT-based Difference-of-Gaussians filter for arrays with the same size and type as A.
All FFT plans, Fourier-domain kernel data, and working buffers are allocated during this step and reused during filtering.
SourceExtraction.filter_sources! — Function
filter_sources!(prepared, A)Apply a prepared source-enhancement filter to A.
The returned array is an internal reusable buffer owned by prepared. Its contents will be overwritten by the next call using the same prepared filter.
filter_sources!(dst, A, prepared)Apply the prepared filter and copy the result into dst.
ROI extraction
SourceExtraction.extract_rois! — Function
extract_rois!(rois, A, indices, n)Extract fixed-size 2-D ROIs centered on the first n source positions.
rois must have dimensions
(roi_x, roi_y, max_sources)and both ROI dimensions must be odd.
Returns n.
extract_rois!(rois, A, workspace::DetectionWorkspace, n)Extract ROIs using source indices stored in a detection workspace.
Index
SourceExtraction.DetectionWorkspaceSourceExtraction.DoGSourceExtraction.LocalMaximaDetectorSourceExtraction.SourceExtractionResultSourceExtraction.SourceExtractorSourceExtraction.detect_sources!SourceExtraction.dog_kernel!SourceExtraction.extract_rois!SourceExtraction.extract_sources!SourceExtraction.filter_sources!SourceExtraction.find_sourcesSourceExtraction.find_sources!SourceExtraction.prepare_dogSourceExtraction.prepare_filterSourceExtraction.source_countSourceExtraction.source_indicesSourceExtraction.source_roisSourceExtraction.source_scores