Shahid Akhtar Khan has Published 217 Articles

How to detect and draw FAST feature points in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 10:37:14

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 ... Read More

OpenCV Python – How to detect and draw keypoints in an image using SIFT?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 10:34:36

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 ... Read More

How to perform matrix transformation in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 10:31:22

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 ... Read More

How to rotate an image in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 10:28:48

OpenCV provides us the function cv.rotate() to rotate an image (numpy array) in multiples of 90 degrees. This function rotates an image in three possible ways: 90, 180, and 270 degrees clockwise. We use the following syntax − Syntax cv2.rotate(img, rotateCode) rotateCode is a rotate flag specifying ... Read More

How to blend images using image pyramids in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 10:25:55

We can blend the images using the Gaussian and Laplacian image pyramids. The Gaussian pyramid is a type of image pyramid. To create a Gaussian pyramid, OpenCV provides us two functions cv2.pyrDown() and cv2.pyrUp(). We can form the Laplacian Pyramids from the Gaussian pyramids. In Laplacian pyramid images look like ... Read More

How to extract the foreground of an image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 11:08:18

We apply the cv2.grabCut() method to extract the foreground in an image. For detailed approach please 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 image path. Define ... Read More

How to find discrete cosine transform of an image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 11:06:22

We apply cv2.dct() to find the discrete cosine transform of an image. This function transforms the grayscale image of dtype float32. It accepts two types of flag cv2.DCT_INVERSE or cv2.DCT_ROWS. To convert the transformed image to the original image we use cv2.idct(). Steps To find discrete cosine transform of an ... Read More

Implementing Shi-Tomasi Corner Detector in OpenCV Python

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 11:04:42

The Shi-Tomasi Corner Detector is an enhanced algorithm of the Harris Corner Detector. To implement the Shi-Tomasi corner detector, OpenCV provides us with the function, cv2.goodFeaturesToTrack(). It detects N strongest corners in the image. Steps To detect corners in an image using Shi-Tomasi corner detector, you could follow the steps ... Read More

Detecting corners using Harris corner detector in Python OpenCV

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 11:02:32

In OpenCV, the Harris corner detector is implemented using the function cv2.cornerHarris(). It accepts four arguments: img, blockSize, ksize, and k. Where img is the input image in grayscale and of float32 dtype, blockSize is the size of neighborhood considered for corner detection, ksize is Aperture parameter of Sobel derivative ... Read More

How to compare histograms of two images using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 11:00:28

The histograms of two images can be compared using cv2.compareHist() function. The cv2.compareHist() function accepts three input arguments- hist1, hist2, and compare_method. The hist1 and hist2 are histograms of the two input images and compare_method is a metric to compute the matching between the histograms. It returns a numerical parameter ... Read More

Advertisements