照片人脸检测MATLAB代码.docx

上传人:李医生 文档编号:6109610 上传时间:2020-09-11 格式:DOCX 页数:4 大小:36.68KB
返回 下载 相关 举报
照片人脸检测MATLAB代码.docx_第1页
第1页 / 共4页
照片人脸检测MATLAB代码.docx_第2页
第2页 / 共4页
照片人脸检测MATLAB代码.docx_第3页
第3页 / 共4页
照片人脸检测MATLAB代码.docx_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《照片人脸检测MATLAB代码.docx》由会员分享,可在线阅读,更多相关《照片人脸检测MATLAB代码.docx(4页珍藏版)》请在三一文库上搜索。

1、.% 载入图像Img = imread(star1.jpg);if ndims(Img) = 3I=rgb2gray(Img);elseI = Img;endBW = im2bw(I, graythresh(I); %二值化figure;subplot(2, 2, 1); imshow(Img);title( 原图像 , FontWeight, Bold);subplot(2, 2, 2); imshow(Img);title( 网格标记图像, FontWeight, Bold);hold on;xt, yt = meshgrid(round(linspace(1, size(I, 1), 1

2、0), .round(linspace(1, size(I, 2), 10);mesh(yt, xt, zeros(size(xt), FaceColor, .None, LineWidth, 3, .EdgeColor, r);subplot(2, 2, 3); imshow(BW);title( 二值图像 , FontWeight, Bold);n1, n2 = size(BW);r = floor(n1/10); % 分成 10 块,行c = floor(n2/10); % 分成 10 块,列x1 = 1; x2 = r; % 对应行初始化s = r*c; % 块面积for i = 1:

3、10y1 = 1; y2 = c; % 对应列初始化for j = 1:10if (y2=9*c) | (x1=1 | x2=r*10)% 如果是在四周区域loc = find(BW(x1:x2, y1:y2)=0);p, q = size(loc);pr = p/s*100; %黑色像素所占的比例数if pr mx & (Bd(k, 3)/Bd(k, 4)1.8% 如果满足面积块大,而且宽 / 高 1.8 mx = p;j = k;endendsubplot(2, 2, 4);imshow(I); hold on;rectangle(Position, Bd(j, :), .EdgeColo

4、r, r, LineWidth, 3);title( 标记图像 , FontWeight, Bold);if ndims(Img) = 3I=rgb2gray(Img);elseI = Img;endBW = im2bw(I, graythresh(I); %二值化figure;subplot(2, 2, 1); imshow(Img);title( 原图像 , FontWeight, Bold);subplot(2, 2, 2); imshow(Img);title( 网格标记图像, FontWeight, Bold);hold on;xt, yt = meshgrid(round(lins

5、pace(1, size(I, 1), 10), .round(linspace(1, size(I, 2), 10);mesh(yt, xt, zeros(size(xt), FaceColor, .None, LineWidth, 3, .EdgeColor, r);subplot(2, 2, 3); imshow(BW);title( 二值图像 , FontWeight, Bold);n1, n2 = size(BW);r = floor(n1/10); % 分成 10 块,行c = floor(n2/10); % 分成 10 块,列x1 = 1; x2 = r; % 对应行初始化.s

6、= r*c; % 块面积for i = 1:10y1 = 1; y2 = c; % 对应列初始化for j = 1:10if (y2=9*c) | (x1=1 | x2=r*10)% 如果是在四周区域loc = find(BW(x1:x2, y1:y2)=0);p, q = size(loc);pr = p/s*100; %黑色像素所占的比例数if pr mx & (Bd(k, 3)/Bd(k, 4)1.8% 如果满足面积块大,而且宽 / 高 1.8 mx = p;j = k;endendsubplot(2, 2, 4);imshow(I); hold on;rectangle(Position, Bd(j, :), .EdgeColor, r, LineWidth, 3);title( 标记图像 , FontWeight, Bold);.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1