Search code examples
matlabbinarymask

Elliptic binary mask


I would like to create a binary mask of two vectors which are the coordinates of 50 point that make an ellipse.

e.g. caxy(50,1) and caxy(50,2) are my coordinated in the image by the pixel size of 1024x1280.

I have seen different approaches, but they are using (x,y) of the ellipse centre point and long and short radius. I know I could find these features from my vectors but I am looking for direct approach.

Any help would be appreciated.


Solution

  • After a day of challenging with the question, finally I have figured out the answer and wanna post it if somebody encounter the same problem, it could helps.

    There is function in matlab (image processing toolbox) for that purpose:

    Mask = poly2mask(caxy(50,1), caxy(50,2), 1024, 1280);
    

    It can be used for any kind of polygon regions to mask.