Shahid Akhtar Khan has Published 216 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

991 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 ... 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

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

875 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, ... 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

3K+ 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 ... 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

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

562 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 ... 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

21K+ Views

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

3K+ Views

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

1K+ Views

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

OpenCV Python – How to draw curves using Mouse Events?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 02-Dec-2022 07:22:31

1K+ Views

There are different types of muse events such as left or right button click, mouse move, left button double click etc. OpenCV provides us with different types of mouse events such as cv2.EVENT_LBUTTONDOWN for mouse left button down, cv2.EVENT_LBUTTONDBLCLK for left button double click and others. A mouse event returns ... Read More

Previous 1 ... 3 4 5 6 7 ... 22 Next
Advertisements