`
cakin24
  • 浏览: 1334001 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

图像处理模块ndimage

 
阅读更多

一 原始图像 

1 代码
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. plt.imshow(face)#绘制测试图像
  7. plt.show()#原始图像
2 运行结果


 
 
二 高斯滤波
1 代码
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. blurred_face = ndimage.gaussian_filter(face, sigma=7)#高斯滤波
  7. plt.imshow(blurred_face)
  8. plt.show()
2 运行结果


 
 
三 边缘锐化处理
1代码
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. blurred_face1 = ndimage.gaussian_filter(face, sigma=1)#边缘锐化
  7. blurred_face3 = ndimage.gaussian_filter(face, sigma=3)
  8. sharp_face = blurred_face3 +6*(blurred_face3-blurred_face1)
  9. plt.imshow(sharp_face)
  10. plt.show()
2运行结果


 
 
四 中值滤波 
1 代码
  1. from scipy import misc
  2. from scipy import ndimage
  3. import matplotlib.pyplot as plt
  4. face = misc.face()#face是测试图像之一
  5. plt.figure()#创建图形
  6. median_face = ndimage.median_filter(face,7)#中值滤波
  7. plt.imshow(median_face)
  8. plt.show()
2 运行结果


 
  • 大小: 400.3 KB
  • 大小: 148.4 KB
  • 大小: 496.1 KB
  • 大小: 298 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics