使用 OpenCV 对图像执行反向零阈值
在本程序中,我们将使用 OpenCV 对图像执行反向零阈值。阈值化是一种根据阈值更改每个像素值的过程。如果像素小于阈值,则赋予其某个值,如果大于阈值,则赋予其另一个值。在反向零阈值中,强度值大于阈值的像素设置为 0。
原始图像

算法
Step 1: Import cv2. Step 2: Define the threshold and max_val. Step 3: Pass these parameters in the cv2.threshold value and specify the type of thresholding you want to do. Step 4: Display the output.
示例代码
import cv2
image = cv2.imread('testimage.jpg')
threshold_value = 120
max_val = 255
ret, image = cv2.threshold(image, threshold_value, max_val, cv2.THRESH_TOZERO_INV)
cv2.imshow('InverseZeroThresholding', image)输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP