I'm trying to create a 3d matrix of 1's and 0's. I want to connect 2 points together (shortest distance) by forming a line of 1's in between them.
It would look something like this, but in 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];
I'm able to do it in 2d using this code
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)
How can I expand this method to 3d?