This project innovates in its approach to lunar astrophotography through advanced computer vision techniques. Its objective is to process video frames into ultra-sharp composite images of the Moon, utilizing a custom crater reference map and lucky imaging. Alignment and crater detection tuning are applied automatically, but can be customized as needed. The resulting images are fully based on the provided video frames; no part of the final images are AI-generated.
Upload an MP4 to the lunar_videos folder and run the Lunar_Post_Capture notebook. A sample lunar video has been provided in case you don't have a lunar video on hand. Once processed, stacked images will be available in the stacks folder. Artifacts can be found in the lunar_stack_artifacts folder.
Earth-based astrophotography suffers from equipment jitter and atmospheric turbulence.
Lunar Drift Clip
lunar_drift.mp4
The first step in solving this challenge is frame alignment.
To align frames properly, a crater reference map has been developed from a reference mosaic of 1,300 image captures from the Lunar Reconnaissance Orbiter Camera and the Robbins Lunar Crater Database. Mapping has been limited to 295 craters in eight highly-visible maria to avoid detection anomalies that commonly occur near the Moon's limb and terminator.
To align with the crater reference map, Meta's lightweight ViT-B Segment Anything Model (SAM) is applied to segment the lit portion of the Moon in each video frame, as well as the reference mosaic. Captured frames are then rescaled through RANSAC circle fitting.
Starting at the center of the lit portion of the moon in the sharpest captured frame, craters are detected using Laplacian-of-Gaussian Blob Detection (LoG). Detection is hypertuned for optimal alignment based on the n-closest craters, crater diameter, and crater magnification. Finally, captured frames are fine tuned through rotation.
Resulting in a crisp, ultra-sharp image of the moon!
- Segment Anything Model (SAM)
- Laplacian-of-Gaussian Blob Detection (LoG)
- RANSAC Circle Fitting
- Centroid-Based Alignment
A technical synopsys is available in the documentation folder.
MIT License. See LICENSE for details.




