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()
上一篇:回溯算法之轮船货箱装载问题(最优装载)


下一篇:canvas系列教程06-柱状图项目4