◐ Shell
clean mode source ↗

Comparing main...scijava-ops-image/image-equation · scijava/scijava

Commits on May 26, 2026

  1. Implement image.equation op

    This implementation brings back the image.equation Op from ImageJ Ops,
    but using Parsington instead of JavaScript for deterministic evaluation.
    
    - Equation.java — the image.equation Op with a Computer signature
      (String, RandomAccessibleInterval<T>)). Parses the expression once
      into a SyntaxTree, then iterates pixels with a localizing cursor,
      updating position before each evaluation. Any per-pixel runtime error
      yields NaN.
    
    - EquationEvaluator.java — extends Parsington's DefaultTreeEvaluator.
      Exposes p[0..n], x/y/z/t, pi/e, and reflects every public-static
      numeric java.lang.Math method.
    
    - EquationTest.java — 10 tests covering constants, p[i], axis
      shorthands, single- and multi-arg math, pi/e, a 3D image,
      reproducibility, random() distribution, and the NaN-on-bad-expression
      contract.
    
    Adds parsington as a dependency to scijava-ops-image.
    
    Notable design notes:
    - parens(...) returns the single arg unwrapped, or an Object[] for
      multi-arg, so function() can pick Math overloads.
    - brackets(...) returns a marker BracketIndex so function(fn, args)
      can distinguish p[i] from cos(x).
    - Multi-arg function args came through as unresolved Variable tokens;
      resolved via Parsington's value(arg) before reflection.
    - Single-threaded for now — Parsington's evaluator is stateful, and the
      op is documented as a demo helper, so top performance is not critical.
    
    Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>

    and claude committed

    May 26, 2026
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history