feat(pixel-grid): add explicit grid reconstructor - #495
Conversation
Detected grids need a separate local stage that can rebuild one color per cell. Add deterministic two-stage reconstruction with bounded memory and explicit grid arguments. Images can now be rebuilt without invoking detection, application services, or generation flows.
The native reconstructor needs a reproducible package boundary and dependency graph. Add the Rust manifest, locked dependencies, and local target exclusion. The reconstruction module can now build independently with deterministic inputs.
Explicit reconstruction must preserve source colors without creating dense-grid artifacts. Cover exact cells, uncapped final palettes, bad points, input limits, and working-set rejection. Color and resource regressions now fail before this module reaches the application layer.
The extracted reconstruction algorithm must remain traceable and license compliant. Document its explicit-grid contract, two-stage color behavior, fixed upstream revision, and MIT terms. Maintainers can review the reuse boundary without consulting the generation codebase.
The standalone reconstructor needs a narrow gate independent of backend CI. Run format and locked release tests only for reconstructor paths and its workflow. Reconstruction changes now receive isolated validation without touching generation jobs.
|
Deployment failed for project windup with the following error: Learn More: https://vercel.com/huyan-s-projects1?upgradeToPro=build-rate-limit |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| let cell = cell_y[y] * cols + cell_x[x]; | ||
| let weight = weight_y[y] * weight_x[x] + 1e-4; | ||
| let rgb = [ | ||
| rgba[source_offset] as f64 / 255.0, |
There was a problem hiding this comment.
[P1] Exclude transparent RGB values from visible color averaging
When a cell is majority-opaque, this loop still adds every source pixel's RGB to fallback_sum and, if its label wins, to color_sum, regardless of alpha. The k-means sample deliberately uses only opaque pixels, so a common PNG with opaque red content and transparent padding whose stored RGB is blue can produce a visible blended/purple cell even though the transparent RGB should not affect the reconstructed color. Keep the existing alpha-majority calculation, but exclude transparent pixels from the color sums and their denominator (while retaining a sensible fallback for cells with no opaque pixels).
新增一个与检测器和业务应用均解耦的显式网格重建器:调用方给定网格后,本地模块输出每格单色的原生 1x PNG。
Why
网格识别与像素重建是两种不同职责。把重建逻辑绑定在检测器或生成管线中,会导致后续替换检测算法时同时改动颜色恢复,并把本地工具扩散到现有业务路径。
Changes
cols、rows、colors并输出 PNG。colors只控制结构聚类,不硬性截断最终全局色板。Implementation
backend/native/pixel_grid_reconstructor/,不导入检测器、windup_app、工作流、生成 API、数据库或媒体服务。cells × labels投票矩阵、颜色/透明度累加器、轴缓冲与编码重叠,溢出使用 checked arithmetic。Verification
cargo fmt --check:通过。cargo test --release --locked --offline:9 项测试通过,0 项失败。cargo clippy --release --locked --offline -- -D warnings:通过。git diff --check upstream/main...HEAD:通过。Scope
colors不是最终图片颜色数上限;测试证明结构色为 2 时仍可保留 4 种原色。Development Context
Related Issues
Closes #491
Refs #489