I am trying to find an image in an image. I do this to automate the desktop. At this moment I try to be fast, accurate. So I decided to match a similar image solely on the basis of the same average color.
If I find several desktop icons, for example:

And I will look for the latter (I'm still wondering what kind of file it is):

You can clearly see what will most likely correspond:

In different situations, this may not work. However, when the image size is set, it should be fairly reliable and lightning fast.
I can get a screenshot as an object BufferedImage:
MSWindow window = MSWindow.windowFromName("Firefox", false);
BufferedImage img = window.screenshot();
//Or, if I can estimate smaller region for searching:
BufferedImage img2 = window.screenshotCrop(20,20,50,50);
Of course, the search image will be loaded from the template saved in the file:
BufferedImage img = ImageIO.read(...whatever goes in there, I'm still confused...);
, , , :
. , .