Smart Temporal & Spatial Video Compression Algorithm using Alternating Checkerboard Reconstruction
Developed by RMNO21
Video-Compress is an experimental computer vision and spatial-temporal compression pipeline. Instead of standard lossy quantization, it leverages an alternating checkerboard pixel decimation technique combined with a 4-neighbor Selective Mean Filter to reconstruct high-frequency details with minimal perceptual loss.
- Checkerboard Decimation: Each frame is divided into a 2D checkerboard grid of even and odd coordinates.
- Temporal Interlacing: Odd and even pixel sub-grids alternate across successive frames at target frame rates (30+ FPS), taking advantage of human visual persistence (temporal blending).
- Selective Mean Edge Reconstruction: To eliminate halos and blur around sharp edges, the algorithm analyzes the 4 cardinal neighbors (Up, Down, Left, Right), automatically identifies and discards the highest-variance outlier neighbor, and computes the spatial average of the remaining 3 closest pixels.
- ⚡ High-Speed Vectorized Processing: Fully vectorized with NumPy matrix rolling and masking operations.
- 🎯 Edge-Preserving Selective Mean: Eliminates artifacting and ghosting around high-contrast edges.
- 🔄 Temporal Alternation: Preserves motion fidelity without full-frame data duplication.
- 📦 Minimal Dependencies: Requires only standard
opencv-pythonandnumpy.
Clone the repository and install the dependencies:
git clone https://github.com/RMNO21/video-compress.git
cd video-compress
pip install opencv-python numpypython pixel.pyWhen prompted, enter the full path to your source video file:
Video File Path: "C:\path\to\your\video.mp4"
The script will process each frame with a live progress indicator and save the reconstructed output as processed_pixel_video.mp4 in the same directory.
| Step | Technique | Visual Effect |
|---|---|---|
| Stage 1 | Checkerboard Decimation | Reduces per-frame pixel payload |
| Stage 2 | 4-Neighbor Outlier Rejection | Discards boundary noise |
| Stage 3 | Tri-Neighbor Interpolation | Reconstructs missing pixel coordinates |
| Stage 4 | Temporal Frame Alternation | Leverages persistence of vision |
If you find this computer vision experiment interesting, please consider giving it a Star ⭐!
Contributions, optimizations, and PRs are always welcome.
MIT License © RMNO21