Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/pixel-grid-reconstructor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pixel grid reconstructor CI

on:
push:
paths:
- "backend/native/pixel_grid_reconstructor/**"
- ".github/workflows/pixel-grid-reconstructor.yml"
pull_request:
paths:
- "backend/native/pixel_grid_reconstructor/**"
- ".github/workflows/pixel-grid-reconstructor.yml"

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend/native/pixel_grid_reconstructor
steps:
- uses: actions/checkout@v7

- name: Rust format
run: cargo fmt --check

- name: Rust tests
run: cargo test --release --locked
1 change: 1 addition & 0 deletions backend/native/pixel_grid_reconstructor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
210 changes: 210 additions & 0 deletions backend/native/pixel_grid_reconstructor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions backend/native/pixel_grid_reconstructor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "windup-pixel-grid-reconstructor"
version = "0.1.0"
edition = "2021"
license = "MIT"
publish = false

[dependencies]
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
rayon = "1.12.0"

[[bin]]
name = "windup-pixel-grid-reconstructor"
path = "src/main.rs"

[profile.release]
lto = true
codegen-units = 1
21 changes: 21 additions & 0 deletions backend/native/pixel_grid_reconstructor/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Astropulse, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions backend/native/pixel_grid_reconstructor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Pixel grid reconstructor

Windup 的独立显式网格重建器。它不检测像素密度,只读取 PNG/JPEG 字节与明确的 `cols`、`rows`、`colors` 参数,并输出对应尺寸的原生 1x PNG。

```bash
cargo run --release -- --cols 64 --rows 64 --colors 32 < input.png > output.png
```

模块使用两阶段重建:先对结构色标签投票确定每个格子的归属,再从原图中携带胜出标签的像素恢复颜色。输出的每个像素就是一个规则网格单元,透明度按格内多数票确定。

`colors` 控制结构聚类规模,不是最终图片的强制全局色板上限;这样不会把稀有高光或单像素强调色提前删除。若业务需要固定总色板,应在独立的调色板阶段明确处理。
5 changes: 5 additions & 0 deletions backend/native/pixel_grid_reconstructor/UPSTREAM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Upstream

两阶段重建与 deterministic k-means 逻辑源自 [Retro-Diffusion/pixel-art-fixer](https://github.com/Retro-Diffusion/pixel-art-fixer),固定于提交 `ef376e57e1c272633ca2dbf5f29ec3fcf6596465`,使用 MIT License。

Windup 将显式规则网格重建提取为独立模块,删除检测、旧重建器和未使用的量化路径,并修复密集网格下负三角权重造成颜色外插的问题。
Loading
Loading