java - Filter difference between 2 images? -
i trying filter out difference between 2 images (screenshots). unfortunately have absolutely no experience in java , images , have no real idea for.
are there ready-to-use classes that?
what expecting like:
image imga = new (pathtoa); // image instance 500kb image imgb = new (pathtob); // image instance 500kb image imgc = imagefilter.filterdifference(imga, imgb); // difference between imga , imgb , therefore instance 20kb
edit:
example: anyway, mean difference visual difference between images (screenshots). if have 1 screenshot 5 icons in folder , screenshot 1 icon more, want imgc show new icon.
edit 2:
clarification: want difference between 2 screenshots in new image.
edit 3:
some kind of code 1 (code not work):
private bufferedimage getimagedifference(bufferedimage img1, bufferedimage img2) { if (img1.getwidth() == img2.getwidth() && img1.getheight() == img2.getheight()) { bufferedimage img3 = new bufferedimage(img1.getheight(), img1.getwidth(), img1.gettype()); (int x = 0; x < img1.getwidth(); x++) { (int y = 0; y < img1.getheight(); y++) { if (img1.getrgb(x, y) != img2.getrgb(x, y)) //return false; img3.setrgb(x, y, img2.getrgb(x, y)); } return img3; } } else { return false; } }
since interested in screenshots can expect difference image minimal. true small time intervals it's highly uncertain larger. imagine desktop when using application , in few seconds while continuing use same application , on other hand case use different application. parts explains guess file sizes provide images. difference image saved in greyscale format this.
i don't know if there ready library this. suggest (simple) approach kick point:
- just subtract 2 images and
- threshold difference image:
- a) keep differences above value.
- b) keep areas have amount of neighboring pixels differing (this leave out isolated pixel noise)
- you can further process difference image depending on needs.
not java specific solution guess. if don't have idea can start reading bufferedimage
example
Comments
Post a Comment