Advertisement

图像预处理灰度化

阅读量:

重量计算法、峰值选取法、加权均值法

复制代码
    # -*- coding: UTF-8 -*-
    import cv2 as cv
    import numpy as np
    import matplotlib.pyplot as plt
    
    # def zh_ch(string):
    #     return string.encode("gbk").decode(errors="ignore")
    
    img = cv.imread("test.jpg")  # 读取指定位置的彩色图像
    # img = cv.imread("test.jpg", cv.IMREAD_COLOR)  # 读取指定位置的彩色图像
    # gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
    # cv.imshow("img", gray)  # 显示图片
    height, width, channel = img.shape
    
    # 分量法
    R = np.zeros(img.shape, np.uint8)
    G = np.zeros(img.shape, np.uint8)
    B = np.zeros(img.shape, np.uint8)
    f

全部评论 (0)

还没有任何评论哟~