Matlab - 从焦点形状

时间:2012-04-18 03:22:45

标签: matlab image-processing focus shape depth

给定一个图像我已经计算了图像中每个点的深度,我需要在MATLAB中绘制这样的地图。有人可以建议我怎么做。 enter image description here

1 个答案:

答案 0 :(得分:1)

假设您将深度数据存储在名为D的2D数组中,那么您需要确定要在其上绘制D的网格域。我将假设您关心的是x轴范围[x_min, x_max]和y轴范围[y_min, y_max],其中每个范围都是表示每个坐标方向的最小值和最大值的标量。

y_num = size(D,1); % <-- Number of points to use in y-axis grid.
x_num = size(D,2); % <-- Number of points to use in x-axis grid.

x_grid_vals = linspace(x_min,x_max,x_num);
y_grid_vals = linspace(y_min,y_max,y_num);

% Get full coordinate grid for the 3D plot.
[X,Y] = meshgrid(x_grid_vals,y_grid_vals);

% Plot the data.
% The surf() function plots the depth as 3D above the created grid.
surf(X,Y,D);

Here is the surf() documentation.