Prasad Naik has Published 74 Articles

Reading and displaying images using OpenCV

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 08:00:05

1K+ Views

In this article, we will learn how to read and display images using the OpenCV library.OpenCV is a library of programming functions mainly aimed at real time computer vision. Before reading an image, make sure that the image is in the same directory as your program.AlgorithmStep 1: Import OpenCV. Step ... Read More

How to write an image to a file using OpenCV?

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:59:02

346 Views

In this program, we will write an image or save an image to a file using OpenCV.AlgorithmStep 1: Import cv2 Step 2: Read the image using opencv.imread() Step 3: Save the image using opencv.imwrite(filename, image)Example Codeimport cv2 import os image = cv2.imread('testimage.jpg') directory = r'C:\Users\prasa\Desktop' os.chdir(directory) cv2.imwrite('CAMERAMAN.jpg', image)OutputThis program will ... Read More

Converting an image from colour to grayscale using OpenCV

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:57:34

14K+ Views

In this program, we will change the color scheme of an image from rgb to grayscaleAlgorithmStep 1: Import OpenCV. Step 2: Read the original image using imread(). Step 3: Convert to grayscale using cv2.cvtcolor() function.Example Codeimport cv2 image = cv2.imread('colourful.jpg') cv2.imshow('Original', image) grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.imshow('Grayscale', grayscale)OutputOriginal Image:Grayscale Image:Read More

Draw a filled polygon using the OpenCV function fillPoly()

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:56:53

7K+ Views

In this program, we will draw a filled polygon using the opencv function fillPoly(). The function takes in an image and the endpoints of the polygon.AlgorithmStep 1: Import cv2 and numpy. Step 2: Define the endpoints. Step 3: Define the image using zeros. Step 4: Draw the polygon using the ... Read More

Draw a circle using OpenCV function circle()

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:56:11

788 Views

In this article, we will draw a circle on an image using the OpenCV function circle().Original ImageAlgorithmStep 1: Import OpenCV. Step 2: Define the radius of circle. Step 3: Define the center coordinates of the circle. Step 4: Define the color of the circle. Step 5: Define the thickness. Step ... Read More

Draw rectangle on an image using OpenCV

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:54:32

4K+ Views

In this program, we will draw a rectangle using the OpenCV function rectangle(). This function takes some parameters like starting coordinates, ending coordinates, color and thickness and the image itself.Original ImageAlgorithmStep 1: Import cv2. Step 2: Read the image using imread(). Step 3: Define the starting coordinates. Step 5: Define ... Read More

Draw an ellipse on an image using OpenCV

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:52:58

655 Views

In this program, we will draw an ellipse on an image in using the OpenCV library. We will use the OpenCV function ellipse() for the same.Original ImageAlgorithmStep 1: Import cv2. Step 2: Read the image using imread(). Step 3: Set the center coordinates. Step 4: Set the axes length. Step ... Read More

Blurring an image using the OpenCV function Gaussian Blur()

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:50:47

382 Views

In this program, will blur an image using the openCV function GaussianBlur(). Gaussian blur is the process of blurring an image using the gaussian function. It is widely used in graphics software to remove noise from the image and reduce detail.AlgorithmStep 1: Import cv2. Step 2: Read the original image. ... Read More

Blurring an image using the OpenCV function blur()

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:50:10

311 Views

In this program, we will blur an image using the opencv function blur().AlgorithmStep 1: Import OpenCV. Step 2: Import the image. Step 3: Set the kernel size. Step 4: Call the blur() function and pass the image and kernel size as parameters. Step 5: Display the results.Original ImageExample Codeimport cv2 ... Read More

Display text on an OpenCV window by using the function putText()

Prasad Naik

Prasad Naik

Updated on 17-Mar-2021 07:49:09

4K+ Views

In this program, we will write text on an image using the opencv function putText(). This function takes in the image, font, coordinates of where to put the text, color, thickness, etc.Original ImageAlgorithmStep 1: Import cv2 Step 2: Define the parameters for the puttext( ) function. Step 3: Pass the ... Read More

Advertisements