Recreate boundary from array of junctions

Hi, I am detecting and storing the boundary of a sandpile to an array and then save it as a text file for later use. the way i stored the boundary as text file is by using the wand tool, then getting the properties of the selection which gives me a table. Then converting table to array and finally storing it as text file.
after doing so i noticed that the above mentioned table only has the (X,Y) coordinates of the “junctions” on the boundary and not every pixel of the boundary.

Now when i say later use, i want to smooth out the boundary with various methods and redraw it but i am stuck at how to go from junctions to complete boundary. Below is my attempt to do it but i am seeing heavy ram usage just after the output is printed.
Thanks for any help and your time.

X=newArray(1,5,5,10);
Y=newArray(3,3,8,8);
c=newArray("c1","c2");
//answer should be g=(1,2,3,4,5,5,5,5,5,5,6,7,8,9,10,    --x part   
//                    3,3,3,3,3,4,5,6,7,8,8,8,8,8,8)      --y part
//f=slide(a,2,c);Array.print(f);
g=cmpltarray(X,Y);Array.print(g);

function cmpltarray(Tx,Ty){
	
	for (i = 0; i < Tx.length-1; i++) {
	if(Tx[i]==Tx[i+1] && Ty[i]!=Ty[i+1])
	{
		l=abs(Ty[i]-Ty[i+1])-1;tempy=newArray(l);tempx=newArray(l);
		for (j = 0; j < l; j++) {
			tempy[j]=Ty[i]+j+1;tempx[j]=Tx[i];
		}
		Tx=slide(Tx,(i+1),tempx);Ty=slide(Ty,(i+1),tempy);i=i+l;
	}
	if(Ty[i]==Ty[i+1] && Tx[i]!=Tx[i+1])
	{
		l=abs(Tx[i]-Tx[i+1])-1;tempy=newArray(l);tempx=newArray(l);
		for (j = 0; j < l; j++) {
			tempx[j]=Tx[i]+j+1;tempy[j]=Ty[i];
		}
		Tx=slide(Tx,(i+1),tempx);Ty=slide(Ty,(i+1),tempy);i=i+l;
	}
		}
		return Array.concat(Tx,Ty);
}
function slide(array,n,data){
		array=Array.concat(Array.slice(array,0,n),data,Array.slice(array,n,array.length));
		return array;
	}
	

so now i have got the junctions —> boundary figured out (code above has been updated).

Did you consider using the junctions as edge coordinates in a segmented line and then interpolate the coordinates? Here is an example that does various interpolations and gathers the coordinates in two arrays. When you set the interval to 1, each pixel on the line selection ends up in the coordinates arrays.
If it is not what you intend to obtain, it may help to enhance the description of your desired result:

run("AuPbSn 40 (56K)");
setTool("polyline");
makeLine(105,245,147,177,236,128,357,160);
run("Interpolate", "interval=5 smooth");
run("Fit Spline");
run("Interpolate", "interval=3 smooth");
run("Fit Spline");
run("Interpolate", "interval=10 smooth adjust");
run("Interpolate", "interval=1 smooth adjust");
Roi.getCoordinates(xpoints, ypoints);

this is easier and less time consuming than my brute force method to draw the boundaries for sure. thanks.