feat(tuya_t5_pocket): add edge-locked Atkinson and gamma-serpentine dithering - #677
Merged
shiliu-yang merged 3 commits intoAug 18, 2026
Conversation
…ithering Add two ordered/error-diffusion dithering methods to the camera YUV422->binary pipeline (BINARY_METHOD_EDGE_ATKINSON, BINARY_METHOD_GAMMA_SERPENTINE), selectable via the existing method-cycling UI in camera_screen.c. - Edge-locked Atkinson: locks high-contrast edges to solid black (via a raw 3x3 Laplacian magnitude, gated by brightness) and Atkinson-diffuses the rest, giving a bold poster-like look while keeping outlines crisp. - Gamma-corrected serpentine Floyd-Steinberg: brightens shadow detail via a gamma LUT before dithering (since raw camera luma isn't gamma-corrected and error diffusion otherwise preserves the source's true, often darker, average brightness), with scan direction alternating per row. - Both use calculate_adaptive_threshold()/gamma(mean(raw)) for a per-frame black/white split instead of a fixed threshold tuned for normal photos. bayer_dither.py gets PC-side ports (edge_atkinson_dither, gamma_serpentine_dither) used to validate these constants against real photos before porting to C. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add the local dev tooling used to validate/generate dithering output for the T5 Pocket display, and keep the one remaining sample PHOTO asset: - compare_dither.py: runs all bayer_dither.py algorithms against test photos and composites them into a single comparison grid image. - tools/png2lvgl_raw.py: embeds PNGs as raw-byte lv_img_dsc_t C arrays (same format already used by tuya_floyd.c / tuyaopen_logo). - photos/photo_image2_gamma_serpentine_dither.c: sample output of the new gamma-serpentine dither, wired into the build via CMakeLists.txt (not currently referenced by any screen). - .gitignore: ignore the local .agents/ tooling directory. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
bayer_dither.py and compare_dither.py are PC-side test/dev scripts, not part of the firmware build (nothing in CMakeLists.txt or C code references them). Move them next to the existing png2lvgl_raw.py and ditter-converter/ tooling in apps/tuya_t5_pocket/tools/, out of src/display/ which should only contain compiled display source. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
shiliu-yang
approved these changes
Aug 18, 2026
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BINARY_METHOD_EDGE_ATKINSON(edge-locked Atkinson, bold poster-like look with crisp outlines) andBINARY_METHOD_GAMMA_SERPENTINE(gamma-corrected serpentine Floyd-Steinberg, brightens shadow detail before dithering).camera_screen.c(no new UI needed).src/tal_imagecomponent (TAL_IMAGE_MONO_MTH_EDGE_ATKINSON/TAL_IMAGE_MONO_MTH_GAMMA_SERPENTINE), which was already linked into this and other apps (your_robot_dog,your_chat_bot,lvgl_games, etc.) but not previously used by the T5 Pocket camera path -- the app had its own separate copy of the same 9 base algorithms. Adding the two new methods there too keeps both implementations in sync and makes them available to any app callingtal_image_format_yuv422_to_binary().bayer_dither.py(moved toapps/tuya_t5_pocket/tools/, alongsidecompare_dither.pyandpng2lvgl_raw.py) gets matching PC-side ports (edge_atkinson_dither,gamma_serpentine_dither) used to validate these constants against real photos before porting to C.Test plan
tos.py buildsucceeds for T5AI / TUYA_T5AI_POCKET (both the app-local copy and the sharedtal_imagecomponent)tal_image-consuming app (e.g.your_chat_bot) to double-check the shared component change🤖 Generated with Claude Code