26 Şubat 2021 Cuma

OpenCV Sharr Edge Detection

Giriş
OpenCV Edge Detection için bir sürü yöntem sağlıyor.

Örnek
Açıklaması şöyle
OpenCV has several ways to compute edge detection, and we are going to use Scharr, as it performs quite well. Scharr computes a derivative, so it detects the difference in colors in the image. We are interested in the X axis, and we want the result to be a 64-bit float, so our call would be like this:
Şöyle yaparız
edge_x = cv2.Scharr(channel, cv2.CV_64F, 1, 0)
Açıklaması şöyle
As Scharr computes a derivative, the values can be both positive and negative. We are not interested in the sign, but only in the fact that there is an edge. So, we will take the absolute value: 
Şöyle yaparız
edge_x = np.absolute(edge_x)
Açıklaması şöyle
 Another issue is that the values are not bounded on the 0–255 value range that we expect on a single channel image, and the values are floating points, while we need an 8-bit integer. We can fix both the issues with the following line: 
Şöyle yaparız
edge_x = np.uint8(255 * edge_x / np.max(edge_x))


Hiç yorum yok:

Yorum Gönder