当前位置:网站首页>[200 opencv routines] 218 Multi line italic text watermark
[200 opencv routines] 218 Multi line italic text watermark
2022-07-04 09:51:00 【Xiaobai youcans】
OpenCV routine 200 piece General catalogue
【youcans Of OpenCV routine 200 piece 】218. Multi line oblique text watermark
8.1 Add multi line italic text watermark
A watermark is a sign superimposed on an image 、 Signature 、 Text or pattern , Used to protect the copyright of images .
First, add an image or text on the black background to make a watermark , Reuse cv.addWeight function , The watermark is added to the original image by overlapping and mixing .
The watermark pattern or text area can also be used as a mask , Use cv.add Function to modify the pixel value of the mask area , Realize adding the watermark to the original image .
routine A4.10: Add a watermark to the image
# A4.10 Add a watermark to the image
img = cv.imread("../images/imgLena.tif", 1) # Load the original image
h, w = img.shape[0], img.shape[1]
# # Generate watermark pattern
# logo = cv.imread("../images/logoXupt.png", 0) # load Logo
# logoResize = cv.resize(logo, (100,100)) # Adjust the size of the picture
# grayMark = np.zeros(img.shape[:2], np.uint8) # Watermark black background
# grayMark[10:110,10:110] = logoResize # Generate watermark pattern
# Generate text watermark
mark = np.zeros(img.shape[:2], np.uint8) # Black background
for i in range(h//100):
cv.putText(mark, "youcans2022", (50,70+100*i), cv.FONT_HERSHEY_SIMPLEX, 1.5, 255, 2)
MAR = cv.getRotationMatrix2D((w//2,h//2), 45, 1.0) # rotate 45 degree
grayMark = cv.warpAffine(mark, MAR, (w,h)) # Rotation transformation , The default is black fill
# Add a watermark to the image 1
markC3 = cv.merge([grayMark, grayMark, grayMark])
imgMark1 = cv.addWeighted(img, 1, markC3, 0.25, 0) # Weighted addition image fusion
# Add a watermark to the image 2
imgMark2 = cv.add(img, 64, mask=grayMark) # Use the watermark pattern as a mask
plt.figure(figsize=(9, 6))
plt.subplot(221), plt.title("original"), plt.axis('off')
plt.imshow(cv.cvtColor(img, cv.COLOR_BGR2RGB))
plt.subplot(222), plt.title("watermark"), plt.axis('off')
plt.imshow(cv.cvtColor(markC3, cv.COLOR_BGR2RGB))
plt.subplot(223), plt.title("watermark embedded"), plt.axis('off')
plt.imshow(cv.cvtColor(imgMark1, cv.COLOR_BGR2RGB))
plt.subplot(224), plt.title("watermark embedded"), plt.axis('off')
plt.imshow(cv.cvtColor(imgMark1, cv.COLOR_BGR2RGB))
plt.tight_layout()
plt.show()
【 At the end of this section 】
Copyright notice :
[email protected] Original works , Reprint must be marked with the original link :(https://blog.csdn.net/youcans/article/details/125506829)
Copyright 2022 youcans, XUPT
Crated:2022-6-28
217. Mouse interaction to obtain polygon area
218. Multi line oblique text watermark
边栏推荐
- Hands on deep learning (43) -- machine translation and its data construction
- PHP student achievement management system, the database uses mysql, including source code and database SQL files, with the login management function of students and teachers
- 2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
- C language pointer classic interview question - the first bullet
- System.currentTimeMillis() 和 System.nanoTime() 哪个更快?别用错了!
- Basic data types in golang
- 智能网关助力提高工业数据采集和利用
- 自动化的优点有哪些?
- C语言指针经典面试题——第一弹
- Explanation of for loop in golang
猜你喜欢
Pcl:: fromrosmsg alarm failed to find match for field 'intensity'
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
Summary of reasons for web side automation test failure
Dynamic memory management
el-table单选并隐藏全选框
Hands on deep learning (41) -- Deep recurrent neural network (deep RNN)
Devop basic command
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
2022-2028 global strain gauge pressure sensor industry research and trend analysis report
Leetcode (Sword finger offer) - 35 Replication of complex linked list
随机推荐
华为联机对战如何提升玩家匹配成功几率
Baidu R & D suffered Waterloo on three sides: I was stunned by the interviewer's set of combination punches on the spot
Hands on deep learning (33) -- style transfer
PHP is used to add, modify and delete movie information, which is divided into foreground management and background management. Foreground users can browse information and post messages, and backgroun
Qtreeview+ custom model implementation example
Exercise 7-3 store the numbers in the array in reverse order (20 points)
2022-2028 global seeder industry research and trend analysis report
自动化的优点有哪些?
QTreeView+自定义Model实现示例
Deadlock in channel
mmclassification 标注文件生成
Exercise 9-4 finding books (20 points)
Web端自动化测试失败原因汇总
Golang defer
Mmclassification annotation file generation
2022-2028 global probiotics industry research and trend analysis report
什么是 DevSecOps?2022 年的定义、流程、框架和最佳实践
Servlet基本原理与常见API方法的应用
Pcl:: fromrosmsg alarm failed to find match for field 'intensity'
Hands on deep learning (44) -- seq2seq principle and Implementation