You can traverse the pixels of two pictures at the same time, compare the gray values of pixels in the same position, and create a new picture with the same size. If the comparison results are the same, draw dots in one color on the picture, and if they are different, draw dots in another color, so that the differences between the two pictures can be presented.
You can view the knowledge about traversing pixels.
/jackey rain/blog/item/9f 1803 ea 6b 6660 DBD 439 c 93 b . html