资源简介
利用opencv自带的骨架提取函数,经优化后得到汉字图像的骨架图
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Tue Mar 20 10:53:50 2018
@author: Administrator
“““
import cv2 as cv
import numpy as np
def VThin(image array):
h = image.shape[1]
w = image.shape[0]
NEXT = 1
for i in range(399):
for j in range(399):
if NEXT == 0:
NEXT = 1
else:
M = image[i j - 1] + image[i j] + image[i j + 1] if 0 < j < w - 1 else 1
if image[i j] == 0 and M != 0:
a = [0] * 9
for k in range(3):
for l in range(3):
if -1 < (i - 1 + k) < h and -1 < (j - 1 + l) < w and image[i - 1 + k j - 1 + l] == 255:
a[k * 3 + l] = 1
sum = a[0] * 1 + a[1] * 2 + a[2] * 4 + a[3] * 8 + a[5] * 16 + a[6] * 32 + a[7] * 64 + a[8] * 128
image[i j] = array[sum] * 255
if array[sum] == 1:
NEXT = 0
return image
print(‘4‘)
def HThin(image array):
h = image.shape[1]
w = image.shape[0]
NEXT = 1
for j in range(399):
for i in range(399):
if NEXT == 0:
NEXT = 1
else:
M = image[i - 1 j] + image[i j] + image[i + 1 j] if 0 < i < h - 1 else 1
if image[i j] == 0 and M != 0:
a = [0] * 9
for k in range(3):
for l in range(3):
if -1 < (i - 1 + k) < h and -1 < (j - 1 + l) < w and image[i - 1 + k j - 1 + l] == 255:
a[k * 3 + l] = 1
sum = a[0] * 1 + a[1] * 2 + a[2] * 4 + a[3] * 8 + a[5] * 16 + a[6] * 32 + a[7] * 64 + a[8] * 128
image[i j] = array[sum] * 255
相关资源
- Python - 截取指定帧数间隔指定大小的
- Graph Cut图像分割算法——Python+Opencv实
- 《OpenCV视觉之眼》专栏图像处理总体
- opencv实现石头剪刀布代码
- 基于PYTHON+OPENCV的SIFT SURF图像特征匹配
- pycharm工程python调用OpenCV实现USB摄像头
- 基于opencv绘制图片的三维空间显示图
- 全景图像拼接python+opencv
- python 利用OpenCV 图像黑白化
- python-opencv 机器视觉 质心,形心 坐标
- 安装步骤。提取码也在里面
- BM3D去噪python代码
- python+opencv鼠标选择目标自动跟踪,
- 工训物流小车颜色及二维码识别
- Python+OpenCv实现AI人脸识别身份认证系
- 智能小车视觉巡线python代码
- python简易jpeg编码
- 树莓派利用python、opencv、PyALPR识别车
- 人脸识别UI Pythone+pyq5+opencv 多线程模式
- 基于Python的双路视频传输及双显示系
- python调用opencv实现人脸识别的简单D
- 树莓派小车物体追踪
- OpenCV动作识别
- 基于OpenCV的python颜色提取
- 火焰检测代码python
- python,Opencv实现的车牌识别定位及分
- python+opencv实现初步手势识别源码(本
- opencv实时识别指定物体
- OpenCV 3.x with Python By Example 2nd .txt
- 基于Python-opencv的车牌识别
评论
共有 条评论