Core Principles of Cos Comparison

This project implements a novel feature extraction paradigm based on the fundamental idea that information arises from local differences in raw data. The design is inspired by the centre‑surround antagonism of biological vision and requires no training, no labels, and no backpropagation.

The core principles are:

1. Information is generated by local comparison
      Any meaningful structure (edges, textures, patterns) emerges by comparing neighbouring regions in the data. Global statistics are never used – only local differences matter.
2. Centre‑surround antagonism as the basic operator
      Two sliding windows are compared: a centre window and a surround window with a fixed displacement vector d. This directly mimics the receptive field organisation of retinal ganglion cells.
3. Three complementary similarity measures
   · _cos – angular similarity (direction‑sensitive, shape/texture).
   · _mod – magnitude similarity (intensity/contrast).
   · _cosmod – combined measure (direction + magnitude, recommended).
   The formulas are:
   · cos = (A·B) / (‖A‖·‖B‖)
   · mod = 2·‖A‖·‖B‖ / (‖A‖² + ‖B‖²)
   · cosmod = 2·(A·B) / (‖A‖² + ‖B‖²)
   cosmod is numerically efficient (no square root) and balances directional and contrast sensitivity.
4. Dual operational modes
   · Passive mode – compares two windows at fixed relative offset; detects edges, boundaries, and local discontinuities without any learning.
   · Active mode – compares a sliding window with a fixed kernel (template); analogous to a learnable filter for active pattern matching.
5. Multi‑scale and multi‑directionality
      By varying the window size, the operator naturally extracts features at different semantic levels (pixel‑level details → object‑level contours).
      Changing the displacement vector d selects different edge orientations (vertical, horizontal, diagonal), exactly reproducing the direction‑selective properties of simple cells in the primary visual cortex.
6. Dimension‑agnostic design
      The same algorithm works on 1D (time series, audio), 2D (images), 3D (volumes, video), or higher‑dimensional tensors without any modification. Only the notion of a local neighbourhood (window) and a displacement vector is needed.
7. Zero training, zero labels
      All outputs are computed deterministically from the raw data. No supervision, no optimisation, and no large datasets are required. The model is ready to use out‑of‑the‑box.
8. Full determinism and interpretability
      Every output value has a clear geometric meaning (similarity between two local patches). The effect of every parameter (window size, displacement, step, similarity measure) is perfectly linear and predictable – no black‑box behaviour.
9. Modular, pluggable architecture
      The framework is backend‑agnostic: pure Python (reference), NumPy (vectorised), and C (high‑performance) backends share the same API. Fallback priorities can be set without changing user code.

These principles together form a biologically plausible, mathematically transparent, and computationally lightweight alternative to deep learning for low‑level feature extraction, unsupervised structure detection, and attention‑guided processing.