Shahid Akhtar Khan has Published 216 Articles

OpenCV Python – How to draw a rectangle using Mouse Events?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 07:16:05

5K+ Views

There are different types of muse events such as left or right button click, mouse move, left button double click etc. A mouse event returns the coordinates (x, y) of the mouse event. To perform an action when an event happens we define a mouse callback function. We use ... Read More

How to flip an image in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 07:12:23

15K+ Views

In OpenCV, an image can be flipped using the function cv2.flip(). Using this function we can flip the image across X-axis, Y-axis and across both axes. It accepts a flag flipCode as an argument to flip the image across the axis. If the flipCode is set to 0, the ... Read More

How to access and modify pixel value in an image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 07:10:33

13K+ Views

To access a single pixel value in an image we can use indexing the same as we do to NumPy array indexing. We can use slicing to access a sequence of pixel values. To modify the pixel values we use the simple Python assignment operator ("="). Steps To access ... Read More

How to split an image into different color channels in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 07:08:26

7K+ Views

A color image consists of three color channels- Red, Green and Blue. These color channels can be split using cv2.split() function. Let's look at the steps to split an image into different color channels- Import the required library. In all the following examples, the required Python library is ... Read More

OpenCV Python – How to perform SQRBox filter operation on an image?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 07:04:51

241 Views

We can perform SQRBox Filter operation on an image using cv2.sqrBoxFilter(). It calculates the normalized sum of squares of the pixel values overlapping the filter. We use the following syntax for this method − cv2.sqrBoxFilter(img, ddepth, ksize, borderType) where, img is the input image, ddepth is the output image ... Read More

OpenCV Python – How to add borders to an image?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 07:02:40

1K+ Views

OpenCV provides the function cv2.copyMakeBorder() to add borders in images. To add border in an image, you could follow the steps given below − The first step is to import required libraries. In all below Python examples the required Python library is OpenCV. Make sure you have already installed ... Read More

OpenCV Python – How to find and draw extreme points of an object on an image?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 06:59:32

2K+ Views

To find and draw the extreme points of an object in the input image, we could follow the steps given below − The first step is to import required libraries. In all below Python examples the required Python library is OpenCV. Make sure you have already installed it. ... Read More

OpenCV Python – How to draw circles using Mouse Events?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 06:55:16

2K+ Views

There are different types of muse events such as left or right button click, mouse move, left button double click etc. OpenCV provides us with different types of mouse events such as cv2.EVENT_LBUTTONDOWN for mouse left button down, cv2.EVENT_RBUTTONDOWN for right button down, cv2.EVENT_LBUTTONDBLCLK for left button double click and ... Read More

How to approximate a contour shape in an image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 28-Sep-2022 12:50:30

5K+ Views

The function cv2.approxPolyDP() approximates a contour shape to another shape with less number of vertices. It accepts the following arguments − cnt − The array of the contour points. epsilon − Maximum distance from contour to approximated contour. A wise selection of epsilon is needed to get the correct ... Read More

How to compute the area and perimeter of an image contour using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 28-Sep-2022 12:42:42

11K+ Views

The contours of the objects in an image are very helpful to compute the area and perimeter of the image. A contour of an image is a curve joining all the continuous points along the boundary, having the same color or intensity. Contours are used for shape analysis and object ... Read More

Previous 1 ... 4 5 6 7 8 ... 22 Next
Advertisements