Python图像处理模块ndimage用法实例分析

作者:cakincqm 时间:2023-09-08 16:52:26 

本文实例讲述了Python图像处理模块ndimage用法。分享给大家供大家参考,具体如下:

一 原始图像

1 代码


from scipy import misc
from scipy import ndimage
import matplotlib.pyplot as plt
face = misc.face()#face是测试图像之一
plt.figure()#创建图形
plt.imshow(face)#绘制测试图像
plt.show()#原始图像

2 运行结果

Python图像处理模块ndimage用法实例分析

二 高斯滤波

1 代码


from scipy import misc
from scipy import ndimage
import matplotlib.pyplot as plt
face = misc.face()#face是测试图像之一
plt.figure()#创建图形
blurred_face = ndimage.gaussian_filter(face, sigma=7)#高斯滤波
plt.imshow(blurred_face)
plt.show()

2 运行结果

Python图像处理模块ndimage用法实例分析

三 边缘锐化处理

1 代码


from scipy import misc
from scipy import ndimage
import matplotlib.pyplot as plt
face = misc.face()#face是测试图像之一
plt.figure()#创建图形
blurred_face1 = ndimage.gaussian_filter(face, sigma=1)#边缘锐化
blurred_face3 = ndimage.gaussian_filter(face, sigma=3)
sharp_face = blurred_face3 +6*(blurred_face3-blurred_face1)
plt.imshow(sharp_face)
plt.show()

2 运行结果

Python图像处理模块ndimage用法实例分析

四 中值滤波

1 代码


from scipy import misc
from scipy import ndimage
import matplotlib.pyplot as plt
face = misc.face()#face是测试图像之一
plt.figure()#创建图形
median_face = ndimage.median_filter(face,7)#中值滤波
plt.imshow(median_face)
plt.show()

2 运行结果

Python图像处理模块ndimage用法实例分析

希望本文所述对大家Python程序设计有所帮助。

来源:https://blog.csdn.net/chengqiuming/article/details/78601448

标签:Python,图像处理模块,ndimage
0
投稿

猜你喜欢

  • 利用Python将彩色图像转为灰度图像的两种方法

    2021-02-06 05:28:54
  • Flask核心机制之上下文源码剖析

    2022-07-29 18:23:28
  • ASP中双引号单引号和&连接符使用技巧

    2007-10-01 18:20:00
  • vue实现简单的登录弹出框

    2024-05-21 10:30:12
  • 微信小程序实现图片轮播及文件上传

    2023-09-05 00:12:52
  • Java实现数据库连接池简易教程

    2024-01-20 01:30:29
  • 使用python+Flask实现日志在web网页实时更新显示

    2021-03-15 10:16:30
  • 基于python实现聊天室程序

    2022-09-26 07:50:33
  • python 实现体质指数BMI计算

    2023-01-25 12:44:56
  • 远程过程调用RPC基本概念及实现原理

    2022-09-24 06:45:30
  • python不同版本的_new_不同点总结

    2023-09-21 15:36:45
  • GO语言基本数据类型总结

    2024-02-06 08:14:27
  • Python进度条的制作代码实例

    2022-01-01 23:17:34
  • 原生Js与jquery的多组处理, 仅展开一个区块的折叠效果

    2024-04-17 10:06:48
  • python实现跨年表白神器--你值得拥有

    2021-03-04 05:16:14
  • Pytest allure 命令行参数的使用

    2022-04-12 17:06:19
  • python mac下安装虚拟环境的图文教程

    2021-11-02 23:35:21
  • Python模块zipfile原理及使用方法详解

    2022-03-24 10:33:37
  • 解决Django数据库makemigrations有变化但是migrate时未变动问题

    2024-01-15 16:55:39
  • 最具创意的广告牌全集

    2007-09-21 19:54:00
  • asp之家 网络编程 m.aspxhome.com