Python|OpenCV-How to add borders to target images (7)

Preface

This article is the seventh in this column. I will continue to share the practical knowledge of OpenCV computer vision later, so remember to pay attention.

When using opencv to process images, it is inevitable to perform some operations on some specific areas of the image. For example, you want to create a border around the target image. To put it simply, it is to fill in a thick line frame around the picture. The specific effect is as shown in the figure below:

Around the target image, a custom color area is filled to surround the image. So how does OpenCV implement this requirement? Without further ado, let’s go straight to the text. (complete code attached)

text

Before we begin, we must first familiarize ourselves with the usage of the function cv.copyMakeBorder() . The cv.copyMakeBorder() function here is also the focus of this article.

It needs to be added here that cv.copyMakeBorder() has a very wide range of applications in convolution operations and zero padding. Interested students can check relevant information. The author will discuss it here

Guess you like

Origin blog.csdn.net/Leexin_love_Ling/article/details/133499622