学习就这样,边学边记录,欧耶(^o^)/
- floor函数
今天第一个碰到的函数是
floor函数
定义 Round toward negative infinity 向负无穷取整
用法 B = floor(A)
举个例子
>> WSize=15;
N = floor(WSize/2)
N =
7
- meshgrid
他的定义是Rectangular grid in 2-D and 3-D space 翻译一下是长方形网格,可以使二维的或者三维的
用法有四种,第三四种就是xgv=ygv的情况。
[X,Y] = meshgrid(xgv,ygv)
[X,Y,Z] = meshgrid(xgv,ygv,zgv)
[X,Y] = meshgrid(gv)
[X,Y,Z] = meshgrid(gv)
>> N=3; [x,y] = meshgrid(-N:N, -N:N)
x =
-3 -2 -1 0 1 2 3
-3 -2 -1 0 1 2 3
-3 -2 -1 0 1 2 3
-3 -2 -1 0 1 2 3
-3 -2 -1 0 1 2 3
-3 -2 -1 0 1 2 3
-3 -2 -1 0 1 2 3
y =
-3 -3 -3 -3 -3 -3 -3
-2 -2 -2 -2 -2 -2 -2
-1 -1 -1 -1 -1 -1 -1
0 0 0 0 0 0 0
1 1 1 1 1 1 1
2 2 2 2 2 2 2
3 3 3 3 3 3 3
>> N=1; [x,y,z] = meshgrid(-N:N, -N:N, -N:N)
x(:,:,1) =
-1 0 1
-1 0 1
-1 0 1
x(:,:,2) =
-1 0 1
-1 0 1
-1 0 1
x(:,:,3) =
-1 0 1
-1 0 1
-1 0 1
y(:,:,1) =
-1 -1 -1
0 0 0
1 1 1
y(:,:,2) =
-1 -1 -1
0 0 0
1 1 1
y(:,:,3) =
-1 -1 -1
0 0 0
1 1 1
z(:,:,1) =
-1 -1 -1
-1 -1 -1
-1 -1 -1
z(:,:,2) =
0 0 0
0 0 0
0 0 0
z(:,:,3) =
1 1 1
1 1 1
1 1 1
meshgrid还是挺有用的,可用于采样。
然后我学习到的是用于求高斯导数
[x,y] = meshgrid(-N:N, -N:N);
G = exp(-(x.^2+y.^2)/(2*sig^2))/(2*pi*sig);%高斯函数
Gx = -x.*G/(sig^2);%x方向导数
Gx = Gx/sum(abs(Gx(:)));%归一化
Gy = -y.*G/(sig^2);
Gy = Gy/sum(abs(Gy(:)));