Title: Template matching with distortions
Tags: python;matlab;image-processing;template-matching
Question: I have a pattern/image that's printed on a piece of paper and multiple copies are stuck on the wall (ImageA) and I have a larger image (B) of the wall with all these pieces of paper. I want to find the locations of these patterns. Due to apparent distortion of the pattern on the wall, I am unable to use template matching properly (MATLAB or Python). Are there any other methods to do this?
Input: Small Pattern Image (A), Large Image (B)
Desired Output: Multiple pixel X,Y coordinates of A found in B (Approximate locations are ok)
Comment: Depends on how deep you want to go I think... probably the most robust solution would be a type of convolutional neural network, but if you don't have experience with this, it's a big step. Also they tend to a little tough to use when doing image localization (as opposed to classification).


Here is another answer: If the patterns in image B are all roughly the same size / scale, and template A doesn't have strong rotational symmetry, I would try doing a normalized cross-correlation, with the template rotated at different angles. normxcorr2 in MATLAB, or skimage.feature.match_template in Python. You should get a result that has one global maximum and several smaller maxima. Depending on the clutter in your image, the locations of most or all of these maxima should correspond to the locations of A in B.
Have a look at the two answers here: Normalize scipy.ndimage.filters.correlate

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:08/31/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><matlab><image-processing><template-matching>', 'Title': 'Template matching with distortions', 'ViewCount': 434, 'id': 45989512, 'user_AboutMe': '', 'user_AccountId': 1276583.0, 'user_DisplayName': 'SEU', 'user_Reputation': 1172.0, 'user_Views': 175.0, 'user_id': 1231714.0}}