Fix MMCQ bounds - #12
Open
mezz wants to merge 1 commit into
Open
Conversation
Author
|
@SvenWoltmann sorry for the ping, this might be hidden since it's not an active project |
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.
I found a minor bounds issue that could cause problems with classifying single-color images.
I decided to add some tests that cover this case, and clean up a little.
Java version is bumped up to Java 8.
Details
In
MMCQ.vboxFromPixels, it builds the initial color-space box by scanning pixels and finding min/max quantized values for red, green, and blue. Before the fix, each channel did:For the first pixel in a solid non-black image,
value < minis true, so theelse ifnever runs. If every pixel has the same value,maxnever gets updated from0. A solid red image could end up with red bounds likermin = 31, rmax = 0, which is an invalid/inverted box.The fix was to make min and max independent checks in
MMCQ.java, so a single pixel can establish both bounds.Impact
Failing tests that are now working:
ignoresPixelsBelowAlphaThresholdForAbgr[4, 4, 128]instead of blue[0, 0, 255].keepsPixelsAtAlphaThresholdForAbgr[128, 4, 4]instead of red[255, 0, 0].ignoresWhitePixelsWhenRequested[128, 4, 4].keepsWhitePixelsWhenNotIgnored