How to find an image within another image using python -


I'm trying to use a python to determine if a (small) image is any other (big) Image is in or not

/ Edit: OK, some thoughts: I am using PR, and I use each image as a 'P' mode, I get the integer form of each pixel I can compare something like a Bauer-Moore String Search or Noth-Morris-Prat algorithm Direct'm trying to do, but in two dimensions.

It will probably help you: XXXABCXXX (answer = 4) instead of searching ABC

  ABC DEF GI  

In

  xxxxx Looking for XABCX XDEFX XGHIX XXXXX  

(Answer = (2,2))

Edit: OK, this is the easiest way to do this:

  Import Image, Blue Def Sabimag (IMG1, IMG2): IMG1 = MMP Eserre (IMG1) IMG2 = MMPAsr (Img2) # img1 = numpy.array ([[1,2,3], [4,5,6], [7,8,9]] # img2 = numpy .array ([[0,0,0, 0,0], [0,1,2,3,0], [0,4,5,6,0], [0,7,8,9,0 ], [0,0,0,0, 0]]) img1y = img1.shape [0] img1x = img1.shape [1] img2y = img2.shape [0] img2x = img2.shape [1] stopy = img2y X1 range (0, stopx) in -img1y + 1 stopx = img2x-img1x + 1: for range y1 (0, step): x2 = x1 + img1x y2 = y1 + img1y pic = img2 [y1: y2, X1: x2] test = pic == img1 if test.all (): return x1, y1 returns false small = Image.open ('small .tif') big = Image.open ('big.tif') print subimag ( Small, large)  

It works just fine, but I want to accelerate it in UP I think the key array is in 'test', which we may be able to leave some positions in the image.

Edit 2: Make sure you test the images For losses- use in less format.

on Mac , pillow and Import image from PIL import


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -