Creating A WaterMark on Image using OpenCV with Source Code

Introduction:

We are now making watermarking images using OpenCV in Python in this project. Watermark is looking left Text/logo onto the image. This helps us to identify the actual developer of an artist. Watermarks are used to protect the copyright of the picture. watermarks sometimes work as branding & marketing for the company or as an individual.

A watermark is a logo, signature, text, or pattern that is intentionally onto different images and is used to protect the copyright of the photos & branding. The primary purpose of Watermarking is to promote a brand. After watermarking, a picture is too difficult to copy or use the original image without the company & developer’s permission. Before giving watermarking to the vision we have to OpenCV module install in your system. OpenCV is a python library that provides various features. it is easy to use and does not need any setup. Let’s understand this now open Your code editor.

Image before watermarking

How To Run The Code :

1. Open any python code editor and paste the code below
2. after that need to install the OpenCV python library
3.  open your command prompt and hit the command below
4. pip install OpenCV-python 
5. Click on the run and run the code

Source Code:

Get Discount on Top Educational Courses

Brand NameDiscount InformationCoupon Codes Link
Educative.io20% discount on Educative courses and plans
W3Schools20% discount on W3Schools courses
KodeKloud10% discount on KodeKloud courses and plans
GeeksforGeeks30% discount on GeeksforGeeks courses
Target Test Prep20% discount on Target Test Prep
Coding Ninjas₹5000 discount on Coding Ninjas courses
Skillshare40% discount on Skillshare
DataCamp50% discount on DataCamp
365 Data Science57% discount on 365 Data Science Plans
Get SmarterFlat 20% discount on Get Smarter courses
SmartKeedaFlat 40% discount on SmartKeeda courses
StackSocial20% discount on StackSocial courses
				
					# importing cv2

import cv2
  
# importing watermark that we are going to use & python file and image in same folder

logo = cv2.imread("logo.png")
  
# importing image on which we are going to apply watermark

img = cv2.imread("image1.png")
  

# height and width of the watermark
h_logo, w_logo, _ = logo.shape
  
# height and width of the image
h_img, w_img, _ = img.shape
  
# calculating coordinates of center
# calculating center, where we are going to 
# place our watermark
center_y = int(h_img/2)
center_x = int(w_img/2)
  
# calculating from top, bottom, right and left
top_y = center_y - int(h_logo/2)
left_x = center_x - int(w_logo/2)
bottom_y = top_y + h_logo
right_x = left_x + w_logo
  
# adding watermark to the image
destination = img[top_y:bottom_y, left_x:right_x]
result = cv2.addWeighted(destination, 1, logo, 0.5, 0)
  
# displaying and saving image
img[top_y:bottom_y, left_x:right_x] = result
cv2.imwrite("watermarked.jpg", img)
cv2.imshow("Watermarked Image", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
				
			

Output:

Find More Projects

Whack a Mole Game with HTML CSS And JavaScript Introduction Hello friends, you all are welcome to today’s beautiful and unique project. Today …

3D Car Driving Game Using Html CSS And JavaScript Introduction Hello friends, welcome to today’s new blog post. Today we have created …

Dice Rolling Game Using HTML CSS And JavaScript Introduction Hey coders, welcome to another new blog. In this article we’ll build a …

Crossey Road Game Clone Using HTML CSS And JavaScript Introduction This is our HTML code which sets up the basic structure of …

Memory Card Game Using HTML CSS And JavaScript Introduction Hello coders, welcome to another new blog. Today in this article we’ll learn …

sudoku game using html CSS and JavaScript Introduction Hello friends, you all are welcome to today’s beautiful project. Today we have made …

Get Huge Discounts
More Python Projects