how can i apply an oval mask to extract face region?

조회 수: 7 (최근 30일)
EM_JEY
EM_JEY 2016년 11월 26일
답변: DGM 2023년 3월 20일
how can i apply an oval mask to extract face region?

답변 (1개)

DGM
DGM 2023년 3월 20일
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)
... but if all you really want is an ellipse, just use imellipse() or drawellipse()

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by