编程语言
首页 > 编程语言> > python+openCV图像处理(十七)

python+openCV图像处理(十七)

作者:互联网

import cv2 as cv
import numpy as np

def big_image_binary(image):
    print(image.shape)
    cw = 256
    ch = 256
    h, w = image.shape[:2]
    gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
    for row in range(0, h, ch):
        for col in range(0, w, cw):
            roi = gray[row:row+ch, col:cw+col]
            dst=cv.adaptiveThreshold(roi, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY, 127,20)
            gray[row:row+ch, col:cw+col]=dst

            print(np.std(dst), np.mean(dst))

    cv.imwrite("2.png", gray)

src = cv.imread("1.png")
big_image_binary(src)
cv.waitKey(0)

cv.destroyAllWindows()

标签:ch,python,image,col,openCV,图像处理,cw,cv,row
来源: https://blog.csdn.net/yang_jianfeng/article/details/111828725