The ROIPOLY function in the Image Processing Toolbox is capable of providing the functionality required. This function may be used with the following syntax:
I = imread('<filename>');
mask = roipoly(I);
where filename is the name of your image file.
This displays the image 'I' on the screen and lets you specify the polygon using the mouse. Use left button clicks on the mouse to add vertices to the polygon.
Note that pressing the Backspace or Delete keys removes the previously selected vertex. A double-click adds a final vertex to the selection and then starts the fill; pressing Return finishes the selection without adding a vertex.
Best Answer