Shahid Akhtar Khan has Published 217 Articles

How to perform distance transformation on a given image in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:58:26

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

How to implement probabilistic Hough Transform in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:51:28

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

How to find the Fourier Transforms of Gaussian and Laplacian filters in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:49:06

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

How to find the Fourier Transform of an image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:47:25

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

OpenCV Python – How to compute and plot the histogram of a region of an image?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:44:25

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

How to compute and plot 2D histograms of an image in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:41:58

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

OpenCV Python – How to convert a colored image to a binary image?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:39:58

We use cv2.threshold() to convert a grayscale image to binary image. To convert a color image to binary image, we first convert the color image to grayscale image using cv2.cvtColor() then apply cv2.threshold() on the grayscale image. Steps One could follow the below given steps to convert a color ... Read More

OpenCV Python – How to find the shortest distance between a point in the image and a contour?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:37:06

We could compute the shortest distance between a point and a contour on the image using cv2.pointPolygonTest() passing the contour points coordinates and the point coordinate as arguments. Before applying cv2.pointPolygonTest() we need to compute the contours in the image. We could follow the below given steps to find shortest ... Read More

OpenCV Python – How to perform bitwise NOT operation on an image?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:34:43

We can perform bitwise NOT operation on an image using cv2.bitwise_not(). Here is the syntax to perform bitwise NOT operation on an image - cv2.bitwise_not(img) Steps To compute bitwise NOT on an image, you can follow the steps given below − Import the required library. In all the ... Read More

How to normalize an image in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 10:32:03

We use the function cv2.normalize() to normalize an image in OPenCV. This function accepts the parameters- src, dst, alpha, beta, norm_type, dtype and mask. src and dst are input image and output of the same size as input, alpha is lower norm value for range normalization, beta is upper norm ... Read More

Advertisements