Add basic erosion morphological operation #68
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.
Hey there 👋
While comparing images produced by two different computers via WebGL, we noticed that sometimes the images would include 1px-2px thick spurious diff regions, likely caused by differences in rasterization and floating point precision between GPU models.
pixelmatch
already includes antialias detection which helps alleviate some of these false-positives, but in some cases they were still showing up in our image diffs.This PR introduces logic to optionally apply an erosion morphological operation after calculating the diff — which eliminates 1-2px wide structures from the image diff — and to return the total of non-eroded pixels.
Erosion is implemented as a separate pass, so it requires the
output
image to be present. By default eroded pixels are marked with an orange color.