Use max() and min() to find the extremes of the coordinates you drew. Then you can create a box and use imcrop(). You know that cropping gives you a matrix which is a rectangular shape, right?
poly2mask() and use the resulting mask to extract pixels from the image. You will probably also want to calculate the bounding box of the mask and create a rectangular area that size to store the extracted pixels in (as it is not possible to have a matrix which is an irregular shape.)
Play games and win prizes!Learn more