I am trying to determine differences between two images during an integration test. After doing some research on the web, I stumbled over the MarvinProject and tried to create a UnitTest with it, see below.
As far as I understood the plugin DifferentRegions
, it will fill the passed ImageMask differenceMask
with the regions that contain the differences. The two images I pass for the test do differ, so it should print out something.
Unfortunately it does not.
I have written other tests that compare those two images byte-wise and those succeed. For those who want to try the problem, I have created a repository on GitHub and here is the ImageCompareTest.
@Test
public void tryMarvinProject() {
// init images
String root = "src/test/resources/";
MarvinImage assertedImg = MarvinImageIO.loadImage(root + "image1.bmp");
MarvinImage actualImg = MarvinImageIO.loadImage(root + "image2.bmp");
// init diff-regions plugin
DifferentRegions regions = new DifferentRegions();
regions.load();
regions.setAttribute("comparisonImage", assertedImg);
int width = assertedImg.getWidth();
int height = assertedImg.getHeight();
int type = assertedImg.getType();
// process the images and retrieve differences from the ImageMask
MarvinImageMask differenceMask = new MarvinImageMask();
regions.process(
actualImg,
new MarvinImage(new BufferedImage(width, height, type)),
new MarvinAttributes(),
differenceMask,
false);
// should contain the differences, but does not
System.out.println(differenceMask.getMaskArray());
assertNotNull(differenceMask.getMaskArray());
}