Sign in

Image processing by using OpenCV in python

COMPUTER VISION

🔰TASK_4:

Task Description:

🔹Task 4.1:Create an image by yourself Using Python Code.

🔹Task 4.2:Take 2 images, crop some part of both images and swap them.

🔹Task 4.3:Take 2 images and combine them to form a single image. For example collage.

Lets know more about image processing by using OpenCV……..

💻IMAGE PROCESSING: Image processing deals with manipulation of digital images through a digital computer. Image processing focuses on developing a computer system that is able to perform processing on an image. The input of that system is a digital image and the system process that image using efficient algorithm and gives an image as an output.

◼Why we use image processing?

Image processing is a method to perform some operations on an image, to get an enhanced image or to extract some useful information from it. However, to get an optimized workflow and to avoid losing time, it is important to process images after the capture, in a post-processing step.

◼What is mean by Pixels?

Pixels are the small small box present in image .Technically it is an entry inside an array at a particular position of row and column. Each pixel consists of three colors namely, Red, Green, and Blue. Upon combining these different colors are formed. Multiple pixels together form a complete image.

◼What is OpenCV?

OpenCV is the huge open-source library for the computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even handwriting of a human. OpenCV-Python is a library of Python bindings designed to solve computer vision problem.

OpenCV-Python makes use of Numpy, which is a highly optimized library for numerical operations with a MATLAB-style syntax. All the OpenCV array structures are converted to and from Numpy arrays. This also makes it easier to integrate with other libraries that use Numpy such as Matplotlib.

The color code format is used in OpenCV is BGR(Blue Green Red).

Install OpenCV by using pip install OpenCV-python command.

To import the cv2 model use import cv2 command.

◼Now lets discuss some more command we used in task:

  1. img = cv2.imread(“pyimg.jpg”) = To read the image, use the imread() method of the cv2 module.
  2. cv2.imshow(‘Original Image’, img)=To display the image, you can use the imshow() method of cv2 module.
  3. cv2.waitKey()=The waitkey() functions take time as an argument in milliseconds as a delay for the window to close.

This are some commands we have to use.

Now lets move towards task:

🔹Task 4.1:

Write a code for creating image: Here i am creating two images.

This is 1st image
This is second image

🔹Task 4.2: Take two images and crop & swap it. Here I take images of two cats.

cat1
cat2

OUTPUT IS:

🔹Task 4.3:Here i use same images to collage it.

OUTPUT IS:

THANK YOU!!!