Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

VS 2010 [RESOLVED] How would I find a certain pixel pattern in an image?

$
0
0
Currently the code I have been using is similar to this:
Code:

Dim img As Bitmap                                                                        'Image we are scanning
For xCoord = 1 To img.Width - 1                                                      'Running though each pixel in each row
      For yCoord = 1 To img.Height - 1                                              'Running through each row
            If img.GetPixel(xCoord, yCoord) = Color.Brown Then                'First Pixel that matches
                  If img.GetPixel(xCoord + 1, yCoord) = Color.Black Then            'Second matching, the one right next to the first
                        If img.GetPixel(xCoord + 1, yCoord + 1) = Color.Red Then          'Third matching, the one below and to the right of the first
                              XPix = xCoord                                                                        'The three pixels match up in the correct pattern
                              YPix = yCoord                                                                        'Recodring their location
                        End If
                  End If
            End If
      Next
Next

Obviously this is highly inefficient having to scan each pixel on screen individually, not to mention extremely slow and resource heavy.
Any other way to find a certain pattern of pixels on the screen (or in an image ect.) without having to scan each separately?

Any help appreciated.
-Thanks!

Viewing all articles
Browse latest Browse all 27329

Trending Articles