Repository navigation
fix: a small bright change in a tile is not lost in the tile average - #69
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
tile_changed only looked at the tile's mean pixel difference. A new digit on a display is a handful of pixels inside a 256 px tile: on the 1/8 thumbnail the patch is tiny, so even a sharp black-to-white change moves the tile's mean by well under TILE_DIFF (6.0), and the tile read as unchanged. The OCR cache then kept its old reading of that region for the rest of the run. Now a tile also counts as changed when one thumbnail pixel moved by more than TILE_PEAK_DIFF (32). Uniform noise moves every pixel a little and none by much, so it still reads as no change; a small sharp patch does not. Added a test that paints a 12x12 patch in one tile (mean diff ~0.5, peak diff ~225): it failed before this fix (changed_tiles returned no tiles) and passes now.
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.
Fixes part of #58 (bug 4, "The OCR cache misses one new digit").
tile_changedonly compared the mean pixel difference of a tile on the 1/8 thumbnail. A new digit on a display is a handful of pixels inside a 256 px tile, so even a sharp black-to-white change moves the tile's mean by well underTILE_DIFF(6.0). The tile read as unchanged, and the OCR cache kept its old reading of that region for the rest of the run - this is what hid the Calculator display's first digits in #58.Fix: a tile also counts as changed when one thumbnail pixel moved by more than a new
TILE_PEAK_DIFF(32). Uniform noise moves every pixel a little and none by much, so it still reads as no change (see the existingtest_faint_noise_does_not_count_as_a_change); a small sharp patch does not.I re-derived this independently from the bug report rather than taking the diff there as-is; the shape ended up close to it, but the threshold name, value, and test are my own.
Test: added
test_a_small_bright_change_is_not_lost_in_the_tile_averagetotests/test_ocr_cache.py- paints a 12x12 patch in one 256 px tile (measured mean diff ~0.5, peak diff ~225). It fails onmain(changed_tilesreturns no tiles) and passes with this fix.Ran before opening:
731 passed, 2 skipped, 1 xfailed (one more pass than
main's 730, the new test).🤖 Generated with Claude Code