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.

//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

function cmpltarray(Tx,Ty){
	for (i = 0; i < Tx.length-1; i++) {
	if(Tx[i]==Tx[i+1] && Ty[i]!=Ty[i+1])
		for (j = 0; j < l; j++) {
	if(Ty[i]==Ty[i+1] && Tx[i]!=Tx[i+1])
		for (j = 0; j < l; j++) {
		return Array.concat(Tx,Ty);
function slide(array,n,data){
		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)");
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.