use*_*805 6 matlab image-processing computer-vision face-detection matlab-cvst
我想从图像中提取椭圆区域(图像中面部分的一部分),最好是在MATLAB中:
例如,在此图像中,我想提取红色边界内的区域.
谁能帮我这个 ?
Eit*_*n T 11
裁剪很容易,你所要做的就是使用适当的面膜.诀窍是创建这样的掩码.
假设A是你的形象,试试这个:
%# Create an ellipse shaped mask
c = fix(size(A) / 2); %# Ellipse center point (y, x)
r_sq = [76, 100] .^ 2; %# Ellipse radii squared (y-axis, x-axis)
[X, Y] = meshgrid(1:size(A, 2), 1:size(A, 1));
ellipse_mask = (r_sq(2) * (X - c(2)) .^ 2 + ...
r_sq(1) * (Y - c(1)) .^ 2 <= prod(r_sq));
%# Apply the mask to the image
A_cropped = bsxfun(@times, A, uint8(ellipse_mask));
Run Code Online (Sandbox Code Playgroud)
裁剪后的图像将被存储A_cropped.使用中心坐标和半径值进行游戏,直到获得所需结果.
编辑:我扩展了RGB图像的解决方案(如果矩阵A是3-D).