Python OpenCVモルフォロジー操作(腐食膨張,開演算,閉演算)

951 ワード

Python OpenCVモルフォロジー操作(腐食膨張,開演算,閉演算)
フィルタ生成

kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3)) #
kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (3, 3)) #
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3)) #

エッチング膨張開閉演算

# -*-encoding:utf-8-*-
import pytesseract
from PIL import Image
from PIL import ImageFilter
from PIL import ImageFont
from PIL import ImageDraw
import numpy as np
from PIL import Image

import cv2


def main():
# img = cv2.imread("test001.jpg") #
# cv2.imshow("1",img) #
# cv2.waitKey(10000)# 10s

# image = Image.open("test002.png")
# img = image.convert('1') #

# img.show()

img = cv2.imread("test002.png", 0)
kernel = np.ones