python3 opencv 图象灰度化处理

2021-01-14 10:26:28 浏览数 (1)

文章目录

  • 图象灰度化处理
  • src
  • 效果

图象灰度化处理

src

代码语言:javascript复制
# -*- coding:utf-8 -*-
# /usr/bin/python
'''
Author:Yan Errol  Email:2681506@gmail.com   Wechat:qq260187357
Date:2019-05-08--10:07
File:img2gray.py
Describe:将加载的图象进行灰度化处理
'''

print (__doc__)

import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt

def read_img(path):
    # Load an color image in grayscale
    img = cv.imread(path, 0)
    return img

def show_img(img):
    # matplot plt show img
    plt.imshow(img, cmap='gray', interpolation='bicubic')
    plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
    plt.show()

def show_Digit(vector):
    # 重新变形
    img = vector.reshape((8, 8))
    plt.imshow(img, cmap='gray')
    plt.show()
src

0 人点赞