1

Currently I use this to find a bitmap that occurs in another image on the screen i.e. a window but it is tool slow, i want it to take 1 or less seconds, I was thinking of cropping the image into a section i.e. a 80,60 section at point 0,0 of the image and searching there, when it has done that it do the same crop but y+60 and continue until it has covered the full image assuming it is 800 by 600 pixel

the code i currently use is:

 public bool findImage(Bitmap small, Bitmap large, out Point location) { //Loop through large images width for (int largeX = 0; largeX < large.Width; largeX++) { //And height for (int largeY = 0; largeY < large.Height; largeY++) { //Loop through the small width for (int smallX = 0; smallX < small.Width; smallX++) { //And height for (int smallY = 0; smallY < small.Height; smallY++) { //Get current pixels for both image Color currentSmall = small.GetPixel(smallX, smallY); Color currentLarge = large.GetPixel(largeX + smallX, largeY + smallY); //If they dont match (i.e. the image is not there) if (!colorsMatch(currentSmall, currentLarge)) //Goto the next pixel in the large image goto nextLoop; } } //If all the pixels match up, then return true and change Point location to the top left co-ordinates where it was found location = new Point(largeX, largeY); return true; //Go to next pixel on large image nextLoop: continue; } } //Return false if image is not found, and set an empty point location = Point.Empty; return false; } 
1

1 Answer 1

1

Since you are looking for an exact match you can downsample your large picture, and downsample your small picture (but several times, at different offsets). Then search for an exact match of the downsampled pictures (potentially recursing).

Your large picture does not sound that large, you may be able to get away with doing a Boyer-Moore search for one of the lines.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.