Matlab中显示法线方向 display normal map in matlab
2015-09-30 13:07
393 查看
% X and Y components of the normals vectors are between -1 and 1.
% The step number specifies the size of the output image.
range = -1:0.01:1;
% Repeat the range to build a matrix
X = repmat(range, [size(range, 2), 1]);
Y = flipud(repmat(range', [1, size(range, 2)]));
% These normals must be of unit norm, so find an Z component which
% solves sqrt(X^2 + Y^2 + Z^2) = 1
Z = (1 - (X.^2 + Y.^2)).^0.5;
% Change the display range of X and Y to 0..1 instead of -1..1
X = (X + 1) / 2;
Y = (Y + 1) / 2;
Z = (Z + 1) / 2;
% Mask pixels outside the sphere (in which the Z component is complex)
X(Z ~= real(Z)) = 0;
Y(Z ~= real(Z)) = 0;
Z(Z ~= real(Z)) = 0;
% Build the map
map = cat(3,X,Y,Z);
imshow(map);
% The step number specifies the size of the output image.
range = -1:0.01:1;
% Repeat the range to build a matrix
X = repmat(range, [size(range, 2), 1]);
Y = flipud(repmat(range', [1, size(range, 2)]));
% These normals must be of unit norm, so find an Z component which
% solves sqrt(X^2 + Y^2 + Z^2) = 1
Z = (1 - (X.^2 + Y.^2)).^0.5;
% Change the display range of X and Y to 0..1 instead of -1..1
X = (X + 1) / 2;
Y = (Y + 1) / 2;
Z = (Z + 1) / 2;
% Mask pixels outside the sphere (in which the Z component is complex)
X(Z ~= real(Z)) = 0;
Y(Z ~= real(Z)) = 0;
Z(Z ~= real(Z)) = 0;
% Build the map
map = cat(3,X,Y,Z);
imshow(map);
相关文章推荐
- Matlab删除NaN数据
- 批梯度下降算法 matlab
- 随机梯度下降算法 matlab
- MATLAB:批量随机抽取一定数量的图片
- matlab一些基本重要的指令
- Matlab DCT详解
- matlab窗口学习
- c# vs2010 matlab2012b 混合编程
- MATLAB中的diff函数
- matlab中字符串连接的3种方法
- matlab初步学习1
- matlab句柄图形
- 数字信号处理MATLAB简单序列
- Matlab通过mex调用CUDA的方法
- matlab中同一文件定义子函数的方法
- MATLAB 单变量函数一阶及N阶求导
- matlab plot画多条不同颜色的线
- Java调用MATLAB程序
- matlab混合编程入门教程
- matlab(8) Regularized logistic regression : 不同的λ(0,1,10,100)值对regularization的影响,对应不同的decision boundary\ 预测新的值和计算模型的精度predict.m