Home > Automation Testing > Compare images using Java

Compare images using Java

This code will compare pixel from base image with other image.

  • If both pixel at location (x,y) are same then add same pixel in result image without change. Otherwise it modifies that pixel and add to our result image.
  • In case of baseline image height or width is larger than other image then it will add red color for extra pixel which is not available in other images.
  • Both image file format should be same for comparison.
  • Code will use base image file format to create resultant image file.

This code will highlight color change in image and place-change of character in image.

Code for image comparison (pixel-by-pixel).

Sample images that are used for comparison.

Image A(Baseline)
Image B

 

 

Comparison Result:

   
Comparison Result

 

This Article is TAGGED in , , . BOOKMARK THE permalink.

Avatar photo
Neeraj Vishwakarma
Senior QA Engineer Skills: Automation Testing, Manual Testing, STLC, Java, Selenium Webdriver, Protractor, Database Testing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">