Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze cv2.copyMakeBorder

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to analyze cv2.copyMakeBorder, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

When an image is involved in convolution operation, 0 filling is often used. 0 filling is a special edge filling. CopyMakeBorder () function is used in opencv-python library, which has many filling methods.

Original picture:

Fill it with cv2.BORDER_REPLICATE, repeat the last pixel, code, and effect:

Img2 = cv2.copyMakeBorder (img1,200,200,200,200,cv2.BORDER_REPLICATE) # adjust drawing size plt.figure (figsize= (5)) plt.imshow (img2,interpolation='bicubic')

Filled with cv2.BORDER_REFLECT, a mirror image of the boundary element:

Img3 = cv2.copyMakeBorder (img1,200,200,200,200,cv2.BORDER_REFLECT)

Populate with cv2.BORDER_REFLECT_101, similar to cv2.BORDER_REFLECT:

Img3 = cv2.copyMakeBorder (img1,200,200,200,200,cv2.BORDER_REFLECT_101)

You can't see much difference with the naked eye, but if you make a difference between the two images, you can see that they are still different:

Plt.imshow (img4-img3,interpolation='bicubic')

If there is any difference, you can tell me what you know.

Fill with cv2.BORDER_WRAP:

Img5 = cv2.copyMakeBorder (img1,200,200,200,200,cv2.BORDER_WRAP)

Fill it with cv2.BORDER_CONSTANT and add a boundary of the specified value, which is black by default:

Img6 = cv2.copyMakeBorder (img1,10,10,10,10,cv2.BORDER_CONSTANT) # add a red border # RED = [255pj0pl 0] # img6 = cv2.copyMakeBorder (img1,10,10,10,10,cv2.BORDER_CONSTANT,value=RED)

The answer to the question on how to analyze cv2.copyMakeBorder is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report