Shahid Akhtar Khan has Published 216 Articles

How to perform image translation using OpenCV in Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:51:32

2K+ Views

Shifting the image location in a particular direction is referred to as Image Translation. To perform image translation, we should first understand what is a translation matrix and how to define it using OpenCV and NumPy. If we want to make a translation in (x, y) direction, let it be ... Read More

How to perform Otsu's thresholding on an image using Python OpenCV?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:45:23

3K+ Views

Otsu’s thresholding is a kind of thresholding technique. There are other types of thresholding techniques such as simple thresholding and adaptive thresholding. The simple thresholding technique uses a global threshold value while the adaptive thresholding technique uses different threshold values for different regions. Otsu’s thresholding technique uses a global threshold ... Read More

How to perform adaptive mean and gaussian thresholding of an image using Python OpenCV?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:38:50

1K+ Views

Adaptive thresholding is a kind of thresholding technique. There are other types of thresholding techniques such as simple thresholding that uses a global threshold value. But using a global threshold value is not a good idea for an image having different lighting conditions in different areas. Adaptive thresholding calculates the ... Read More

How to perform different simple thresholding of an image using Python OpenCV?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:32:46

698 Views

In simple thresholding, we define a threshold value and if a pixel value is greater than a threshold value, it is assigned a value (say 255), else it is assigned another value (say 0). A simple thresholding can be applied using the function cv2.threshold(). It accepts four arguments− the source ... Read More

How to access image properties in OpenCV using Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:26:07

3K+ Views

An image in OpenCV is a NumPy array. We can access the image properties using the attributes of the numpy array. We access the following image properties for the input image img − Image Type − data structure of the mage. Image in OpenCV is numpy.ndarray. We can access ... Read More

How to find the HSV values of a color using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:22:11

11K+ Views

To find the HSV values of a color, we can use color space conversion from BGR to HSV. First we define the color value in BGR format as numpy.ndarray and then convert it to HSV space. We can also find the lower and upper limits of HSV value as [H-10, ... Read More

How to create a trackbar as the HSV color palette using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:12:57

1K+ Views

To create trackbars as the HSV (Hue, Saturation and Value) color palette in OpenCV, we apply two different functions. These functions are cv2.reateTrackbar() and cv2.getTrackbarPos() The cv2.reateTrackbar() function is used to create a trackbar, while cv2.getTrackbarPos() function is used to access the value of the selected trackbar position. Using ... Read More

How to create a trackbar as the RGB color palette using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 12:05:22

1K+ Views

In OpenCV, a trackbar can be created using cv2.reateTrackbar() function. To access the value of the selected trackbar position, we use cv2.getTrackbarPos() function. Using these two functions, we create a window that contains the trackbars for R, G, B colors and a color window to display the selected color. By ... Read More

How to convert an RGB image to HSV image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 11:57:39

18K+ Views

An RGB (colored) image has three channels, Red, Blue and Green. A colored image in OpenCV has a shape in [H, W, C] format, where H, W, and C are image height, width and number of channels. All three channels have a value range between 0 and 255. The HSV ... Read More

How to create a black image and a white image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 27-Sep-2022 11:54:58

17K+ Views

To create a black image, we could use the np.zeros() method. It creates a numpy n-dimensional array of given size with all elements as 0. As all elements are zero, when we display it using cv2.imshow() or plt.imshow() functions, it displays a balck image. To create a white image, we ... Read More

Advertisements