前段时间看到了一个发票去红章的博客,看了一下源码将源码 c++改成 python

感谢博主提供的思路和代码

原博客https://www.cnblogs.com/skyfsm/p/7638301.html

ubuntu+python2.7

 

#-*- coding: utf-8 -*-
import cv2
import numpy as np
from matplotlib import pyplot as plt

def RemoveRed(img):
    #img = cv2.imread('10.jpg')
    b, g, r = cv2.split(img)
    cv2.imshow('2',r)
    img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)#灰度
    th = 180   #阈值
    #cv2.threshold(img, th, 255, 0, img)#二值
    cv2.threshold(r, th, 255, 0, img)
    cv2.imshow('1',img)
    cv2.waitKey()

if __name__ == '__main__':
    img = cv2.imread('10.jpg')
    result = RemoveRed(img)

 

posted on 2018-07-27 19:39  jjcc  阅读(169)  评论(0编辑  收藏  举报