这是一个$$ f(x) = \\int_{-\\infty}^\\infty\\hat f(\\xi)\\,e^{2 \\pi i \\xi x}\\,d\\xi $$行内公式 这是一个公式 katex f(x) = \\int_{-\\infty}^\\infty\\hat f(\\xi)\\,e^{2 \\pi i \\xi x}\\,d\\xi

关于一些功能测测试会在这篇文章中进行

微梦云盘视频外链速度测试

芭芭拉冲呀!

[vplayer url=https://pan.vinua.cn/api/v3/file/source/6123/%E5%8E%9F%E7%A5%9E%202022-02-07%2023-53-19.mp4?sign=smSPGJgCo4-TTjuByUb8trrmLBvmX7opi7zIcFOmXMQ%3D%3A0 pic=\ /]

下一项工作是....

[vplayer url=https://pan.vinua.cn/api/v3/file/source/6126/%E5%8E%9F%E7%A5%9E%202022-01-27%2016-14-51.mp4?sign=BUXXIOicWZZMQWuhuVDGrGEndbWg3t5DnHoQ-KHZ3lc%3D%3A0 pic=\ /]

LaTeX 公式测试

$$ M = \begin{bmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \end{bmatrix} $$ $$ M = \begin{bmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \end{bmatrix} $$

收缩框测试

   测试  ==>  展开 / 收起

cloudflaer cdn速度测试

87855751_p0.png
87855751_p1.png
88157939_p0.png
88292124_p0.jpg
88292124_p1.jpg
88958571_p0.jpg
89258146_p0.png
89485423_p0.jpg
89578398_p0.png
89672655_p0.png
89921521_p0.jpg
90403485_p0.png
91251432_p02c249952313fa901.jpg
91327318_p0.png
91915882_p0.jpg
93068312_p0b55cd28ee790eb33.png
93243989_p0.png
93491124_p0.jpg
93518475_p0.jpg
93609889_p0.png
93852293_p0.png
93868453_p0.png
93868453_p1.png
93881225_p0.jpg
93888388_p0.jpg
93893732_p0.jpg
93965292_p0.jpg
94060172_p0.jpg
94068635_p0.jpg
94079149_p0.png
94114012_p0.jpg
94124723_p0.png
94124723_p1.png
94124723_p2.png
94124723_p3.png
94124723_p4.png
94124723_p5.png
94124723_p6.png
94126608_p0.jpg
94155936_p0.jpg
94192051_p0.jpg
94207421_p0.jpg
94243674_p0.jpg
94353846_p0.png
94505059_p0.png
95156097_p0.jpg
95162574_p0.jpg
95225935_p0.png
95225935_p1.png
95304555_p0.png
95316313_p0.jpg
95355938_p0.png
95932790_p0.jpg
96124437_p0.png
96241169_p0.jpg
96261249_p0.jpg
96261823_p0.jpg
96261823_p1.jpg
96261823_p2.jpg
96261823_p3.jpg
4028484.png
19591509.png
24955808.png
27457941.png
88153191_p0.png
88178896_p0.png
88202672_p0.png
88221705_p0.png
88230324_p0.png
88233006_p0.png
88266566_p0.png
88267064_p0.png
88274213_p1.png
88281043_p0.png
88285159_p0.png
88285159_p1.png
88289715_p0.png
88293439_p0.png
88303977_p0.png
88312502_p0.png
88315779_p0.png
88316903_p0.png
88326996_p0.png
88329490_p0.png
88337857_p0ae86b9e46b9b7bf4.png
88337935_p0.png
88349228_p0.png
88350829_p0.png
88359759_p0.png
1463671.jpg
3064140.jpg
5274293.jpg
5741723.jpg
6657532.jpg
12859631.jpg
13955393.jpg
26505589.jpg
28621914.jpg
29678589.jpg
33821183.jpg
64465066.jpg
88144173_p0.jpg
88189538_p0.jpg
88218789_p0.jpg
88230471_p0.jpg
88246317_p0.jpg
88250958_p0.jpg
88257590_p0.jpg
88286789_p0.jpg
88286864_p0.jpg
88286864_p1.jpg
88292278_p0.jpg
88306963_p0.jpg
88314730_p0.jpg
88317754_p0.jpg
88319786_p0.jpg
88321683_p0.jpg
88325920_p1.jpg
88326344_p0.jpg
88326344_p1.jpg
88338389_p0.jpg
88346259_p0.jpg
88347053_p0.jpg
88347993_p0.jpg
88350270_p0.jpg
88350270_p1.jpg
88362681_p0.jpg
88383247_p0.jpg
88599483_p0.jpg

Goal

In this chapter, we will learn about

  • Concept of Canny edge detection
  • OpenCV functions for that : cv.Canny()

Theory

Canny Edge Detection is a popular edge detection algorithm. It was developed by John F. Canny in

  1. It is a multi-stage algorithm and we will go through each stages.
  2. Noise Reduction
    Since edge detection is susceptible to noise in the image, first step is to remove the noise in the image with a 5x5 Gaussian filter. We have already seen this in previous chapters.
  3. Finding Intensity Gradient of the Image
    Smoothened image is then filtered with a Sobel kernel in both horizontal and vertical direction to get first derivative in horizontal direction ( Gx) and vertical direction ( Gy). From these two images, we can find edge gradient and direction for each pixel as follows:

Edge_Gradient(G)=G2x+G2y−−−−−−−√Angle(θ)=tan1(GyGx)
Gradient direction is always perpendicular to edges. It is rounded to one of four angles representing vertical, horizontal and two diagonal directions.

  1. Non-maximum Suppression
    After getting gradient magnitude and direction, a full scan of image is done to remove any unwanted pixels which may not constitute the edge. For this, at every pixel, pixel is checked if it is a local maximum in its neighborhood in the direction of gradient. Check the image below:

nms.jpgimage

Point A is on the edge ( in vertical direction). Gradient direction is normal to the edge. Point B and C are in gradient directions. So point A is checked with point B and C to see if it forms a local maximum. If so, it is considered for next stage, otherwise, it is suppressed ( put to zero).
In short, the result you get is a binary image with thin edges.

  1. Hysteresis Thresholding
    This stage decides which are all edges are really edges and which are not. For this, we need two threshold values, minVal and maxVal. Any edges with intensity gradient more than maxVal are sure to be edges and those below minVal are sure to be non-edges, so discarded. Those who lie between these two thresholds are classified edges or non-edges based on their connectivity. If they are connected to sure-edge pixels, they are considered to be part of edges. Otherwise, they are also discarded. See the image below:

hysteresis.jpgimage

The edge A is above the maxVal, so considered as sure-edge. Although edge C is below maxVal, it is connected to edge A, so that also considered as valid edge and we get that full curve. But edge B, although it is above minVal and is in same region as that of edge C, it is not connected to any sure-edge, so that is discarded. So it is very important that we have to select minVal and maxVal accordingly to get the correct result.
This stage also removes small pixels noises on the assumption that edges are long lines.

So what we finally get is strong edges in the image.

Canny Edge Detection in OpenCV

OpenCV puts all the above in single function, cv.Canny() . We will see how to use it. First argument is our input image. Second and third arguments are our minVal and maxVal respectively. Fourth argument is aperturesize. It is the size of Sobel kernel used for find image gradients. By default it is 3. Last argument is L2gradient which specifies the equation for finding gradient magnitude. If it is True, it uses the equation mentioned above which is more accurate, otherwise it uses this function: Edge**Gradient(G)=|Gx|+|Gy**|. By default, it is False.

import numpy as np

import cv2 as cv

from matplotlib import pyplot as plt

img = cv.imread(\'messi5.jpg\',0)

edges = cv.Canny(img,100,200)

plt.subplot(121),plt.imshow(img,cmap = \'gray\')

plt.title(\'Original Image\'), plt.xticks([]), plt.yticks([])

plt.subplot(122),plt.imshow(edges,cmap = \'gray\')

plt.title(\'Edge Image\'), plt.xticks([]), plt.yticks([])

plt.show()

See the result below:

canny1.jpgimage

Additional Resources

  1. Canny edge detector at Wikipedia
  2. Canny Edge Detection Tutorial by Bill Green, 2002.

Exercises

  1. Write a small application to find the Canny edge detection whose threshold values can be varied using two trackbars. This way, you can understand the effect of threshold values.
この素晴らしい世界に祝福を!
最后更新于 2023-10-07