2012-04-18 52 views
2

給定一個圖像,我已經計算了圖像中每個點的深度,我需要在MATLAB中繪製這樣的圖。有人可以建議我如何去做這件事。 enter image description hereMatlab - 從焦點形狀

回答

1

假設你有存儲在一個二維數組的深度數據稱爲D,那麼你需要在它上面繪製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.