当前位置:网站首页>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 .
边栏推荐
- 聊聊远程办公那些事儿 | 社区征文
- 更多龙蜥自研特性!生产可用的 Anolis OS 8.6 正式发布
- Two methods for MySQL to open remote connection permission
- 思源笔记:能否提供页面内折叠所有标题的快捷键?
- 腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
- RT-Thread 堆區大小設置
- [activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!
- Eight basic sorting (detailed explanation)
- 删除有序数组中的重复项 II[双指针--多情况统一]
- [Verilog quick start of Niuke online question series] ~ bit splitting and operation
猜你喜欢

容联云首发基于统信UOS的Rphone,打造国产化联络中心新生态

Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"

Mathematical modeling for war preparation 33- grey prediction model 2

猎头5万挖我去VC

ArcMap operation series: 80 plane to latitude and longitude 84

Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API

Installing jupyter notebook under Anaconda

【Verilog基础】关于Clock信号的一些概念总结(clock setup/hold、clock tree、clock skew、clock latency、clock transition..)

抖快B为啥做不好综艺

Mathematical modeling for war preparation 35 time series prediction model
随机推荐
容联云首发基于统信UOS的Rphone,打造国产化联络中心新生态
RTP sending PS stream zero copy scheme
JS Es5 can also create constants?
[Verilog basics] summary of some concepts about clock signals (clock setup/hold, clock tree, clock skew, clock latency, clock transition..)
RT-Thread 堆区大小设置
The image variables in the Halcon variable window are not displayed, and it is useless to restart the software and the computer
Yunhe enmo won the bid for Oracle maintenance project of Tianjin Binhai rural commercial bank in 2022-2023
Restartprocessifvisible process
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
【微信小程序】常用组件基本使用(view/scroll-view/swiper、text/rich-text、button/image)
八大基本排序(详解)
Go zero micro Service Practice Series (VIII. How to handle tens of thousands of order requests per second)
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
附加:(还没写,别看~~~)WebMvcConfigurer接口;
云和恩墨中标天津滨海农村商业银行2022-2023年度Oracle维保项目
RT thread heap size Setting
中国传奇教授李泽湘,正在批量制造独角兽
Installing jupyter notebook under Anaconda
云技能提升好伙伴,亚马逊云师兄今天正式营业
Halcon knowledge: regional topics [07]