


# Python at GlobalSino:
# https://www.globalsino.com/ICs/page4853.html

import numpy as np
import imageio
import scipy.signal as ss
import cv2
import numpy as np
 
image1 = cv2.imread('C:\GlobalSino\images\TestImages\ImagesOnly\ImageTarget.tif')
# Convert the image in grayscale
img1 = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
cv2.imshow('', img1)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(img1.shape)

image2 = cv2.imread('C:\GlobalSino\images\TestImages\ImagesOnly\Template.tif')
# Convert the image in grayscale
img2 = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY)
cv2.imshow('', img2)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(img2.shape)

cdata = ss.correlate2d(img1, img2 )
cv2.imshow('Tesult A after the correlation', cdata)
print(cdata.shape)

cdata = ss.correlate2d( img1, img2, mode='same' )
cv2.imshow('Tesult A after the correlation', cdata)
print(cdata.shape)

def Correlate2DF( img1, img2 ):
  c = img1*img2.conjugate( )
  C = ft.ifft2( c )
  C = ft.fftshift(C)
  return C

