计算机视觉的卷积及Dr的代码,上课没有听懂,需要超级详细讲解

计算机视觉的卷积及Dr的代码,上课没有听懂,需要超级详细讲解

问题描述:

问题遇到的现象和发生背景

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 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

img

问题相关代码,请勿粘贴截图
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段代码

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632