
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

6K+ Views
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 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 image using cv2.imread() method. Specify the full path of the image. Convert the input image to grayscale image using cv2.cvtColor() metod. Convert ... Read More

1K+ Views
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 given below − Import 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() metod. Apply cv2.goodFeaturesToTrack() function on the grayscale image. Pass suitable ... Read More

3K+ Views
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 used and k is Harris detector free parameter in the equation. Steps To detect corners in an image using Harris corner detector, you could follow the steps given below Import required libraries OpenCV and NumPy. Make sure you have already installed them. Read the input image using cv2.imread() method. ... Read More

5K+ Views
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 that expresses how well two histograms match with each other. There are four metrics available to compare the histograms- Correlation, Chi-square, Intersection and Bhattacharyya distance. Steps To compare the histograms of two images one could follow the steps given below − Import the required libraries. In all the following ... Read More

1K+ Views
We can perform the distance transform using the method cv2.distanceTransform(). Following is the syntax of this method. Syntax cv2.distanceTransform(src, distanceType, maskSize) This method accepts the following parameters − src − 8-bit, single-channel (binary) source image. distanceType − Type of the distance. maskSize − Size of the distance transform mask. Steps To perform distance transform on the image, we could follow the below steps- Import the required library. In all the following examples, the required Python library is OpenCV. Make sure you have already installed it. Read an input image using cv2.imread(). The RGB image read using ... Read More

2K+ Views
Probabilistic Hough Transform is an optimization of the Hough Transform. The hough transform takes a lot of computation even for a line with two arguments. Probabilistic Hough Transform doesn't take all the points into consideration, it takes only a random subset of points and that is sufficient for line detection. We could follow the below given steps to implement probabilistic Hough Transform on an image- Import the required library. In all the following examples, the required Python library is OpenCV. Make sure you have already installed it. Read an input image using cv2.imread(). The RGB image read using ... Read More

1K+ Views
We apply Fourier Transform to analyze the frequency characteristics of various filters. We can apply Fourier transform on the Gaussian and Laplacian filters using np.fft.fft2(). We use np.fft.fftshift() to shift the zero-frequency component to the center of the spectrum. Steps To find Fourier transforms of the Gaussian or Laplacian filters, one could follow the steps given below − Import the required libraries. In all below Python examples the required Python libraries are OpenCV, Numpy and Matplotlib. Make sure you have already installed them. Define a Gaussian or a Laplacian Filter. Apply Fourier transform on the above defined ... Read More

4K+ Views
The Discrete Fourier Transform (DFT) and Inverse Discrete Fourier Transform (IDFT) are applied on images to find the frequency domain. To find the Fourier transforms of an image we use the functions cv2.dft() and cv2.idft(). We can apply Fourier Transform to analyze the frequency characteristics of various filters. Steps To find Fourier transforms of an input image, one could follow the steps given below − Import the required libraries. In all below Python examples the required Python libraries are OpenCV, Numpy and Matplotlib. Make sure you have already installed them. Load the input image as a grayscale image ... Read More

3K+ Views
In OpenCV, We use the cv2.calcHist() function to compute the histogram of an image. We can use this function to compute the histogram of a region of the image. To compute a histogram of a region in the image first we define a mask. The white color in the maskis for regions to examine in the original input image and the black color in the mask image is for regions to ignore. Now we calculate the histogram passing this mask as a parameter to the function. Steps To compute and plot the histograms of a region of the image, one ... Read More

799 Views
We can apply the cv2.calcHist() function to compute a 2D histogram of an image. The color image has three channels- Red, Green and Blue. We can compute the 2D histograms for two color channels at a time. So we have three combinations of the color channels taking two at a time- Red & Green (or Green & Red), Green & Blue (or Blue & Green) and Blue & Red (or Red & Blue). Steps To compute and plot 2D histograms of an input image, one could follow the steps given below − Import required libraries OpenCV and matplotlib. ... Read More