In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what the cv2.warpAffine parameters are, and the editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
WarpAffine: it means affine change. The official parameters are:
Cv2.warpAffine (src, M, dsize [, dst [, flags [, borderMode [, borderValue]) → dst
Where:
Src-enter the image.
M-transformation matrix.
Dsize-the size of the output image.
Flags-combination of interpolation methods (int type! )
BorderMode-Border Pixel Mode (int type! )
BorderValue-(key point! The boundary fill value; by default, it is 0
Of the above parameters:
M, as an affine transformation matrix, generally reflects the relationship between translation or rotation, and is a 2 × 3 transformation matrix of InputArray type.
Flages represents interpolation method. Default is flags=cv2.INTER_LINEAR, which represents linear interpolation.
In addition: cv2.INTER_NEAREST (nearest neighbor interpolation)
Cv2.INTER_AREA (region interpolation)
Cv2.INTER_CUBIC (cubic Spline interpolation)
Cv2.INTER_LANCZOS4 (Lanczos interpolation)
In daily affine transformation, when only the first three parameters are set, such as cv2.warpAffine (img,M, (rows,cols)), the basic affine transformation effect can be achieved, but the "black edge" phenomenon can occur, as shown in the figure:
This often causes a lot of trouble to the subsequent processing, the sixth parameter can choose the color of the fill, the default is black. The parameter for setting warpAffine in python is different from that in C++. You must specify the name of the parameter, as shown below:
In C++:
WarpAffine (src,img,M,Size (aforme b), 1meme 0meme Scalar (255255255))
In python:
Cv2.warpAffine (img,M, (rows,cols), flags=cv2.INTER_,borderMode=cv2.BORDER_REFLECT,borderValue= (255255255))
One advantage in python is that you don't have to set it sequentially, but simply specify the parameters you set. For example, fill the boundary area of the above image with white:
Cv2.warpAffine (img,M, (lengh,lengh), borderValue= (255255255))
Effect picture:
This is the end of this article on "what are cv2.warpAffine parameters?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.