0

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;
    }

Palash
  • 21
  • 3
  • so now i have got the junctions ---> boundary figured out (code above has been updated). – Palash Nov 17 '19 at 20:09
  • Note that this same question was also [asked here](https://forum.image.sc/t/recreate-boundary-from-array-of-junctions/31436?u=imagejan) on the image.sc forum (which is the preferred place for ImageJ-related questions). @Palash please always disclose when cross-posting on different locations, so others can also follow the discussion on both places. Thanks! – Jan Eglinger Nov 17 '19 at 20:55
  • Sure, will do. Thanks – Palash Nov 18 '19 at 10:57

0 Answers0