【图像算法|OpenCV Threshold ( Python , C++ )】本系列主要为learn opencv的翻译和学习,整理。
参考:https://www.learnopencv.com/opencv-threshold-python-cpp/
——————————————————————————————————————
阈值分割: 1、Binary Threshold
原理:
if src(x,y) > thresh
dst(x,y) = maxValue
else
dst(x,y) = 0
函数:
cv2.threshold(src, thresh, maxValue, cv2.THRESH_BINARY);
python 代码
import cv2
src = https://www.it610.com/article/cv2.imread(“threshold.png”, cv2.IMREAD_GRAYSCALE)
thresh = 5
maxValue = https://www.it610.com/article/255
th, dst = cv2.threshold(src, thresh, maxValue, cv2.THRESH_BINARY);
2、 Inverse Binary Threshold
原理:
if src(x,y) > thresh
dst(x,y) = 0
else
dst(x,y) = maxValue
函数:
cv2.threshold(src, thresh, maxValue, cv2.THRESH_BINARY_INV)
3、Truncate Thresholding
原理:
if src(x,y) > thresh
dst(x,y) = thresh
else
dst(x,y) =src(x,y)
函数:
cv2.threshold(src, thresh, maxValue, cv2.THRESH_TRUNC)
4、Threshold to Zero
原理:
if src(x,y) > thresh
dst(x,y) = src(x,y)
else
dst(x,y) =0
函数:
cv2.threshold(src, thresh, maxValue, cv2.THRESH_TOZERO)
5、Inverted Threshold to Zero
原理:
if src(x,y) > thresh
dst(x,y) = 0
else
dst(x,y) =src(x,y)
函数:
cv2.threshold(src, thresh, maxValue, cv2.THRESH_TOZERO_INV)
推荐阅读
- 推荐系统论文进阶|CTR预估 论文精读(十一)--Deep Interest Evolution Network(DIEN)
- Python专栏|数据分析的常规流程
- Python|Win10下 Python开发环境搭建(PyCharm + Anaconda) && 环境变量配置 && 常用工具安装配置
- Python绘制小红花
- Pytorch学习|sklearn-SVM 模型保存、交叉验证与网格搜索
- OpenCV|OpenCV-Python实战(18)——深度学习简介与入门示例
- python|8. 文件系统——文件的删除、移动、复制过程以及链接文件
- 爬虫|若想拿下爬虫大单,怎能不会逆向爬虫,价值过万的逆向爬虫教程限时分享
- 分布式|《Python3网络爬虫开发实战(第二版)》内容介绍
- java|微软认真聆听了开源 .NET 开发社区的炮轰( 通过CLI 支持 Hot Reload 功能)