函数
>
图像处理
>
特征提取
>
示例:矩不变量
示例:矩不变量
使用
moment_invariant
函数计算图像的七个空间不变矩。
不变矩是图像的特征,对图像进行平移、旋转或缩放操作时,其不会改变,因此其在图形识别中非常有用。
有关使用此示例的信息,请参考
关于图像处理示例
。
简单图象
1.
定义简单图像矩阵,然后使用
WRITEBMP
函数将图像保存到文件中。
i
0
29
j
0
39
M
i
j
i
40
j
Pix
WRITEBMP
image_matrix.bmp
M
(image_matrix.bmp)
2.
计算二阶矩或质心。
nrow
rows
M
ncol
cols
M
mnc
i
j
j
M
i
j
0
ncol
1
0
nrow
1
i
j
M
i
j
0
ncol
1
0
nrow
1
mnr
i
j
i
M
i
j
0
ncol
1
0
nrow
1
i
j
M
i
j
0
ncol
1
0
nrow
1
3.
计算三阶中心矩。
p
0
3
q
0
3
μ
p
q
i
j
j
mnc
p
i
mnr
q
M
i
j
0
ncol
1
0
nrow
1
μ
7.194
10
5
4.62
10
-10
9.582
10
7
2.558
10
7
8.149
10
-10
7.993
10
5
3.553
10
5
1.917
10
8
3.592
10
7
7.991
10
6
4.781
10
9
6.387
10
8
1.443
10
8
1.675
10
8
1.915
10
10
3.504
10
10
4.
计算正则化矩。
η
p
q
μ
p
q
μ
0
0
p
q
2
2
5.
计算第一个矩不变量。
ϕ1
η
2
0
η
0
2
ϕ1
2.546
10
-4
6.
调用
moment_invariant
函数并比较结果。
P
moment_invariant
M
P
0
0
ϕ1
2.711
10
-19
几何变换
1.
使用
READ_IMAGE
函数来读取图像。
M
READ_IMAGE
flower.bmp
(flower.bmp)
2.
使用
translate
、
rotate
和
zoom
函数在图像上执行三种类型的几何变换:平移、旋转和缩放。
M1
translate
M
-10
-5
0
Pix
WRITEBMP
flower_t.bmp
M1
(flower_t.bmp)
M3
rotate
M
45
Pix
WRITEBMP
flower_r.bmp
M3
(flower_r.bmp)
M2
zoom
M
0.8
0.8
Pix
WRITEBMP
flower_z.bmp
M2
(flower_z.bmp)
3.
对图像应用
moment_invariant
并计算结果。
Φ
moment_invariant
M
Φ1
moment_invariant
M1
Φ2
moment_invariant
M2
Φ3
moment_invariant
M3
Φ
1.814
10
-3
1.308
10
-6
1.211
10
-9
4.609
10
-10
3.062
10
-19
2.992
10
-13
1.577
10
-19
Φ1
1.814
10
-3
1.308
10
-6
1.211
10
-9
4.609
10
-10
3.062
10
-19
2.992
10
-13
1.577
10
-19
Φ2
1.815
10
-3
1.307
10
-6
1.213
10
-9
4.62
10
-10
3.074
10
-19
2.999
10
-13
1.584
10
-19
Φ3
1.822
10
-3
1.361
10
-6
1.228
10
-9
4.633
10
-10
3.101
10
-19
3.279
10
-13
1.611
10
-19
不变矩未改变。
上述结果与从原始图像计算所得的不变量合理一致。小误差则是由变换中所进行的补零和像素插值造成的。
4.
更改变换值,并将矩不变量与原始量进行比较。
M1
rotate
M
-60
M2
zoom
M1
0.75
0.75
M3
translate
M2
-10
10
0
Φ
moment_invariant
M
Φ1
moment_invariant
M1
Φ2
moment_invariant
M2
Φ3
moment_invariant
M3
Φ
1.814
10
-3
1.308
10
-6
1.211
10
-9
4.609
10
-10
3.062
10
-19
2.992
10
-13
1.577
10
-19
Φ1
1.815
10
-3
1.311
10
-6
1.216
10
-9
4.637
10
-10
3.101
10
-19
2.976
10
-13
1.584
10
-19
Φ2
1.816
10
-3
1.311
10
-6
1.216
10
-9
4.638
10
-10
3.102
10
-19
2.976
10
-13
1.585
10
-19
Φ3
1.816
10
-3
1.311
10
-6
1.216
10
-9
4.638
10
-10
3.102
10
-19
2.976
10
-13
1.585
10
-19
上述结果也与从原始图像计算所得的不变量合理一致。
复制表达式
相关主题
矩不变量
这对您有帮助吗?
此站点在 JavaScript 启用时工作最佳