In computational image processing, there exist two domains that, at first glance, could hardly be considered academically distinct: Astrophotography, which accumulates weak photons across cosmic distances, and Extreme Macro Photography, which isolates microscopic depth-of-field layers in the millimeter range.

From a mathematical and algorithmic perspective, however, both face exactly the same problem: How does one reconstruct an undistorted, low-noise, and artifact-free overall representation from an incomplete, optically distorted image stack?

While established stacking programs have treated this challenge for decades as a static, purely pixel-based computation, the MoonEngine, in conjunction with the cognitive subsystem L.U.N.A., takes a different approach: We couple deterministic signal processing with adaptive heuristics—while transparently illuminating the real limitations of the optics.


1. The Reality on the Moon: Seeing vs. Image Fusion

Anyone pointing a high-resolution camera system with extreme focal length (e.g., 800 mm to 1200 mm) at the lunar surface is looking through kilometers of dense, thermally unstable Earth's atmosphere. Convection currents and vertical temperature gradients generate the dreaded seeing: local focusing variations, chromatic dispersion, and wandering wavefronts that deform the image field at tens of Hertz.

1. RAW Single Image (Seeing & Noise) 2. MoonEngine Stacked Image
RAW (Seeing)
MoonEngine Stack

The 3 Stages of Image Fusion: From the turbulent, noisy RAW frame to the calculated stacked image, and finally to the deconvolution-processed, color-differentiated final result.

Where Classic Tools Fail:

The MoonEngine Architecture:


2. Problem Areas in Macro Photography: Focus Breathing, Reflections & Halos

During macro stacking (e.g., on mushrooms, lichens, or crystals), the plane of focus is shifted via fine micrometer steps. This generates typical optical artifacts that often cause standard stackers to fail:

A. Focus Breathing (Dynamic Scale Change)

Every optical lens system minimally changes its effective focal length when the focus is shifted. The subject "breathes": it enlarges or shrinks across the image stack. * The Error: Rigid addition creates double contours and soft edges. * Our Solution: The engine_macro fully compensates for scale drifts using an affine SIFT and a modified ECC (Enhanced Correlation Coefficient) registration in the subpixel domain before fusion begins.

B. Specular Highlights & Reflections

Moist mushroom caps, insect exoskeletons, or mineral edges generate specular highlights. These pixels are often fully saturated on the sensor (255 or 65535). * The Error: Conventional stackers incorrectly classify highlights as unstructured blur and replace them with blurred layers. This results in torn, gray patches. * Our Solution: An adaptive saturation mask semantically freezes the highlights and anchors their brightness value stably in the summed image, rather than applying erroneous contrast powers.

C. Hard Edges & Transparent Halos (Occlusion Boundaries)

The most complex problem in focus stacking: when a sharp foreground object (e.g., a mushroom cap) is positioned in front of a distant background.

Problem Zone: Occlusion Boundary
+------------------------+
| Sharp Foreground | ---> Sharp Contour
+------------------------+
| Diffuse Blur Edge | ---> Here the blurred background optically mixes with the sharp foreground edge!
+------------------------+

If the camera captures the sharp background, the foreground becomes extremely blurred and lays down as a diffuse veil over the edge regions. Conventional stackers cannot mathematically separate this veil—resulting in an unnatural, transparent "ghost halo" around the edge.


3. The Mathematical Pipeline: Numerical Stability over Overflow

Many experimental stackers fail due to numerical overflow when attempting to sharply separate edges. If a Laplace weight is simply blindly powered, astronomically high values are generated from 16-bit raw data, leading to NaN (Not a Number) or memory overflows.

The MoonEngine deterministically normalizes the edge matrix using a stepwise fusion equation:

W(x, y) = ( Laplacehybrid(x, y) 255.0 ) 4
# Excerpt from engines/engine_macro.py:
# Stable weight synthesis without floating-point overflow
norm_weight = np.clip(weight / 255.0, 0.0, 1.0)
weight = np.power(norm_weight, 4.0).astype(np.float32)

better = weight > max_weight_tracker
max_weight_tracker[better] = weight[better]
depth_map[better] = frame_index

final_img += img * weight[..., np.newaxis]
accum_weight += weight

This exponentiation radically dampens soft blur transitions, ensuring that only the steepest edge receives the credit for the final pixel. Concurrently, every pixel decision is logged in a high-resolution depth map (depth_map).


4. The Limits of Pure Physics – and Where L.U.N.A. Takes Over

No Fourier Transform or Laplace filter in the world can conjure image information that was not optically captured:

Here, classical signal processing reaches its absolute limit. And precisely here begins the raison d'être of L.U.N.A. Prime:


5. Measured Performance: Autonomous Optimization in Real-World Benchmarks

The theoretical architecture proves its utility only under real data loads. Our internal hardware sensor (SystemProfiler) automatically determines the physical limit of the host system before each run and configures threads and tile sizes without user intervention.

Mission Sector Raw Frames Guillotine Filter (Top 15%) Selected Elite Frames CPU Allocation Tile Dimension Total Duration
Sector Moon00003 274 RAWs Active (Crater Radar) 41 Frames (38 merged) 11 Cores 4096 x 4096 px 07:05 Min
Sector Moon00004 198 RAWs Active (Crater Radar) 29 Frames (29 merged) 11 Cores 4096 x 4096 px 05:10 Min

Why These Numbers Are Crucial:


Conclusion & Outlook

The interplay between the deterministic computational power of the MoonEngine and the cognitive heuristics of L.U.N.A. proves that modern image processing should not hide behind outdated interfaces and rigid algorithms.

By mathematically modeling optical flaws such as focus breathing, seeing, and edge halos, and securing them with semantic AI decisions, we overcome the stagnation of conventional stacking suites.

In the next white paper article, we will take a detailed look at the Zero-Memory-Leak Architecture and demonstrate how Agent Joan and the PredictiveCache optimize I/O streaming for 10,000 RAW files.