python CV小记

np.zeros
用法:zeros(shape, dtype=float, order=‘C’)

返回:返回来一个给定形状和类型的用0填充的数组;

参数:shape:形状

        dtype:数据类型,可选参数,默认numpy.float64

        dtype类型:t ,位域,如t4代表4位

                             b,布尔值,true or false

                             i,整数,如i8(64位)

                            u,无符号整数,u8(64位)

                            f,浮点数,f8(64位)

                           c,浮点负数,

                            o,对象,

                           s,a,字符串,s24

                           u,unicode,u24

        order:可选参数,c代表与c语言类似,行优先;F代表列优先

例子:

np.zeros(5)
array([ 0., 0., 0., 0., 0.])

np.zeros((5,), dtype=np.int)
array([0, 0, 0, 0, 0])

np.zeros((2, 1))
array([[ 0.],
[ 0.]])

s = (2,2)
np.zeros(s)
array([[ 0., 0.],
[ 0., 0.]])

np.reshape
reshpae,是数组对象中的方法,用于改变数组的形状。

二维数组

import numpy as np

a=np.array([1, 2, 3, 4, 5, 6, 7, 8])
print a
d=a.reshape((2,4))
print d

三维数组

import numpy as np

a=np.array([1, 2, 3, 4, 5, 6, 7, 8])
print a
f=a.reshape((2, 2, 2))
print f

变换与卷绕
线性变换:
1.直线还是直线
2.比例保持不变
3.原点不变
仿射变换:
1.直线还是直线
2.比例保持不变
旋转矩阵T[cos -sin
sin cos]
numpy.eye
numpy.eye(N, M=None, k=0, dtype=<class ‘float’>, order=‘C’)[source]
Return a 2-D array with ones on the diagonal and zeros elsewhere.

Parameters:	
N : int
Number of rows in the output.

M : int, optional
Number of columns in the output. If None, defaults to N.

k : int, optional
Index of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.

dtype : data-type, optional
Data-type of the returned array.

order : {‘C’, ‘F’}, optional
Whether the output should be stored in row-major (C-style) or column-major (Fortran-style) order in memory.

New in version 1.14.0.

Returns:	
I : ndarray of shape (N,M)
An array where all elements are equal to zero, except for the k-th diagonal, whose values are equal to

numpy中的切片操作小结
https://blog.csdn.net/ccwlisha/article/details/88866429

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值