3
我試圖創建一個1和0的三維矩陣。我想通過在它們之間形成一行1來連接2個點(最短距離)。在多維矩陣中連接兩個點
這將是這個樣子,但在3D
path_pixels = [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,1,0,0,0,0,0,0,0,0,0,0,0;
0,0,0,0,1,0,0,0,0,0,0,0,0,0,0];
我能夠使用這個代碼
clc;
clear;
%matrix size
A = zeros(70);
A(20,20) = 1; %arbitrary point
B = zeros(70);
B(40,40) = 1; %arbitrary point
D1 = bwdist(A);
D2 = bwdist(B);
D_sum = D1 + D2 ;
path_pixels = imregionalmin(D_sum);
spy(path_pixels)
如何展開這種方法到3d做到在2D?
3D Bresenham? http://www.mathworks.com/matlabcentral/fileexchange/21057-3d-bresenham-s-line-generation – knedlsepp
是的,看起來我的答案是Bresenham的實現。毫不奇怪,我記住了舊的辛克萊譜PLOT;)。 –