How to make polygon out of selected point from a list of coordinates in image J?

Hi Everyone !

I need help for a simple command line in image J! I would like to generate a polygon selection using a subset of points within a list of points (the points coordinates will be the variable in my code).

I want to use the function makePolygon(1240,208,1345.333,348.000,1288.000,77.333,1189.333,404.000);

But instead of the numbers for the coordinates I want to call the coordinates from the selected points in the ROI. the whole point is not to have to manually type down the coordinates…

And I don’t know with what line of code I should replace the numbers…and how I should write it for the code to work…

I know you can get coordinates from the getSelectionCoordinates(xCoordinates, yCoordinates); command…but I dont know how to connect this with the makePolygon(); command…

Thanks a lot for your help !

Actually I found the solution ! Very simple if somebody needs it :
getSelectionCoordinates(xpoints, ypoints);
makeSelection(“polygon”, xpoints, ypoints);
run this and it works !