Post-Render Perspective Align
Project description
PRPA: Post-Render Perspective Align
This repo is the Python implementation of PRPA (Post-Render Perspective Align), a post-render view alignment algorithm for rendered 3D Gaussian Splatting images. Given a target camera with its rendered depth map and a reference camera with its colour image, PRPA warps the reference image into the target view, detects occlusion conflicts, and fills warping artifacts with an error-erosion pass.
PRPA is introduced in (SIGGRAPH 2026) CAGS: Color-Adaptive Volumetric Video Streaming with Dynamic 3D Gaussian Splatting. The CAGS codec implementation is maintained separately at ColorAdaptiveGaussianSplatting.
Features
- Standard Python package with
pip installsupport - Depth-map reconstruction from rendered target views
- Perspective reprojection from target view to reference view
- Reference-image warping with PyTorch
grid_samplesupport - Occluded / occluding pixel masks from projected-depth competition
- Error-erosion filling for occluded regions with configurable kernels and dilation
- Multiple execution backends: PyTorch, Taichi CUDA, and compiled CUDA extension
- Helper renderer for generating colour, depth, and camera files from Gaussian Splatting outputs
Install
Prerequisites
- Python >= 3
- PyTorch with CUDA support
- CUDA Toolkit and a C++ compiler if building the compiled CUDA extension
- Taichi if using the
taichibackend opencv-pythonandnumpyfor reading images, depth maps, and camera filesgaussian-splattingif usingrender.pyto generate test data
Install common runtime dependencies first:
pip install torch torchvision
pip install opencv-python numpy taichi tqdm matplotlib
PyPI Install
pip install --upgrade PostRenderPerspectiveAlign
or build the latest version from source:
pip install wheel setuptools
pip install --upgrade git+https://github.com/yindaheng98/PostRenderPerspectiveAlign.git@master --no-build-isolation
Development Install
git clone https://github.com/yindaheng98/PostRenderPerspectiveAlign.git
cd PostRenderPerspectiveAlign
pip install torch torchvision opencv-python numpy taichi tqdm matplotlib
pip install --upgrade --no-build-isolation -e .
For rendering Gaussian Splatting outputs into PRPA test data, install the packaged Gaussian Splatting dependency:
pip install --upgrade --target . --no-deps git+https://github.com/yindaheng98/gaussian-splatting.git@master
The cuda backend uses the CUDA extension declared in setup.py. If extension compilation fails, use the torch or taichi backend.
Data Layout
PRPA command-line tools address each view by a file prefix. The target view needs a camera JSON file and a depth .npz file; the reference view needs a camera JSON file and a colour image:
testdata/
|-- 00000.camera.json
|-- 00000.png
|-- 00001.camera.json
`-- 00001.depth.npz
Camera JSON files use the Gaussian Splatting camera fields consumed by prpa.data.fromJSON, including height, width, rotation, position, fx, and fy. Depth files store a compressed NumPy array named depth, shaped as 1 x H x W.
Command-Line Usage
Align a Reference View to a Target View
python -m prpa \
--local testdata/00001 \
--reference testdata/00000 \
--warped output/00001_from_00000 \
--backend torch \
--kernel-size 16
The command reads:
testdata/00001.camera.jsonandtestdata/00001.depth.npzas the target viewtestdata/00000.camera.jsonandtestdata/00000.pngas the reference view
It writes:
output/00001_from_00000.no_error_erosion.png: raw reprojected result before error erosionoutput/00001_from_00000.png: final PRPA-aligned image
Choose a Backend
python -m prpa \
--local testdata/00001 \
--reference testdata/00000 \
--warped output/00001_from_00000 \
--backend taichi
Available backends:
torch: reference implementation using PyTorch tensor operations andgrid_sampletaichi: fused Taichi kernels for reprojection, occlusion detection, and erosion on CUDAcuda: compiled CUDA extension exposed through the Taichi kernel wrapper
The Taichi and CUDA query kernels use nearest-neighbour colour sampling. Use the torch backend when bilinear grid_sample sampling is required.
Tune Error Erosion
python -m prpa \
--local testdata/00001 \
--reference testdata/00000 \
--warped output/00001_from_00000 \
--kernel-size 16 \
--occluded-dilation-size 1 \
--occlude-dilation-size 1 \
--max-iterations 64
kernel-size controls the colour-averaging window for filling occluded regions. The dilation arguments expand the occluded / occluding masks before source pixels are selected. max-iterations can be used to cap the erosion loop.
Render Your Own Test Data
python render.py \
-s data/flame_salmon_1/frame1 \
-d output/flame_salmon_1/frame1 \
-t testdata \
-i 10000 \
--mode base \
--device cuda
render.py loads output/flame_salmon_1/frame1/point_cloud/iteration_10000/point_cloud.ply, renders the cameras from the source scene, and writes .png, .depth.npz, .depth.png, and .camera.json files under testdata/.
API Usage
Run PRPA on Files
import torch
from prpa import PRPA
from prpa.data import read_camera_color, read_camera_depth
with torch.device("cuda"):
target = read_camera_depth("testdata/00001.camera.json", "testdata/00001.depth.npz")
reference = read_camera_color("testdata/00000.camera.json", "testdata/00000.png")
warped = PRPA(target, reference, bordermode="grid_sample", kernel_size=16)
target.depth is an H x W depth tensor. reference.color is an H x W x C image tensor as loaded by OpenCV.
Select an Accelerated Backend
import taichi as ti
from prpa.prpa import set_backend
set_backend("taichi", arch=ti.cuda)
or:
from prpa.prpa import set_backend
set_backend("cuda")
Call set_backend before invoking PRPA. The default backend is torch.
Use Lower-Level Operators
from prpa import reconstruction, projection, query, warp
xyz = reconstruction(target.K, target.R, target.T, target.depth)
uv, depth = projection(reference.K, reference.R, reference.T, xyz)
warped, mask_occluded, mask_occlude = query(target, reference, reference.color)
warped = warp(warped, mask_occluded, mask_occlude, kernel_size=16)
These operators expose the same pipeline stages used by PRPA for experiments and custom post-processing.
Design: Post-Render Perspective Align
PRPA separates perspective alignment into four stages:
Target depth + target camera -> 3D reconstruction
3D points + reference camera -> reference-view projection
Reference colour + projected pixels -> warped colour + occlusion masks
Warped colour + masks -> error-eroded final image
Reprojection
reconstruction lifts target-view pixels into 3D using the target camera intrinsics, pose, and depth map. projection maps those reconstructed 3D points into the reference camera, producing reference-image coordinates and projected depth.
Occlusion Detection
is_occlusion compares projected depths that land on the same reference pixel. Pixels whose depth is farther than the nearest competing depth are marked as occluded, while the nearer pixels that hide them are marked as occluding.
Error Erosion
warp first closes the occlusion masks morphologically, then repeatedly applies error_erosion to fill occluded pixels from nearby valid colour samples. This removes holes and edge artifacts introduced by perspective warping.
Backends
The PyTorch backend is the readable reference path. The Taichi and CUDA backends fuse the expensive reprojection, occlusion, and erosion kernels for faster CUDA execution. benchmark.py compares Taichi and CUDA performance on local test data.
Testing and Benchmarking
python test_cuda_vs_taichi.py
python benchmark.py
test_cuda_vs_taichi.py checks query and erosion consistency between the Taichi and CUDA kernels. benchmark.py reports average PRPA runtime for both accelerated backends.
Acknowledgement
This repo is developed based on PyTorch, Taichi, and 3D Gaussian Splatting. Many thanks to the authors for open-sourcing their codebases.
License
This project is released under the Apache-2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file postrenderperspectivealign-1.2.2.tar.gz.
File metadata
- Download URL: postrenderperspectivealign-1.2.2.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb6a7f676a7d4818314cc04a5214e90cdc94e5471f8481c283f7dc1324de3f85
|
|
| MD5 |
648d38045a605ed965dc279c1c7ebd7c
|
|
| BLAKE2b-256 |
a7da685887d8d9bda59e53ada8118635aa4e50b42859b801d6dd1887edab8fb8
|
File details
Details for the file postrenderperspectivealign-1.2.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: postrenderperspectivealign-1.2.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 127.4 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e1e43dd909f75d94c9395d72ab099fa23422ba60a6e1e0f948cdacaf6cc93b3
|
|
| MD5 |
d116e72bc71c1da0e67ee79cd648c9d4
|
|
| BLAKE2b-256 |
86209642cf371b91e4b075c8bd861a573470f61779762f791d3c4e68439d83df
|
File details
Details for the file postrenderperspectivealign-1.2.2-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: postrenderperspectivealign-1.2.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 126.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c901a38c3cc51283bf88878e564ee6843196874d16b64dd52946e43f5ab37cb
|
|
| MD5 |
867276a67d4cb90dff1757e391f66005
|
|
| BLAKE2b-256 |
688bccb37a212639ab9977c2ae4eb9c7ae5b01f057c261100916e9fe1e14cb0d
|
File details
Details for the file postrenderperspectivealign-1.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: postrenderperspectivealign-1.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a4540ae1c29f7c97fd7fdb708107fa976773ec62e31abae0af5acdaacf63ad0
|
|
| MD5 |
0b246fb60fc8ae2829e7972276f42f88
|
|
| BLAKE2b-256 |
58bf2c1368ffbef0fbbd6337d1b53f0c13c5eb3bc6a0360be7b9c840d7710654
|
File details
Details for the file postrenderperspectivealign-1.2.2-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: postrenderperspectivealign-1.2.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 125.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dc5ced42e5e24ae80f1a7aa0376a28d195581fafb07e846221a0a62b5fd5a10
|
|
| MD5 |
770efbe8f79806431f35c738be80b9e4
|
|
| BLAKE2b-256 |
cfed5b6d40433c5831af34fa46594d9948bc1d206c7e8c497f1164f9fabc0324
|
File details
Details for the file postrenderperspectivealign-1.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: postrenderperspectivealign-1.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e6b232b84fbd5226fe13b0abc6d2555e6ab53f106d601183351d008d80e20d0
|
|
| MD5 |
dd2e4b358788cddd9c5abb09002ed4fc
|
|
| BLAKE2b-256 |
ce90b04f46bd6112dc8787d0071cc7c17e90ccd3bb1169b76e176ab913b9d2a4
|