how can i apply an oval mask to extract face region?
7 views (last 30 days)
Show older comments
how can i apply an oval mask to extract face region?
0 Comments
Answers (1)
DGM
on 20 Mar 2023
Oh well if you want an oval, you're in luck. This is one way to generate oval masks.
inpict = imread('peppers.png');
[rows,cols,~] = size(inpict);
% generate a binary mask containing multiple ovals
[x y] = makeoval(60,[120 120],-60,'type','stadium');
mask = poly2mask(x,y,rows,cols);
[x y] = makeoval(80,[250 270],-100,'type','superegg');
mask = mask | poly2mask(x,y,rows,cols);
[x y] = makeoval(80,[400 120],-130,'type','ellipse','ratio',1.5);
mask = mask | poly2mask(x,y,rows,cols);
imshow(mask)
% apply the mask
outpict = im2uint8(double(mask).*im2double(inpict));
imshow(outpict)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!