In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to carry out cv2.copyMakeBorder (). The editor thinks it is very practical, so I hope you can get something after reading this article. Let's take a look at it with the editor.
If you want to set a bounding box for your picture, like a picture frame, you can use the cv2.copyMakeBorder () function. However, it has also been applied in convolution operation, zero filling and so on, and can be used in some data augmentation operations.
Parameters.
Src: entered picture
Top, bottom, left, right: border width in the corresponding direction
BorderType: defines the type of border to add, which can be one of the following:
Cv2.BORDER_CONSTANT: the value of the added bounding box pixel is constant (an additional parameter is required)
Cv2.BORDER_REFLECT: the border pixels added will be specular reflections of boundary elements, similar to gfedcb | abcdefgh | gfedcba
Cv2.BORDER_REFLECT_101 or cv2.BORDER_DEFAULT: similar to the above, but with some slight differences, similar to gfedcb | abcdefgh | gfedcba
Cv2.BORDER_REPLICATE: use the most bounded pixel value instead, similar to aaaaaa | abcdefgh | hhhhhhh
Cv2.BORDER_WRAP: I don't know how to explain it. Just read it. Cdefgh | abcdefgh | abcdefg
Value: the constant value to be populated if borderType is cv2.BORDER_CONSTANT.
Instance img = cv2.imread ('testimg.png') img = cv2.resize (img, (256256)) cv2.imshow (' origin',img), cv2.waitKey (0), cv2.destroyAllWindows () replicate = cv2.copyMakeBorder (img,20,20,20,20,cv2.BORDER_REPLICATE) cv2.imshow ('replicate',replicate), cv2.waitKey (0), cv2.destroyAllWindows () constant = cv2.copyMakeBorder (img,20,20,20,20,cv2.BORDER_CONSTANT,value= (255255255) cv2.imshow (' constant',constant), cv2.waitKey (0)) Cv2.destroyAllWindows () reflect = cv2.copyMakeBorder (img,20,20,20,20,cv2.BORDER_REFLECT) cv2.imshow ('reflect',reflect), cv2.waitKey (0), cv2.destroyAllWindows () reflect101 = cv2.copyMakeBorder (img,20,20,20,20,cv2.BORDER_REFLECT_101) cv2.imshow (' reflect101',reflect101), cv2.waitKey (0), cv2.destroyAllWindows () wrap = cv2.copyMakeBorder (img,20,20,20,20,cv2.BORDER_WRAP) cv2.imshow ('wrap',wrap), cv2.waitKey (0), cv2.destroyAllWindows ()
The above is how to carry out cv2.copyMakeBorder (). The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.