用python-opencv给图像添加椒盐噪音
感谢:https://blog.csdn.net/saltriver/article/details/78882669
import cv2
import numpy as np
from matplotlib import pyplot as plt
peppers = cv2.imread('4.png',0)row, column = peppers.shapenoise_salt = np.random.randint(0,256,(row,column))
noise_pepper = np.random.randint(0,256,(row,column))rand = 0.05noise_salt = np.where(noise_salt<rand*256,255,0)
noise_pepper = np.where(noise_pepper<rand*256,-255,0)peppers.astype("float")
noise_salt.astype("float")
noise_pepper.astype("float")
salt = peppers
salt = peppers+noise_salt
salt = salt+noise_pepper
img = np.where(salt>255,255,salt)
img = np.where(salt<0,0,salt)
plt.subplot(121),plt.imshow(peppers),plt.title('origin')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(img),plt.title('noise')
plt.xticks([]), plt.yticks([])
plt.show()
效果:
用python-opencv给图像添加椒盐噪音相关推荐
- Python+OpenCV:图像修复(Image Inpainting)
Python+OpenCV:图像修复(Image Inpainting) 理论 Most of you will have some old degraded photos at your home ...
- Python+OpenCV:图像二进制鲁棒独立基本特征(BRIEF, Binary Robust Independent Elementary Features)
Python+OpenCV:图像二进制鲁棒独立基本特征(BRIEF, Binary Robust Independent Elementary Features) 理论 We know SIFT us ...
- Python+OpenCV:图像快速角点检测算法(FAST Algorithm for Corner Detection)
Python+OpenCV:图像快速角点检测算法(FAST Algorithm for Corner Detection) 理论 Feature Detection using FAST Select ...
- Python+OpenCV:图像Shi-Tomasi角点检测器
Python+OpenCV:图像Shi-Tomasi角点检测器 理论 The scoring function in Harris Corner Detector was given by: Inst ...
- Python+OpenCV:图像Harris角点检测(Harris Corner Detection)
Python+OpenCV:图像Harris角点检测(Harris Corner Detection) 理论 corners are regions in the image with large v ...
- Python+OpenCV:图像对比度受限自适应直方图均衡化(CLAHE, Contrast Limited Adaptive Histogram Equalization)
Python+OpenCV:图像对比度受限自适应直方图均衡化(CLAHE, Contrast Limited Adaptive Histogram Equalization) ############ ...
- Python+OpenCV:图像轮廓
Python+OpenCV:图像轮廓 轮廓是什么? 轮廓可以简单地解释为一条连接所有连续点(沿边界)的曲线,具有相同的颜色和强度. 轮廓线是形状分析.目标检测和识别的重要工具. 为了获得更好的精度,可 ...
- Python+OpenCV:图像金字塔
Python+OpenCV:图像金字塔 理论 通常情况下,我们使用固定大小的图像.但在某些情况下,我们需要处理(相同的)不同分辨率的图像. 例如,当搜索图像中的某些东西时,比如脸,我们不确定该物体在图 ...
- Python+OpenCV:图像梯度
Python+OpenCV:图像梯度(Image Gradients) 理论 OpenCV提供了三种类型的梯度滤波器或高通滤波器,Sobel, Scharr和Laplacian. 1. Sobel和S ...
最新文章
- PHP-Ajax跨域解决方案
- 关于ssh国际化的记录
- centos 升级curl版本
- 怎么把python解释器配置在pycharm中_在PyCharm中配置项目(三):配置Python解释器...
- 任务管理平台_软件品质评测系统任务分发管理平台
- 一个worker thread服务一个客户端
- c/c++头文件之string.h、cstring与string的区别
- AcWing 1738. 蹄球(特殊基环树)
- 具体数学-第6课(下降阶乘幂)
- jquery几种常用框架比较
- GNS3下载安装和使用、本地主机虚拟网卡消失解决方案以及环回网卡添加与测试
- Qt编写Modbus从机程序
- Thinkphp 5.0 仿百度糯米开发多商家电商平台
- web前端不用怕,外卖平台的项目开发流程,大全!!
- adb 禁止app联网_通过ADB启用和禁用系统应用
- QDialog添加最大化最小化按钮
- C语言-报数出圈问题(链表实现)
- 基于Java web的网上商城系统
- Fedora 29 添加 惠普打印机 Smart Tank 531
- Sherlock and His Girlfriend