views:

136

answers:

3

I have 2 bmp images. ImageA is a screenshot (example) ImageB is a subset of that. Say for example, an icon.

I want to find the X,Y coordinates of ImageB within ImageA (if it exists).

Any idea how I would do that?

A: 

Finding sub images in an image
Find an image in an Image
Check if an image exists within another image

SwDevMan81
The first 2 are not the same question as mine and produce very different results. The last one does not work (another user reported so), and even if it did '720p took a couple of minutes'. I would be scanning 1920x1200 images and multiple minutes would not be acceptable. Even an algorithm where you took Pixel1 from ImageB, found all instances of it in ImageA, then took Pixel2 and removed all instances where it isn't 'next to (horiz/vert respective)', and repeated until the list is empty or all pixels have been scanned would be faster than a couple of minutes.
esac
I am just looking for something better than that idea .. there has to be a decent algorithm for something like this.
esac
A: 
  1. So is there any warping of ImageB in ImageA?
  2. How "exact" are the images, as in, pixel-for-pixel they will be the same?
  3. How much computational power do you have for this?

If the answers to the first two questions are No and Yes, then you have a simple problem. It also helps to know the answer to Q3.

Update:

The basic idea's this: instead of matching a window around every pixel in imageB with every pixel in imageA and checking the correlation, let's identify points of interest (or features) in both images which will be trackable. So it looks like corners are really trackable since the area around it is kinda similar (not going into details) - hence, let's find some really strong corners in both images and search for corners which look most similar.

This reduces the problem of searching every pixel in B with A to searching for, say, 500 corners in B with a 1000 corners in A (or something like that) - much faster.

And the awesome thing is you have several such corner detectors at your disposal in OpenCV. If you don't feel using emguCV (C# varriant), then use the FAST detector to find matching corners and thus locate multiple features between your images. Once you have that, you can find the location of the top-left corner of the image.

Jacob
1. if by warping you mean they are of different sizes, then no.2. yes, they will be pixel by pixel the same. i would like to account for a tiny bit of a margin of error or a specified margin of error (1%, 15%, 50%) etc.. but it is not a must.3. assume minimum requirement is dual proc x64 2.2GHz with 2GB RAM
esac
I know all this might seem excessive but if you could post links to the BMP files, I can show you how effective/fast it is.
Jacob
Easy enough .. the type of stuff I want this for is existing windows applications. So just take a screenshot of chrome http://dl.dropbox.com/u/2809/Chrome.bmp and the idea is to find the X/Y of the home button http://dl.dropbox.com/u/2809/HomeButton.bmp within that.
esac
Are all your `imageB`s going to be that small?
Jacob
Anyway, I'll code up something in C++ in a few hours.
Jacob
No, they can vary in size, probably from 16x16 to 800x600
esac
A: 
AVB