2012-08-25 3 views
1

현재이 도구를 사용하여 화면의 다른 이미지 (즉, 창)에서 발생하는 비트 맵을 찾을 수 있지만 도구가 느리므로 1 초 또는 그 미만의 시간이 걸릴 수 있습니다. 이미지를 섹션 0,0에서 80,60 섹션으로 잘라내서 검색하면 거기에서 검색하면 같은 자르기를하지만 y + 60을 수행하고 전체 이미지를 덮을 때까지 계속됩니다. 그것은 800큰 이미지에서 빠른 이미지 검색

내가 현재 사용하는 코드 픽셀 600이다 :

 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; 
    } 
+0

관심 분야 : http://stackoverflow.com/a/11004944/1373170 –

답변

2

당신이 당신의 큰 그림을 다운 샘플링하고 SM을 다운 샘플링 할 수있는 정확한 일치를 찾고 있기 때문에 모든 그림 (그러나 여러 번, 다른 오프셋에서). 그런 다음 다운 샘플링 된 사진의 정확한 일치를 검색합니다 (재귀 가능성이 있음).

큰 그림이 큰 소리가 나지 않으면 선 중 하나에 대해 Boyer-Moore 검색을 수행 할 수 있습니다.

관련 문제