python的数字图像处理学习(3)
高级滤波:
from skimage import data,color,data_dir
import matplotlib.pyplot as plt
from skimage.morphology import disk
import skimage.filters.rank as sfr
img =color.rgb2gray(data.camera())
auto =sfr.autolevel(img, disk(5)) #半径为5的圆形滤波器
plt.figure('filters',figsize=(8,8))
plt.subplot(121)
plt.imshow(img,plt.cm.gray)
plt.subplot(122)
plt.imshow(auto,plt.cm.gray)
data_dir
高级滤波.....
from skimage import data,color
import matplotlib.pyplot as plt
from skimage.morphology import disk
import skimage.filters.rank as sfr
img =color.rgb2gray(data.camera())
auto =sfr.bottomhat(img, disk(5)) #半径为5的圆形滤波器
auto1 =sfr.tophat(img, disk(5)) #半径为5的圆形滤波器
plt.figure('filters',figsize=(12,12))
plt.subplot(131)
plt.imshow(img,plt.cm.gray)
plt.subplot(132)
plt.imshow(auto,plt.cm.gray)
plt.subplot(133)
plt.imshow(auto1,plt.cm.gray)
提取轮廓....
import numpy as np
import matplotlib.pyplot as plt
from skimage import measure,draw,data,filters
#生成二值测试图像
img=data.page()
thresh = filters.threshold_isodata(img)
img1 = (img <= thresh)*1.0 #根据阈值进行分割
#检测所有图形的轮廓
img2 = img1[:,:]
contours = measure.find_contours(img1, 0.5)
#绘制轮廓
fig, (ax0,ax1,ax2) = plt.subplots(1,3,figsize=(15,15))
ax0.imshow(img,plt.cm.gray)
ax1.imshow(img1,plt.cm.gray)
ax2.imshow(img2,plt.cm.gray) #enumerate索引序列
for n, contour in enumerate(contours):
ax2.plot(contour[:, 1], contour[:, 0], linewidth=1)
plt.show()
提取轮廓..............
import matplotlib.pyplot as plt
from skimage import measure,data,color
img=color.rgb2gray(data.horse())
contours = measure.find_contours(img, 0.5)
fig, axes = plt.subplots(1,2,figsize=(8,8))
ax0, ax1= axes.ravel()
ax0.imshow(img,plt.cm.gray)
rows,cols=img.shape
ax1.axis([0,rows,cols,0])
for n, contour in enumerate(contours):
ax1.plot(contour[:, 1], contour[:, 0], linewidth=1)
ax1.axis('image')
plt.show()
凸包............
import matplotlib.pyplot as plt
from skimage import data,color,morphology
img=color.rgb2gray(data.horse())
img=(img<0.5)*1
chull = morphology.convex_hull_image(img)
fig, axes = plt.subplots(1,2,figsize=(8,8))
ax0, ax1= axes.ravel()
ax0.imshow(img,plt.cm.gray)
ax1.imshow(chull,plt.cm.gray)
多个凸包.....................................................................................
import matplotlib.pyplot as plt
from skimage import data,color,morphology,feature
img=color.rgb2gray(data.coins())
edgs=feature.canny(img, sigma=3, low_threshold=10, high_threshold=50)
chull = morphology.convex_hull_object(edgs) #绘制轮廓
fig, axes = plt.subplots(1,2,figsize=(8,8))
ax0, ax1= axes.ravel()
ax0.imshow(edgs,plt.cm.gray)
ax0.set_title('many objects')
ax1.imshow(chull,plt.cm.gray)
ax1.set_title('convex_hull image')
plt.show()
看不懂也写不下去了...
python的数字图像处理学习(3)的更多相关文章
- python的数字图像处理学习(2)
图像的重定义大小,图像的缩扩,图像的旋转: from skimage import transform,data import matplotlib.pyplot as plt img = data. ...
- python的数字图像处理学习(1)
导入原有的测试图片,测试图片路径,和一些方法,显示出测试图像,测试图像路径. from skimage import io,data,data_dir img_rgb=data.chelsea() i ...
- 【笔记】基于Python的数字图像处理
[博客导航] [Python相关] 前言 基于Python的数字图像处理,离不开相关处理的第三方库函数.搜索网络资源,列出如下资源链接. Python图像处理库到底用哪家 python计算机视觉编程— ...
- 数字图像处理学习笔记之一 DIP绪论与MATLAB基础
写在前面的话 数字图像处理系列的学习笔记是作者结合上海大学计算机学院<数字图像处理>课程的学习所做的笔记,使用参考书籍为<冈萨雷斯数字图像处理(第二版)(MATLAB版)>,同 ...
- MATLAB数字图像处理学习笔记
我们都知道一幅图片就相当于一个二维数组,可以用一个矩阵来表示,而MATLAB可以说就是为矩阵运算而生的,所以学习图像处理,学习MATLAB势在必行! 一. MATLAB基础知识 1. 读取图像 %im ...
- 初始----python数字图像处理--:环境安装与配置
一提到数字图像处理编程,可能大多数人就会想到matlab,但matlab也有自身的缺点: 1.不开源,价格贵 2.软件容量大.一般3G以上,高版本甚至达5G以上. 3.只能做研究,不易转化成软件. 因 ...
- 数字图像处理(一)之灰度转换和卷积python实现
使用Python实现数字图像处理中如下功能: 彩色图像转成灰度图像 实现图像的相关&卷积操作 实现图像的高斯核卷积 使用的库和python版本如下: imageio:2.9.0 用于读取磁盘中 ...
- python数字图像处理(17):边缘与轮廓
在前面的python数字图像处理(10):图像简单滤波 中,我们已经讲解了很多算子用来检测边缘,其中用得最多的canny算子边缘检测. 本篇我们讲解一些其它方法来检测轮廓. 1.查找轮廓(find_c ...
- python数字图像处理(1):环境安装与配置
一提到数字图像处理编程,可能大多数人就会想到matlab,但matlab也有自身的缺点: 1.不开源,价格贵 2.软件容量大.一般3G以上,高版本甚至达5G以上. 3.只能做研究,不易转化成软件. 因 ...
随机推荐
- NumPy 矩阵库(Matrix)
NumPy 矩阵库(Matrix) NumPy 中包含了一个矩阵库 numpy.matlib,该模块中的函数返回的是一个矩阵,而不是 ndarray 对象. 一个 的矩阵是一个由行(row)列(col ...
- JavaWeb网站后台开发记录手册
1.javaweb网站后台开发 1.封装DBTools类 1.注册数据库驱动 Class.forName("oracle.jdbc.driver.OracleDriver"); 2 ...
- 102. Binary Tree Level Order Traversal (Tree, Queue; BFS)
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...
- 200. Number of Islands (Graph)
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...
- TZOJ 2999 Network(连通图割点数量)
描述 A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting ...
- TZOJ 1800 Martian Mining(二维dp)
描述 The NASA Space Center, Houston, is less than 200 miles from San Antonio, Texas (the site of the A ...
- 【centos】centos安装g++
gcc在Centos下的安装:使用的是以下语句:yum install gcc 以为安装g++,类似的应该使用:yum install g++ 可是提示:command is not found 查询 ...
- threejs- z-fighting 问题(模型的重叠部位便不停的闪烁起来。这便是Z-Fighting问题)
Z-Buffer 在threejs中,使用深度缓冲(Z-Buffer)来完成场景可见性计算,即确定场景哪部分可见,哪部分不可见.深度缓冲(Z-Buffer)是一个二维数组,其中的每一个元素对应屏幕上的 ...
- 11.2JS笔记
1.为什么要面向对象:JS一开始就是写网页特效,面向过程,作者发现这样的写不好,代码重复利用率太高,计算机内存消耗太大,网页性能很差,所以作者就受到java和c语言的影响,往面向对象对齐,JS天生有一 ...
- Oracle_高级功能(6) 分区
oracle分区表1.分区表: 当表中的数据量不断增大,查询数据的速度就会变慢,应用程序的性能就会下降,这时就应该考虑对表进行分区. 表进行分区后,逻辑上表仍然是一张完整的表,只是将表中的数据在物理上 ...