image=

Export["/home/student/courses/MATH661/homework/HW1Fig1a.png",image];

contour=Binarize[GradientFilter[image,1]]

A=ImageData[contour];

coords=Position[A,1];

Graphics[Map[Point[#]&,coords]]

A=ImageData[ImageRotate[contour,-π/2]];
coords=Position[A,1];
Graphics[Map[Point[#]&,coords]]

nC=Length[coords]

nN=60;
nodes=Part[coords,Table[RandomInteger[nC-1]+1,nN]];

owlpts=Graphics[Map[Point[#]&,nodes]]

CG=Mean[nodes];
CGpoint=Graphics[{Red,Point[CG]}];
Show[owlpts,CGpoint]

θ=Map[ArcTan[ #[[1]],#[[2]] ]&,Table[N[nodes[[k]]-CG],{k,1,nN}]]

θnodes=Sort[ Table[{θ[[k]],nodes[[k]]},{k,1,nN}] , #1[[1]] < #2[[1]] &]

OrderedNodes=Map[#[[2]]&,θnodes]

Export["/home/student/courses/MATH661/homework/HW1data.mat",N[OrderedNodes]]

owlpts=Graphics[{PointSize[0.015],Map[Point[#]&,OrderedNodes]}]

owlptnumbers=Graphics[{Blue,Table[Text[k-1,OrderedNodes[[k]]],{k,1,Length[OrderedNodes]}]}]

owlptfig=Show[owlpts,owlptnumbers]

Export["/home/student/courses/MATH661/homework/HW1Fig1b.png",owlptfig]

nodetable = ArrayReshape[Flatten[OrderedNodes],{nN/4,8}];

table1 = TableForm[nodetable,TableHeadings->{Table[k,{k,0,nN/4-1}],Flatten[Table[{"(Subscript[x, i])","(Subscript[y, i])"},4]]}]

Export["/home/student/courses/MATH661/homework/HW1table1.tex",table1]

OrderedNodes