4-7 毛玻璃

import cv2
import numpy as np
import random
img = cv2.imread('image2.jpg',1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
dst = np.zeros((height,width,3),np.uint8)#为什么我们总是把高度放在第一位,因为我们当前的矩阵它是以行列式来展示的,所以它要先行后列.
#我们过去图片中某一个元素也是先行后列.行就是当前的高度,列就是当前的宽度.
mm = 8
for m in range(0,height):
    for n in range(0,width):
        index = int(random.random()*8)#0-8
        (b,g,r) = img[m+index,n+index]
        dst[m,n] = (b,g,r)
cv2.imshow('dst',dst)
cv2.waitKey(0)

import cv2
import numpy as np
import random
img = cv2.imread('image2.jpg',1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
dst = np.zeros((height,width,3),np.uint8)#为什么我们总是把高度放在第一位,因为我们当前的矩阵它是以行列式来展示的,所以它要先行后列.
#我们过去图片中某一个元素也是先行后列.行就是当前的高度,列就是当前的宽度.
mm = 8
for m in range(0,height-mm):
    for n in range(0,width-mm):
        index = int(random.random()*8)#0-8
        (b,g,r) = img[m+index,n+index]
        dst[m,n] = (b,g,r)
cv2.imshow('dst',dst)
cv2.waitKey(0)

 

posted on 2018-09-23 13:59  绿茵好莱坞  阅读(213)  评论(0编辑  收藏  举报

导航