当前位置:网站首页>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 .
边栏推荐
- Exception class_ Log frame
- CGR 21 (D,E,F)
- Mathematical modeling for war preparation 34-bp neural network prediction 2
- 观测云与 TDengine 达成深度合作,优化企业上云体验
- 荣盛生物冲刺科创板:拟募资12.5亿 年营收2.6亿
- Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan
- HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
- simpleITK读取nii遇到ITK only supports orthonormal direction cosines的错误
- I implement "stack" with C I
- MicroBlaze serial port learning · 2
猜你喜欢

【微信小程序】小程序的宿主环境

go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)

RT thread heap size Setting
MySQL开放远程连接权限的两种方法

数据挖掘知识点整理(期末复习版)

Mathematical modeling for war preparation 33- grey prediction model 2

The inspiration from infant cognitive learning may be the key to the next generation of unsupervised machine learning

After 15 years of working on 21 types of hardware, where is Google?

CVPR 2022 - Tesla AI proposed: generalized pedestrian re recognition based on graph sampling depth metric learning

halcon知识:区域专题【07】
随机推荐
【机器学习】K-means聚类分析
Eight basic sorting (detailed explanation)
24:第三章:开发通行证服务:7:自定义异常(来表征程序中出现的错误);创建GraceExceptionHandler来全局统一处理异常(根据异常信息,构建对应的API统一返回对象的,JSON数据);
Lambda表达式_Stream流_File类
php7.3 centos7.9安装sqlserver扩展
为了使远程工作不受影响,我写了一个内部的聊天室 | 社区征文
Talk about telecommuting | community essay solicitation
go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
Lambda expression_ Stream stream_ File class
招标公告:深圳市财政局数据库异地灾备项目
Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan
OpenCV中LineTypes各枚举值(LINE_4 、LINE_8 、LINE_AA )的含义
dart:字符串replace相关的方法解决替换字符
Niuke: how many different binary search trees are there
The inspiration from infant cognitive learning may be the key to the next generation of unsupervised machine learning
中航无人机科创板上市:市值385亿 拳头产品是翼龙无人机
[Verilog basics] octal and hexadecimal representation of decimal negative numbers
2020 Blue Bridge Cup group B - move bricks - (greedy sorting +01 backpack)
Observation cloud reached in-depth cooperation with tdengine to optimize enterprise cloud experience
[BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入