You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder whether it's worth introducing complexity with features like this, or just leaving this up to the user since it's easy enough to just iterate over and null all pixels in desired areas in both input images.
I did a quick implemenation that builds a hash from the rectanges, and then tests the hash with each iteration of the comparison loop:
function buildIgnoreHash(rectangles) {
var hash = {};
for (var i=0; i<rectangles.length; i++) {
var x1=rectangles[i][0],
x2=rectangles[i][2]+x1,
y1=rectangles[i][1],
y2=rectangles[i][3]+y1;
for (var y = y1; y < y2; y++) {
for (var x = x1; x < x2; x++) {
hash[x]=hash[x]||{};
hash[x][y]=true;
}
}
}
return hash;
}
if (ignoreHash && ignoreHash[x] && ignoreHash[x][y])
continue;
Surprising to me, it was not any faster than blanking out rectanges in both images. The only advantage of adding ignoreRectangles feature to the package is that is non-destructive, so you can do something else with the images after comparing them.
Another advantage of including this feature in the package is that the color of the ignore rectangles could be set to black in the diff image, making it clear what had been excluded from the comparison.
Setting the color to black in the input images does not produce a diff image that adequately distinguishes ignore rectangles from darker parts of the input images.
You could black-out the resulting diff image as well, but that's getting a be a lot of extra steps.
Reacted by Jess Telford, Christian Vadalà and Serhii Muryhin
Activity
mourner commentedon Nov 17, 2015
I wonder whether it's worth introducing complexity with features like this, or just leaving this up to the user since it's easy enough to just iterate over and null all pixels in desired areas in both input images.
curtw commentedon Nov 22, 2015
I did a quick implemenation that builds a hash from the rectanges, and then tests the hash with each iteration of the comparison loop:
Surprising to me, it was not any faster than blanking out rectanges in both images. The only advantage of adding ignoreRectangles feature to the package is that is non-destructive, so you can do something else with the images after comparing them.
curtw commentedon Dec 10, 2015
Another advantage of including this feature in the package is that the color of the ignore rectangles could be set to black in the diff image, making it clear what had been excluded from the comparison.
Setting the color to black in the input images does not produce a diff image that adequately distinguishes ignore rectangles from darker parts of the input images.
You could black-out the resulting diff image as well, but that's getting a be a lot of extra steps.
skyiea commentedon Dec 24, 2017
Hi.
Any plans to introduce this feature?
mourner commentedon Dec 24, 2017
No plans for now, to keep it simple. There's a workaround:
adamchenwei commentedon Apr 9, 2019
@mourner any example code how to do that? sorry pretty new to pixelmatch!
mourner commentedon Jun 6, 2019
A sample snippet of how to clear pixel data in a rectangular region (
x0, y0, x1, y1):Merge pull request mapbox#9 in ONE/jest-image-snapshot from feature/u…