Practical task 1: Developing a correlation filter.
Developing a correlation filter.
It is necessary to develop a function - a filter based on correlation. without using ready-made implementations and using only numpy library functions.
It is necessary to use the following types of kernels for filters with normalization:
1 1 1 1 1 2) -1 -1 -1 -1 -1 3) -1 -1 -1 -1 -1
1 1 1 1 1 0 0 0 0 0 0 0 1 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
For test Image please use picture boat1_resize.jpg.
Plese, Save your Result as the processed image and code to the report file and subscribe it to answer of this task
import numpy as np
import cv2 as cv
img=cv.imread("D:/boat1_resize.jpg",0)
cv.imshow("1",img)
cv.waitKey(0)
kernel1=np.array([[1,1,1],
[0,0,0],
[-1,-1,-1]])
img=cv.copyMakeBorder(img,1,1,2,2,cv.BORDER_REPLICATE)
img2=img.copy()
for i in range(0,321,1):
for j in range(0,492,1):
a=np.abs(np.sum(np.multiply(img[i:i+3,j:j+3],kernel1)))
img2[i+1,j+2]=a
img=img[1:323,2:495]
cv.imshow("1",img2)
cv.waitKey(0)
cv.destroyAllWindows()
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,已经为您补发到账户,我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。
ps
1 这个代码可能是有问题的
2 题目有3个需求,需要3段代码