Skip to content

Commit f95b433

Browse files
committed
标注信息修改 2018年11月27日
1 parent 0685223 commit f95b433

File tree

30 files changed

+81
-52
lines changed

30 files changed

+81
-52
lines changed

08. 绘图功能/cv2_drawing_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# 5.画一个闭合的四边形
2626
# 定义四个顶点坐标
2727
pts = np.array([[10, 5], [50, 10], [70, 20], [20, 30]], np.int32)
28-
# 顶点个数:4,矩阵变成顶点数*1*2维
28+
# 顶点个数:4,矩阵变成顶点数*1*2维(注意numpy中-1的用法)
2929
pts = pts.reshape((-1, 1, 2))
3030
cv2.polylines(img, [pts], True, (0, 255, 255))
3131

10. 平滑图像/cv2_extra_exercise1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

10. 平滑图像/cv2_image_smoothing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
3+
14
import cv2
25
import numpy as np
36

10. 平滑图像/cv2_source_code_getGaussianKernel.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
// More: http://ex2tron.wang
1+
// ex2tron's blog:
2+
// http://ex2tron.wang
23

3-
cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype )
4+
cv::Mat cv::getGaussianKernel(int n, double sigma, int ktype)
45
{
56
// 对于常见的卷积核,无需计算,直接查表
67
const int SMALL_GAUSSIAN_SIZE = 7;
78
static const float small_gaussian_tab[][SMALL_GAUSSIAN_SIZE] =
8-
{
9-
{1.f},
10-
{0.25f, 0.5f, 0.25f},
11-
{0.0625f, 0.25f, 0.375f, 0.25f, 0.0625f},
12-
{0.03125f, 0.109375f, 0.21875f, 0.28125f, 0.21875f, 0.109375f, 0.03125f}
13-
};
9+
{
10+
{1.f},
11+
{0.25f, 0.5f, 0.25f},
12+
{0.0625f, 0.25f, 0.375f, 0.25f, 0.0625f},
13+
{0.03125f, 0.109375f, 0.21875f, 0.28125f, 0.21875f, 0.109375f, 0.03125f}};
1414

15-
const float* fixed_kernel = n % 2 == 1 && n <= SMALL_GAUSSIAN_SIZE && sigma <= 0 ?
16-
small_gaussian_tab[n>>1] : 0;
15+
const float *fixed_kernel = n % 2 == 1 && n <= SMALL_GAUSSIAN_SIZE && sigma <= 0 ? small_gaussian_tab[n >> 1] : 0;
1716

18-
CV_Assert( ktype == CV_32F || ktype == CV_64F );
17+
CV_Assert(ktype == CV_32F || ktype == CV_64F);
1918
Mat kernel(n, 1, ktype);
20-
float* cf = kernel.ptr<float>();
21-
double* cd = kernel.ptr<double>();
19+
float *cf = kernel.ptr<float>();
20+
double *cd = kernel.ptr<double>();
2221

2322
// sigma大于0和小于0两种情况
24-
double sigmaX = sigma > 0 ? sigma : ((n-1)*0.5 - 1)*0.3 + 0.8;
25-
double scale2X = -0.5/(sigmaX*sigmaX);
23+
double sigmaX = sigma > 0 ? sigma : ((n - 1) * 0.5 - 1) * 0.3 + 0.8;
24+
double scale2X = -0.5 / (sigmaX * sigmaX);
2625
double sum = 0;
2726

2827
int i;
29-
for( i = 0; i < n; i++ )
28+
for (i = 0; i < n; i++)
3029
{
31-
double x = i - (n-1)*0.5;
32-
double t = fixed_kernel ? (double)fixed_kernel[i] : std::exp(scale2X*x*x);
33-
if( ktype == CV_32F )
30+
double x = i - (n - 1) * 0.5;
31+
double t = fixed_kernel ? (double)fixed_kernel[i] : std::exp(scale2X * x * x);
32+
if (ktype == CV_32F)
3433
{
3534
cf[i] = (float)t;
3635
sum += cf[i];
@@ -43,11 +42,11 @@ cv::Mat cv::getGaussianKernel( int n, double sigma, int ktype )
4342
}
4443

4544
// 计算并乘以缩放系数α
46-
sum = 1./sum;
47-
for( i = 0; i < n; i++ )
45+
sum = 1. / sum;
46+
for (i = 0; i < n; i++)
4847
{
49-
if( ktype == CV_32F )
50-
cf[i] = (float)(cf[i]*sum);
48+
if (ktype == CV_32F)
49+
cf[i] = (float)(cf[i] * sum);
5150
else
5251
cd[i] *= sum;
5352
}

11. 边缘检测/cv2_canny_edge_detection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

11. 边缘检测/cv2_exercise1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

12. 腐蚀与膨胀/cv2_erosion_dilation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

13. 轮廓/cv2_find_contours.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45

14. 轮廓特征/cv2_contours_features.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

14. 轮廓特征/cv2_exercise1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

14. 轮廓特征/cv2_exercise2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45

15. 直方图/cv2_histogram.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

16. 模板匹配/cv2_template_matching.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

17. 霍夫变换/cv2_hough_transform.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

19. Harris角点检测/cv2_harris_corner_detector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

20. Shi-Tomasi角点检测/cv2_shi_tomasi_corner_detector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

20. Shi-Tomasi角点检测/cv_exercise1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

21. SIFT/cv2_sift_sample.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇06. 鼠标绘图/cv2_mouse_drawing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇06. 鼠标绘图/cv2_mouse_drawing_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇06. 鼠标绘图/cv2_mouse_drawing_exercise1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇06. 鼠标绘图/cv2_mouse_drawing_exercise2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇07. 亮度与对比度/cv2_contrast_brightness.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇07. 亮度与对比度/cv2_exercise1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇08. 卷积基础(图片边框)/cv2_border_convolution.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇09. 图像梯度/cv2_image_gradient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇10. 轮廓层级/cv2_exercise1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇10. 轮廓层级/cv2_understand_hierarchy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45

番外篇11. 凸包及更多轮廓特征/cv2_convex_hull.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45
import numpy as np

番外篇12. 尺度空间与图像金字塔/cv2_pyrdown_pyrup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# More: http://ex2tron.wang
1+
# ex2tron's blog:
2+
# http://ex2tron.wang
23

34
import cv2
45

56
img = cv2.imread('lena.jpg')
67
lower = cv2.pyrDown(img) # 向下采样一级
7-
higher = cv2.pyrUp(img) # 向上采样一级
8+
higher = cv2.pyrUp(img) # 向上采样一级
89

910

1011
cv2.imshow('origin', img)

0 commit comments

Comments
 (0)