⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showferetface.m

📁 It is for Face Recognition
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function showFeretFace()
%   z.li, 12-16-2003.
%   show face with gnd truth
% function dependency:
%   - loadFeretFace()
% input:
%   gndTruth - 
%   k    - offs
% output:
%   face - facial area sub image 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function [face]=showFeretFace(gndTruth, k)
function [face]=showFeretFace(gndTruth, k)
  dbg='n';   noplot = 'n';
  if dbg=='y'
      gndTruth = truth;
      k=275;
  end    

  % const: window is 4x3 in scale, 
  % margins in times d, so total is (top+botom)*d x (1+2*side)*d
  side = 0.25; top = 1.0; bottom = 1.0;

  % var
  reX = gndTruth(k,2);reY = gndTruth(k,3);
  leX = gndTruth(k,4);leY = gndTruth(k,5);
  moX = gndTruth(k,6);moY = gndTruth(k,7);
  ntX = gndTruth(k,8);ntY = gndTruth(k,9);

  % check for gnd truth 
  if reX== -1 |reY== -1 |leX== -1 |leY== -1 |moX==-1|moY==-1
     face = [];
     return;
  end

  id = sprintf('%s', gndTruth(k,10:26));
  faceImg = loadFeretFace(id);
  [fht, fwid] = size(faceImg);

  
  % eyes - mouth  triangle
  d = norm(([leX leY] - [reX reY]), 2);
  a = norm(([leX leY] - [moX moY]), 2);
  b = norm(([moX moY] - [reX reY]), 2);
  h = moY - 0.5*(leY+reY);

  % find the bounding window
  faceW = fix((1+2*side)*d);
  faceH = fix((top+bottom)*d);
  leftMargin = fix(side*d);
  topMargin = fix(top*d);
 
  ulX = max(1, leX - leftMargin); 
  ulY = ntY - topMargin;
  lrX = ulX + faceW -1;
  lrY = ulY + faceH -1;  

  % facial area
  face(1:faceH,1:faceW) = faceImg(ulY:lrY,ulX:lrX);   

  if noplot == 'n'
      axis ij; 
      imshow(faceImg, 256); hold on;       
      % eyes, mouth and nose tip
      plot(leX, leY, 'or');
      plot(reX, reY, 'om');
      plot(moX, moY, '+r');
      plot(ntX, ntY, '*g');

      % detection window
      px =[ulX lrX]; py=[ulY ulY]; plot(px,py,'.',px,py,'-g');
      px =[ulX ulX]; py=[ulY lrY]; plot(px,py,'.',px,py,'-g');
      px =[ulX lrX]; py=[lrY lrY]; plot(px,py,'.',px,py,'-g');
      px =[lrX lrX]; py=[lrY ulY]; plot(px,py,'.',px,py,'-g');

      imshow(face, 256);
  end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -