当前位置:网站首页>The meaning of linetypes enumeration values (line_4, line_8, line_aa) in opencv
The meaning of linetypes enumeration values (line_4, line_8, line_aa) in opencv
2022-06-30 16:51:00 【Haohong image algorithm】
stay OpenCV Almost all the functions related to drawing in this LineTypes Parameter settings . Let's say functions line()、 function putText()、 function drawContours()、 function rectangle() etc. .
stay OpenCV4.1.2 In the official documents of ,LineTypes There are the following enumeration values :
From this we can see that , There are four enumerated values , Respectively FILLED 、LINE_4 、LINE_8 、LINE_AA .
among FILLED There is no explanation for , This indicates that the enumeration value should be useless .
Let's introduce LINE_4 、LINE_8 、LINE_AA The meaning of .
These values are used to determine the line generation algorithm . We know that a line segment is actually composed of many pixels . Take drawing line segments as an example , When the two endpoints of the line segment are determined , In fact, you can determine the coordinates of those points in the middle of the line segment . So how to calculate the coordinates of these points in the middle ? That is calculated by the relevant algorithm .
stay OpenCV We can use LINE_4 、LINE_8 、LINE_AA To specify which algorithm is used to calculate the coordinates of these points in the middle .
LINE_4 Represents the pixel points on the line segment calculated by the algorithm used , There are only four directions between two adjacent points .
LINE_8 Represents the pixel points on the line segment calculated by the algorithm used , There are only eight directions between two adjacent points .
LINE_AA Represents the pixel points on the line segment calculated by the algorithm used , There are more than eight directions between two adjacent points , For example, sixteen 、 Thirty two or something . How many , You have to look at the source code of the algorithm ,
LINE_AA In the above explanation is “antialiased line”, It means anti huge tooth line .LINE_4 and LINE_8 It belongs to the huge tooth line , Why? LINE_4 and LINE_8 It belongs to the huge tooth line ? Because their direction is very limited ,LINE_8 There are eight directions ,LINE_4 There are only four directions . Limited directional resolution , The drawn lines naturally look like huge teeth .
Be careful : To distinguish four connected domains and eight connected domains from the LINE_4 and LINE_8 And difference . The four pixels of a pixel are called its four connected regions , One pixel 、 Next 、 Left 、 Right 、 The northwest 、 The northeast 、 southwest 、 The southeast pixel is called its eight connected region . obviously , If we want to expand the number of angles formed by a pixel and its adjacent points , Then we have to expand Dalian Tongyu , For example, we can call the following point P Of 5×5-1=24 Connected domain , It's just P Point and 24 The points in a connected domain are not necessarily connected .
Next , Look at a sample code , To experience these kinds of LineTypes The difference in effect .
# Blogger WeChat /QQ 2487872782
# If you have any questions, you can contact the blogger
# If you need image processing development, please also contact the blogger
# Image processing technology exchange QQ Group 271891601
import cv2
import numpy as np
str1 = 'WR'
thick = 3
Scale = 6
img_LINE_4 = np.zeros((300, 300, 3), dtype='uint8')
cv2.putText(
img=img_LINE_4,
text=str1,
org=(20, 150),
fontFace=cv2.FONT_HERSHEY_SIMPLEX,
fontScale=Scale,
color=(0, 255, 0),
thickness=thick,
lineType=cv2.LINE_4)
cv2.imshow('LINE_4', img_LINE_4)
img_LINE_8 = np.zeros((300, 300, 3), dtype='uint8')
cv2.putText(
img=img_LINE_8,
text=str1,
org=(20, 150),
fontFace=cv2.FONT_HERSHEY_SIMPLEX,
fontScale=Scale,
color=(0, 255, 0),
thickness=thick,
lineType=cv2.LINE_8)
cv2.imshow('LINE_8', img_LINE_8)
img_LINE_AA = np.zeros((300, 300, 3), dtype='uint8')
cv2.putText(
img=img_LINE_AA,
text=str1,
org=(20, 150),
fontFace=cv2.FONT_HERSHEY_SIMPLEX,
fontScale=Scale,
color=(0, 255, 0),
thickness=thick,
lineType=cv2.LINE_AA)
cv2.imshow('LINE_AA', img_LINE_AA)
cv2.waitKey(0)
cv2.destroyAllWindows()
The operation results are as follows :
From the running results, we can see that ,LINE_4 and LINE_8 Not much difference , But you can clearly feel LINE_AA Than LINE_4 and LINE_8 Much smoother , That is, good anti aliasing performance .
边栏推荐
- Hologres shared cluster helps Taobao subscribe to the extreme refined operation
- 2022 Blue Bridge Cup group B - expense reimbursement - (linear dp| status DP)
- 华为帐号多端协同,打造美好互联生活
- 荣盛生物冲刺科创板:拟募资12.5亿 年营收2.6亿
- I implement "stack" with C I
- In order to make remote work unaffected, I wrote an internal chat room | community essay
- Explain in detail the use of for loop, break and continue in go language
- 招标公告:2022年台州联通Oracle一体机和数据库维保服务项目
- On July 2, I invited you to TD Hero online conference
- Niuke: how many different binary search trees are there
猜你喜欢

微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”

荣盛生物冲刺科创板:拟募资12.5亿 年营收2.6亿

中国传奇教授李泽湘,正在批量制造独角兽

备战数学建模35-时间序列预测模型

Mathematical modeling for war preparation 36 time series model 2
![[Verilog basics] summary of some concepts about clock signals (clock setup/hold, clock tree, clock skew, clock latency, clock transition..)](/img/54/fd7541dae4aad7e4216bcaabbb146b.png)
[Verilog basics] summary of some concepts about clock signals (clock setup/hold, clock tree, clock skew, clock latency, clock transition..)

24:第三章:开发通行证服务:7:自定义异常(来表征程序中出现的错误);创建GraceExceptionHandler来全局统一处理异常(根据异常信息,构建对应的API统一返回对象的,JSON数据);

On July 2, I invited you to TD Hero online conference
![[activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!](/img/cf/6fc5f7cafbdc5e165eb119b9b41cd9.jpg)
[activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!

I 用c I 实现“栈”
随机推荐
Raft介绍
I implement "stack" with C I
思源笔记:能否提供页面内折叠所有标题的快捷键?
AVIC UAV technology innovation board is listed: the fist product with a market value of 38.5 billion is pterodactyl UAV
备战数学建模36-时间序列模型2
Halcon knowledge: regional topics [07]
After 15 years of working on 21 types of hardware, where is Google?
牛客网:乘积为正数的最长连续子数组
Exception class_ Log frame
Rong Lianyun launched rphone based on Tongxin UOS to create a new ecology of localization contact center
Niuke network: longest continuous subarray with positive product
香港回归25周年 香港故宫博物馆正式开放成文化新地标
Halcon knowledge: matrix topic [02]
Deep learning - (2) several common loss functions
OpenCV中LineTypes各枚举值(LINE_4 、LINE_8 、LINE_AA )的含义
快照和备份
居家办公浅谈远程协助快速提效心得 | 社区征文
Cesium-1.72 learning (add points, lines, cubes, etc.)
Additional: (not written yet, don't look at ~ ~ ~) webmvcconfigurer interface;
[machine learning] K-means clustering analysis