Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
0246cffc
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0246cffc
编写于
10月 15, 2017
作者:
R
Ryan Fox
提交者:
GitHub
10月 15, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix up grammatical errors in python tutorial
上级
fee20496
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
17 deletion
+17
-17
doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
+17
-17
未找到文件。
doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
浏览文件 @
0246cffc
...
...
@@ -50,9 +50,9 @@ You can modify the pixel values the same way.
Numpy is a optimized library for fast array calculations. So simply accessing each and every pixel
values and modifying it will be very slow and it is discouraged.
@note
Above mentioned method is normally used for selecting a region of array, say first 5 rows and
last 3 columns like that. For individual pixel access,
Numpy array methods, array.item() and
array.itemset()
is considered to be better. But it always returns a scalar. So i
f you want to access
@note
The above method is normally used for selecting a region of an array, say the first 5 rows
and last 3 columns. For individual pixel access, the
Numpy array methods, array.item() and
array.itemset()
are considered better, however they always return a scalar. I
f you want to access
all B,G,R values, you need to call array.item() separately for all.
Better pixel accessing and editing method :
...
...
@@ -73,15 +73,15 @@ Accessing Image Properties
Image properties include number of rows, columns and channels, type of image data, number of pixels
etc.
Shape of image is accessed by img.shape. It returns a tuple of number of rows, columns
and channels
The shape of an image is accessed by img.shape. It returns a tuple of number of rows, columns,
and channels
(if image is color):
@code{.py}
>>> print( img.shape )
(342, 548, 3)
@endcode
@note If
image is grayscale, tuple returned contains only number of rows and columns. So it is a
good method to check if loaded image is grayscale or color image
.
@note If
an image is grayscale, the tuple returned contains only the number of rows
and columns, so it is a good method to check whether the loaded image is grayscale or color
.
Total number of pixels is accessed by
`img.size`
:
@code{.py}
...
...
@@ -101,9 +101,9 @@ Image ROI
---------
Sometimes, you will have to play with certain region of images. For eye detection in images, first
face detection is done all over the image
and when
face is obtained, we select the face region alone
and search for eyes inside it instead of searching whole image. It improves accuracy (because eyes
are always on faces :D ) and performance (because we search
for a small area)
face detection is done all over the image
. When a
face is obtained, we select the face region alone
and search for eyes inside it instead of searching
the
whole image. It improves accuracy (because eyes
are always on faces :D ) and performance (because we search
in a small area).
ROI is again obtained using Numpy indexing. Here I am selecting the ball and copying it to another
region in the image:
...
...
@@ -118,9 +118,9 @@ Check the results below:
Splitting and Merging Image Channels
------------------------------------
Sometimes you will need to work separately on B,G,R channels of image.
Then you need to split the
BGR images to single planes. Or another time, you may need to join these individual channels to BGR
image. You can do it simply by:
Sometimes you will need to work separately on B,G,R channels of image.
In this case, you need
to split the BGR images to single channels. In other cases, you may need to join these individual
channels to a BGR
image. You can do it simply by:
@code{.py}
>>> b,g,r = cv2.split(img)
>>> img = cv2.merge((b,g,r))
...
...
@@ -129,13 +129,13 @@ Or
@code
>>> b = img[:,:,0]
@endcode
Suppose
, you want to make all the red pixels to zero, you need not split like this and put it equal
to zero. You can simply use Numpy indexing, and that is faster.
Suppose
you want to set all the red pixels to zero, you do not need to split the channels first.
Numpy indexing is faster:
@code{.py}
>>> img[:,:,2] = 0
@endcode
**
w
arning**
**
W
arning**
cv2.split() is a costly operation (in terms of time). So do it only if you need it. Otherwise go
for Numpy indexing.
...
...
@@ -144,7 +144,7 @@ Making Borders for Images (Padding)
-----------------------------------
If you want to create a border around the image, something like a photo frame, you can use
**cv2.copyMakeBorder()**
function
. But it has more applications for convolution operation, zero
**cv2.copyMakeBorder()**
. But it has more applications for convolution operation, zero
padding etc. This function takes following arguments:
-
**src**
- input image
...
...
@@ -190,7 +190,7 @@ plt.subplot(236),plt.imshow(constant,'gray'),plt.title('CONSTANT')
plt.show()
@endcode
See the result below. (Image is displayed with matplotlib. So RED and BLUE
plane
s will be
See the result below. (Image is displayed with matplotlib. So RED and BLUE
channel
s will be
interchanged):
![
image
](
images/border.jpg
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录