MorphologicalAttributeFilters
Public API documentation
Loading...
Searching...
No Matches
Classes | Static Public Member Functions | List of all members
mmcfilters::local_events::EventEngine Class Reference

Generic event engine for finite binary local computations. More...

#include <EventEngine.hpp>

Classes

struct  WindowOffset
 Relative integer offset of one sample in a local image window. More...
 

Static Public Member Functions

static NodeId entryNode (const MorphologicalTree &tree, int anchorPixel, int samplePixel)
 Returns the first ancestor of anchorPixel that contains samplePixel.
 
static NodeId entryNode (const MorphologicalTree &tree, int anchorPixel, WindowOffset offset)
 Returns the entry node for one translated sample around an anchor.
 
template<class Policy >
static std::vector< typename Policy::Bucket > computeDeltasWithPolicy (const MorphologicalTree &tree, const std::vector< WindowOffset > &window, const Policy &policy)
 Computes local state-change deltas before subtree aggregation.
 
template<class Policy >
static std::vector< typename Policy::Bucket > computeWithPolicy (const MorphologicalTree &tree, const std::vector< WindowOffset > &window, const Policy &policy)
 Computes local counters with a caller-owned bucket policy.
 

Detailed Description

Generic event engine for finite binary local computations.

This engine implements only the structural part of local event computation: entry-node evaluation, event ordering, local-state transitions, and bottom-up bucket aggregation. Attribute-specific headers own the meaning and type of their buckets.

The model is based on a finite window sampled around each anchor pixel. For each valid window sample, entryNode(...) returns the first node, walking upward from the anchor owner, whose support also contains that sample. Events are then processed from descendants to ancestors, so the binary state only gains visible samples. The policy receives the initial state and every later transition, and can store either raw state counters or an already projected attribute bucket.

Returned buffers always use the dense internal node-id space of MorphologicalTree; dead slots keep the default value of the policy bucket. This header is public so new local descriptors can reuse the same policy-based event model.

Definition at line 37 of file EventEngine.hpp.

Member Function Documentation

◆ computeDeltasWithPolicy()

template<class Policy >
static std::vector< typename Policy::Bucket > mmcfilters::local_events::EventEngine::computeDeltasWithPolicy ( const MorphologicalTree tree,
const std::vector< WindowOffset > &  window,
const Policy policy 
)
inlinestatic

Computes local state-change deltas before subtree aggregation.

The policy must define:

  • using Bucket = ...;
  • applyInitial(Bucket&, uint32_t state);
  • applyTransition(Bucket&, uint32_t oldState, uint32_t newState);
  • merge(Bucket& parent, const Bucket& child).

state is a bit mask over the samples in window. Bit i is set after the event for window[i] has entered. Because events are sorted bottom-up, transitions are monotone (newState is oldState plus one or more bits at the same node). The policy is responsible for interpreting a state and adding/removing the previous state's contribution.

Returned buckets are the sparse per-node delta representation: aggregating child buckets into parents materializes the final subtree attribute. Attribute implementations can expose this representation when callers need the local-event model itself rather than only final subtree counts.

Template Parameters
PolicyPolicy type defining Bucket, applyInitial, applyTransition, and merge.
Parameters
treeTree whose dense internal node-id space indexes the returned bucket vector.
windowFinite local window. At most 32 samples are supported because the active state is encoded in a uint32_t mask.
policyStateless or externally owned policy object used to update and merge buckets.
Returns
Dense bucket vector sized by tree.getNumInternalNodeSlots().
Exceptions
std::invalid_argumentIf the tree has no image domain, has no live root, or the window contains more than 32 samples.

Definition at line 164 of file EventEngine.hpp.

◆ computeWithPolicy()

template<class Policy >
static std::vector< typename Policy::Bucket > mmcfilters::local_events::EventEngine::computeWithPolicy ( const MorphologicalTree tree,
const std::vector< WindowOffset > &  window,
const Policy policy 
)
inlinestatic

Computes local counters with a caller-owned bucket policy.

This is computeDeltasWithPolicy(...) followed by bottom-up subtree aggregation with the policy's merge operation.

Let P be the number of image pixels, W the window size, N the number of internal node slots, and A the cost of owner/ancestor/LCA entry evaluation. The structural cost is:

O(P * W * A + P * W log W + N + E),

where E is the number of tree edges. Policy transition and merge costs are multiplied into the corresponding event and aggregation terms.

Template Parameters
PolicyPolicy type defining Bucket, applyInitial, applyTransition, and merge.
Parameters
treeTree whose dense internal node-id space indexes the returned bucket vector.
windowFinite local window. At most 32 samples are supported.
policyStateless or externally owned policy object used to update and merge buckets.
Returns
Dense final subtree bucket vector sized by tree.getNumInternalNodeSlots().
Exceptions
std::invalid_argumentIf the tree/window shape is invalid.

Definition at line 243 of file EventEngine.hpp.

◆ entryNode() [1/2]

static NodeId mmcfilters::local_events::EventEngine::entryNode ( const MorphologicalTree tree,
int  anchorPixel,
int  samplePixel 
)
inlinestatic

Returns the first ancestor of anchorPixel that contains samplePixel.

The entry node is the structural point where a binary local sample becomes visible while the anchor support is expanded from a node to its ancestors:

  • if the anchor owner already contains the sample owner, the entry is the anchor owner;
  • if the sample owner is an ancestor of the anchor owner, the entry is the sample owner;
  • otherwise the two owners are incomparable and the event enters at their lowest common ancestor.

Invalid pixels or pixels without an owner return InvalidNode.

Parameters
treeMorphological tree whose proper-part ownership defines the supports being sampled.
anchorPixelRow-major image-domain proper part used as the window anchor.
samplePixelRow-major image-domain proper part being tested.
Returns
Dense internal NodeId where the sample enters, or InvalidNode when either pixel is invalid or unowned.

Definition at line 87 of file EventEngine.hpp.

◆ entryNode() [2/2]

static NodeId mmcfilters::local_events::EventEngine::entryNode ( const MorphologicalTree tree,
int  anchorPixel,
WindowOffset  offset 
)
inlinestatic

Returns the entry node for one translated sample around an anchor.

This overload converts offset to an absolute sample pixel in the image domain and returns InvalidNode when the translated sample falls outside the image. Out-of-domain samples therefore do not generate local events; attribute policies that need border complements account for them through their own framed-window logic.

Parameters
treeMorphological tree whose image domain defines valid samples.
anchorPixelRow-major image-domain proper part used as the window anchor.
offsetRelative window sample offset.
Returns
Dense internal NodeId where the translated sample enters, or InvalidNode if the anchor/sample is outside the image or unowned.

Definition at line 108 of file EventEngine.hpp.


The documentation for this class was generated from the following file: