import struct import numpy as np import matplotlib.pyplot as plt dateMat = np.ones((7,7)) kernel = np.array([[2,1,1],[3,0,1],[1,1,0]]) def convolve(dateMat,kernel): m,n = dateMat.shape km,kn = kernel.shape newMat = np.ones(((m - km + 1),(n - kn + 1))…