create circular mask and assign zero outside the mask in an image
92 views (last 30 days)
Turbulence Analysis on 25 May 2021
I have the series of images (e.g. input image.jpg), in which I have to create the circular mask (mask.jpg) and make all the values outide the ciecular mask to be zero (after mask.jpg).
Please let me know how to do this..
Note - I also have co ordinate information for this image
Image Analyst on 25 May 2021
If you have the (x,y) coordinates of the circle, simply do this:
[rows, columns, numColorChannels] = size(grayImage);
mask = poly2mask(x, y, rows, columns);
grayImage(~mask) = 0; % Blacken outside the mask.
A variety of demos are attached.