Match a pattern / needle (preferably a bitmap) in a hay raster?

I have two bitmaps in code (.NET). I would like to look for a small drawing (needle) in a large image (haystack). How can I do that?

+3
source share
4 answers

It depends if you are doing an “exact” match with bit patterns or just an approximate (fuzzy) match for images. If you're doing exact matching, just treat the bitmaps as a general search for an array of 2D data.

The smallest but very simple implementation for exact matching can be done in N * M, where N is the number of pixels in the haystack, and M is the number of pixels in the needle.

Given that Haystack is the size (S, T) and the needle bit is the size (U, V), you can iterate over the Haystack using X = [0, SU) and Y = [0, TV). For each location, you can look at a 2D sub-array of the same size as Needle [{X, Y}, {X + U, Y + V}) and compare it with the needle [{0,0}, {U , V}).

+1
source

Perhaps you should take a look at border detection , a generic term for what you are trying to do.

These two links look useful, but they do more with color registration than image processing:

, :

  • "" .
  • "" , ( )
  • ""
  • "" "" ( ) , .
  • "target" "target" XOR "" ( ) , , .

, "" , ( XOR ), , XOR .

, , "" , "" .

, "", 100- , , , .

, , , , . , Codeproject, .

+1

, () .NET, .

++, Insight Toolkit , , " " "" (.. "" /).

0

. :)

, . , . . , .

, , . O () , (, , - , ), , .

I'm sure there are many better ways to do this, but I thought I shared my thoughts :)

Good luck.

0
source

Source: https://habr.com/ru/post/1726268/


All Articles