5

2D Cross-Correlation between Images

Unsolved
Computer Vision
Signal Processing

Difficulty: 2 | Problem written by mesakarghm
Write a function xcorr(x,y) which computes the cross-correlation to find the location of a template (y) in a noisy image (x).
The output of the function should be a tuple(a,b) representing the location of the template in the noisy image.

Feel free to use any library/function you see fit to achieve this task.

Sample Input:
<class 'list'>
x: [[1, 2, 3], [4, 5, 6]]
<class 'list'>
y: [[1, 2, 3], [4, 5, 6]]

Expected Output:
<class 'tuple'>
(2, 1)

This is a premium problem, to view more details of this problem please sign up for MLPro Premium. MLPro premium offers access to actual machine learning and data science interview questions and coding challenges commonly asked at tech companies all over the world

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Get access to Premium only exclusive educational content available to only Premium users.

Have an issue, the MLPro support team is available 24X7 to Premium users.

This is a premium feature.
To access this and other such features, click on upgrade below.

Log in to post a comment

Comments
Jump to comment-139
abhishek_kumar • 3¬†months, 1¬†week ago

1

from scipy import signal
import numpy as np
def xcorr(x,y):
    corr = signal.correlate2d(x,y,boundary='symm', mode='same')
    b,a = np.unravel_index(np.argmax(corr), corr.shape)
    return (a,b)

Basically, this function is being used to locate a portion of the image on a real image.

It works on the principle of Fourier transformation of an image where the spatial format of the image donor provides us with much information.

Fourier format is easy to process.

For achieving more compact image representation

 

 

referecne:

1.scipy.signal.correlate2d

2. INTRODUCTION TO FOURIER TRANSFORMS FOR IMAGE PROCESSING

3. Convolution and Correlation

4. Fourier transform of images


 

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)