相关疑难解决方法(0)

在图像上找到3x3滑动窗口

我有一张图片.

我想为图像中的每个像素获得3x3窗口(相邻像素).

我有这个Python代码:

for x in range(2,r-1,1):
    for y in range(2,c-1,1):
        mask5=numpy.array([cv.Get2D(copy_img,x-1,y-1),cv.Get2D(copy_img,x-1,y),cv.Get2D(copy_img,x-1,y+1),cv.Get2D(copy_img,x,y-1),cv.Get2D(copy_img,x,y),cv.Get2D(copy_img,x,y+1),cv.Get2D(copy_img,x+1,y-1),cv.Get2D(copy_img,x+1,y),cv.Get2D(copy_img,x+1,y+1)])
        cent=[cv.Get2D(copy_img,x,y)]
Run Code Online (Sandbox Code Playgroud)

mask5是3x3窗口.cent是中心像素.

有没有更有效的方法来做到这一点 - 即使用map,iterators - 除了我使用的两个嵌套循环之外的任何东西?

python opencv image-processing

6
推荐指数
1
解决办法
8306
查看次数

标签 统计

image-processing ×1

opencv ×1

python ×1