MATLAB: How to extract a part of image whose coordinates are known

image processingImage Processing Toolboximage segmentation

I have a gray scale image in which i detect two curves. The some points on the both curves are known to us. Then how i will extract the part of image which lies between these two curves. FYI i have attached the image. The red marks are the points which we know.

Best Answer

Use poly2mask
mask = poly2mask(x, y, rows, columns);
extractedPixelValues = grayImage(mask);