Color Quantization in an Image Using K-Means in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:54:13

3K+ Views

In the process of Color Quantization the number of colors used in an image is reduced. One reason to do so is to reduce the memory. Sometimes, some devices can produce only a limited number of colors. In these cases, color quantization is performed. We use cv2.kmeans() to apply k-means clustering for color quantization. Steps To implement color quantization in an image using K-means clustering, you could follow the steps given below − Import required libraries OpenCV and NumPy. Make sure you have already installed them. Read two input images using cv2.imread() method. Specify the full path of the ... Read More

Create Depth Map from Stereo Images in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:51:10

10K+ Views

A depth map can be created using stereo images. To construct a depth map from the stereo images, we find the disparities between the two images. For this we create an object of the StereoBM class using cv2.StereoBM_create() and compute the disparity using stereo.comput(). Where stereo is the created StereoBM object. Steps To create a depth map from the stereo images, you could follow the steps given below − Import the required libraries OpenCV, Matplotlib and NumPy. Make sure you have already installed them. Read two input images using cv2.imread()method as grayscale images. Specify the full path of ... Read More

Implement FLANN Based Feature Matching in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:49:01

5K+ Views

We implement feature matching between two images using Scale Invariant Feature Transform (SIFT) and FLANN (Fast Library for Approximate Nearest Neighbors). The SIFT is used to find the feature keypoints and descriptors. A FLANN based matcher with knn is used to match the descriptors in both images. We use cv2.FlannBasedMatcher() as the FLANN based matcher. Steps To implement feature matching between two images using the SIFT feature detector and FLANN based matcher, you could follow the steps given below: Import required libraries OpenCV, Matplotlib and NumPy. Make sure you have already installed them. Read two input images ... Read More

Implement Feature Matching Between Two Images Using SIFT in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:47:08

9K+ Views

We use Scale Invariant Feature Transform (SIFT) feature descriptor and Brute Force feature matcher to implement feature matching between two images. The SIFT is used to find the feature keypoints and descriptors in the images. A Brute Force matcher is used to match the descriptors in both images. Steps To implement feature matching between two images using the SIFT feature detector and Brute Force matcher, you could follow the steps given below − Import required libraries OpenCV, Matplotlib and NumPy. Make sure you have already installed them. Read two input images using cv2.imread() method as grayscale images. Specify the ... Read More

Match Key Points of Two Images Using ORB and BFMatcher in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:44:54

4K+ Views

To match the keypoints of two images, we use ORB (Oriented FAST and Rotated BRIEF) to detect and compute the feature keypoints and descriptors and Brute Force matcher to match the descriptors in both images. Steps To match keypoints of two images using the ORB feature detector and Brute Force matcher, you could follow the steps given below − Import the required libraries OpenCV, Matplotlib and NumPy. Make sure you have already installed them. Read two input images using cv2.imread() method as grayscale images. Specify the full path of the image. Initiate ORB object orb with default ... Read More

Blur Faces in an Image Using OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:42:14

3K+ Views

To blur faces in an image first we detect the faces using a haar cascade classifier. OpenCV provides us with different types of trained haarcascades for object detection. We use haarcascade_frontalface_alt.xml as a haarcascade xml file. To blur the face area, we apply the cv2.GaussianBlur(). How to Download Haarcascade? You can find different haarcascades following the GitHub website address − https://github.com/opencv/opencv/tree/master/data/haarcascades To download a haarcascade for face detection, click the haarcascade_frontalface_alt.xml file. Open it in raw format, right click and save. Steps You could follow the steps given below to blur faces in an image − Import ... Read More

Implement ORB Feature Detectors in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:39:38

4K+ Views

ORB (Oriented FAST and Rotated BRIEF) is a fusion of FAST keypoint detector and BRIEF descriptors with many changes to enhance the performance. To implement ORB feature detector and descriptors, you could follow the steps given below Import the required libraries OpenCV and NumPy. Make sure you have already installed them. Read the input image using cv2.imread() method. Specify the full path of the image. Convert the input image to grayscale image using cv2.cvtColor() method. Initiate the ORB object with default values using orb=cv2.ORB_create(). Detect and compute the feature keypoints 'kp' and descriptor 'des' in the ... Read More

Detect and Draw Fast Feature Points in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:37:14

3K+ Views

FAST (Features from Accelerated Segment Test) is a high speed corner detection algorithm. We use the FAST algorithm to detect features in the image. We first create a FAST object with cv2.FastFeatureDetector_create(). Then detect the feature points using fast.detect() where fast is the created FAST object. To draw featurepoints, we use cv2.drawKeypoints(). Steps To detect and draw feature points in the input image using the FAST feature detector, you could follow the steps given below Import the required libraries OpenCV and NumPy. Make sure you have already installed them. Read the input image using cv2.imread() method. Specify the full ... Read More

Detect and Draw Keypoints in an Image Using SIFT

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:34:36

6K+ Views

SIFT (Scale-Invariant Feature Transform ) is scale invariant feature descriptor. It detects keypoints in the image and computes its descriptors. We first create a SIFT object with cv2.SIFT_create(). Then detect the keypoints using sift.detect() where sift is the created SIFT object. To draw keypoints, we use cv2.drawKeypoints(). Steps To detect and draw keypoints in the input image using SIFT algorithm, you could follow the steps given below Import the required libraries OpenCVand NumPy. Make sure you have already installed them. Read the input image using cv2.imread() method. Specify the full path of the image. Convert the ... Read More

Perform Matrix Transformation in OpenCV Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 10:31:22

5K+ Views

The cv2.transform() function performs the matrix transformation of each element of the input array. We could apply this transformation directly on the image as the images are NumPy ndarrays in OpenCV. To use this function, we should first define a transformation matrix m. The number of channels in the output will be the same as the number of rows in the transformation matrix m. Steps To find matrix transform of an input image, you could follow the steps given below- Import the required libraries OpenCV and NumPy. Make sure you have already installed them. Read the input ... Read More

Advertisements