根据文件,它Returns array row or row span.它返回指定的行.
我将在Python终端的帮助下解释它:
以灰度模式加载图像并检查其宽度和高度.
>>> import cv2.cv as cv
>>> img = cv.LoadImage('approx2.jpg',0)
>>> img
<iplimage(nChannels=1 width=300 height=300 widthStep=300 )>
Run Code Online (Sandbox Code Playgroud)
看,图像尺寸为300x300.下面是图像.

取所有像素,
>>> cv.Sum(img)
(1252271.0, 0.0, 0.0, 0.0)
Run Code Online (Sandbox Code Playgroud)
现在我们应用我们的第一个函数cv.GetRow()
>>> row = cv.GetRow(img,150)
>>> row
<cvmat(type=42424000 8UC1 rows=1 cols=300 step=300 )>
>>> cv.Sum(row)
(14279.0, 0.0, 0.0, 0.0)
Run Code Online (Sandbox Code Playgroud)
我拿了第150行并取了那一行中所有元素的总和.查看结果图像的高度= 1.
现在取功能cv.GetRows().
>>> rows = cv.GetRows(img,0,150)
>>> rows
<cvmat(type=42424000 8UC1 rows=150 cols=300 step=300 )>
>>> cv.Sum(rows)
(802501.0, 0.0, 0.0, 0.0)
Run Code Online (Sandbox Code Playgroud)
我把所有的行都从150到150.看它的高度是150.看看下面的图像:

现在这个函数有第四个参数delta_row可以用作增量.它将选择行,这是所提到的步长的增量,跳过它们之间的所有内容.即如果指定,the function extracts every delta_row -th row from start_row and up to (but not including) end_row .
>>> rows = cv.GetRows(img,0,300,5)
>>> rows
<cvmat(type=42420000 8UC1 rows=60 cols=300 step=1500 )>
Run Code Online (Sandbox Code Playgroud)
看,现在高度只有30,因为它每隔5行提取一次.
结果如下:

情况类似cv.GetCol() and cv.GetCols().
| 归档时间: |
|
| 查看次数: |
2523 次 |
| 最近记录: |