当前位置:网站首页>Opencn learning Day3
Opencn learning Day3
2022-07-22 15:51:00 【SKYWALKERS_ two thousand three hundred and ninety-seven】
Threshold operation
ret,dst = cv2.threshold(src,thresh,maxval,type)
src: Input diagram , Only single channel images can be input , Generally, grayscale image is used
dst: Output chart
thresh: threshold
maxval: When the pixel value exceeds the threshold ( Or less than the threshold , according to type To decide ), The value assigned to
type: The type of binarization operation , Contains the following 5 Type in the :
cv2.THRESH_BINARY: The part exceeding the threshold is taken as maxval( Maximum ), Otherwise take 0
cv2.THRESH_BINARY_INV:cv2.THRESH_BINARY The reversal of
cv2.THRESH_TRUNC: The part greater than the threshold value is set as the threshold value , Otherwise unchanged
cv2.THRESH_TOZERO: Parts greater than the threshold remain unchanged , Otherwise, it is set to 0
cv2.THRESH_TOZERO_INV:cv2.THRESH_TOZERO The reversal of
import cv2
image = cv2.imread('sample.jpg')
img_Gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
ret1,thresh1 = cv2.threshold(img_Gray, 127, 255, cv2.THRESH_BINARY)
ret2,thresh2 = cv2.threshold(img_Gray, 127, 255, cv2.THRESH_BINARY_INV)
ret3,thresh3 = cv2.threshold(img_Gray, 127, 255, cv2.THRESH_TRUNC)
ret4,thresh4 = cv2.threshold(img_Gray, 127, 255, cv2.THRESH_TOZERO)
ret5,thresh5 = cv2.threshold(img_Gray, 127, 255, cv2.THRESH_TOZERO_INV)
title = ['Original Image', 'BINARY', 'BINARY_INV', 'TRUNC', 'TOZERO', 'THRESH_TOZERO_INV']
images = [image, thresh1,thresh2, thresh3, thresh4, thresh5]
for i in range(6):
cv2.imshow(title[i],images[i])
cv2.waitKey(0)
cv2.destroyAllWindows()
边栏推荐
猜你喜欢
查日志只有ES好使?那是你没这样用Clickhouse……
Information system project manager must recite the core examination site (48) selection of contract type
Wechat applet realizes PDF preview function - pdf.js (including source code analysis)
Statistics, calculate the data ratio of each department in SQL
[C language - program compilation] how does the line by line code get to an executable program step by step?
Ouu probiotics intensive cultivation of gastrointestinal health, award-winning tmall international Micro Ecological Innovation Conference
码蹄集 - MT3182 - 填矩阵
Chapter 3 - creating and maintaining MySQL data tables
Can you still find records in browser traceless browsing, and how to turn on traceless mode
EACCES: permission denied, unlink ‘/usr/local/bin/code‘
随机推荐
信息系统项目管理师必背核心考点(四十八)合同类型的选择
JS高级 之 ES6 实现继承
Pull daily activities, use cloud functions to send wechat applet subscription messages
认识垃圾回收
【一起学Rust】Rust学习前准备——注释和格式化输出
TiDB中规划的集群包括6个DB,3个pd,3个kv,应用去连的时候,是连哪个地址?
EACCES: permission denied, unlink ‘/usr/local/bin/code‘
浏览器无痕浏览还能查到记录吗,如何开启无痕模式
C语言力扣第38题之外观数列。三种方法(遍历法、递归法与狼灭法)
单调栈框架
Can you still find records in browser traceless browsing, and how to turn on traceless mode
C language question bank part.1
Enregistrer un résumé de la mesure de pression jmeter
The interview transcript of sister Juan is updated daily, Day1
Wechat applet realizes PDF preview function - pdf.js (including source code analysis)
Redis high availability principle master-slave sentinel cluster
img.shape[-2:]/len(img.shape[-2:]):GeneralizedRCNN:original_ image_ Torch in sizes_ assert
Autocomplete (autocomplete)
C语言实现在屏幕上打印特定的*星号图案
ROS学习(28)Web GUI