资源简介
用python写的图片处理程序,用的库有OpenCV,PIL , numpy。可进行线圈部分提取以及切割线圈部分图片并保存
代码片段和文件信息
# coding:utf-8
# author:HOJAY
# 矩阵运算 图像预处理
from PIL import Image ImageDraw
import numpy as np
import matplotlib.pyplot as plt
import cv2 as cv
path1 = “border_detection.bmp“
#打开图片并返回二值化图片
def openfile():
img = Image.open(r‘F:/管浩杰/桌面/线圈/1.bmp‘ “r“)
# pix = img.load()
r g b = img.split()
r = np.mat(r)
g = np.mat(g)
b = np.mat(b)
c = (2 * r - g - b)/(2 * r + g + b + 0.000001)
c = c > 0.3
show_pic(r g b c)
# pic.show()
#显示合并的图片
def show_pic(r g b c):
r = np.multiply(r c)
g = np.multiply(g c)
b = np.multiply(b c)
r = Image.fromarray(r)
g = Image.fromarray(g)
b = Image.fromarray(b)
pic = Image.merge(‘RGB‘ [r g b]) #合并三通道
pic.save(path1)
# 边缘处理
def border_detection():
img = cv.imread(path1 0)
b = np.ones((5 5) np.uint8)
result_1 = cv.erode(img b)
result_2 = cv.dilate(result_1 b)
result_2 = cv.dilate(result_2 b)
result_2 = cv.erode(result_2 b)
result_2 = cv.dilate(result_2 b)
result_2 = cv.dilate(result_2 b)
# cv.namedWindow(“result_1“ 0)
# cv.namedWindow(“result_2“ 0)
# cv.imshow(“result_1“ result_1)
# cv.imshow(“result_2“ result_2)
# cv.waitKey(0)
# cv.destroyAllWindow
- 上一篇:KSVD代码手写版本
- 下一篇:vmd,python实现代码
相关资源
- python+pyqt5+百度AI+车牌识别.rar
- python3.5 百度ai人脸识别
- GENERATIVE_ADVERSARIAL_NETWORKS_COOKBOOK
- 深度学习入门:基于Python的理论与实
- [PDF] Reinforcement Learning With Open AI Tens
- aircraft battle.zip
- Pillow-3.4.2-cp36-cp36m-win_amd64.whl python3
- Deep Learning with Python 原版PDF by Choll
- chainerrl 在Chainer之上,ChainerRL是一个深
- python aiml web 聊天机器人
- 卷积神经网络的Python实现 -《卷积神经
- hog_svm_train_python
- Python-Tensorflow仿AlphaGo框架实现的AI围棋
- python调用dlib库实现简单的人脸识别
- Packt.Python.Artificial.Intelligence.Projects.
- 深度学习入门:基于Python的理论与实
- python深度学习(Chollet中文版)
- Python-mathAI一个拍照做题程序输入一张
- Multi-Devices.rar
- 深度学习入门:基于Python的理论与实
- Python-Tensorflow实现SpatialAsDeepSpatialCNN
- python版本消消乐
- Reinforcement Learning - With Open AI TensorFl
- 文字版pdf书和源代码:深度学习入门
- Python强化学习实战:应用OpenAI Gym和
- Python-使用遗传算法和深度学习训练
- Python机器学习及实践高清
- Introduction to Machine Learning with Python 原
- Python3.5CongLingKaiShiXue-LiuYuZhou.pdf
- Deep Learning for Computer Vision Expert techn
评论
共有 条评论