I have two images that are very similar.
So for example suppose I drew a 200×200 square, went and filled it a wide variety of colors (say, rainbow colored fill), and saved the image.
Then I drew a star in the middle of the square and also filled it with some variety of colors that is different from the square, and saved it as a different file.
Then some days later I come back and I really want that star because it took some effort to make and didn’t want to redo it. I want to be able to crop out that star quickly and isolate it into its own image (because I was using paint which didn’t have layers)
But I know that image with the star is just a minor variation of the image without the star, so ideally if I could just compare the two images and remove the pixels around the star, then I can get my star back.
Is there anything that does this already?
Or some technique that is provided by existing tools that I am unaware of?
Assuming you have the original image, you can read both images into your program and look at each pixel to see if they are the same value, if they are then set them to black, if not, keep them as they are; your resultant image should have only the pixels that changed in it, with the rest being black.
This may give you an issue within the “star” itself, as there are likely to be points in the star that are the same as the points on the original image(i.e. a pixel may be green in both places on both images). In this case you can look at the surrounding pixels to help.
i.e.:
This code doesn’t look at the issues with pixels in the star image that correspond to the same values in the same locations of the non-star image. There are several techniques to solve that, but bear in mind that if you are looking at neighboring pixels you may have issues at the boundaries of the star.