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

📄 imline.m

📁 用人工神经网络进行人脸识别
💻 M
字号:
function M = imline(I, p1x, p1y, p2x, p2y)
% This function draws lines on a grayscale image I
% where p1x(i), p1y(i): first point (x,y) and
% p2x(i), p2y(i): second point (x,y)
% and returns M, the image matrix with lines drawn.

len = length(p1x);
for i=1:len
   if p1x(i) > p2x(i)
      px1 = round(p2x(i)); py1 = round(p2y(i));
      px2 = round(p1x(i)); py2 = round(p1y(i));
   else
      px1 = round(p1x(i)); py1 = round(p1y(i));
      px2 = round(p2x(i)); py2 = round(p2y(i));
   end
   if p1y(i) > p2y(i)
      ty1 = round(p2y(i)); tx1 = round(p2x(i));
      ty2 = round(p1y(i)); tx2 = round(p1x(i));
   else
      ty1 = round(p1y(i)); tx1 = round(p1x(i));
      ty2 = round(p2y(i)); tx2 = round(p2x(i));
   end
   h = py2 - py1;
   w = px2 - px1;
   if w ~= 0
      for p=px1:px2
         y = round((h*(p-px1)/w)+py1);
         I(y,p) = 0;
      end
   end
   h = ty2 - ty1;
   w = tx2 - tx1;
   if h ~= 0
      for t=ty1:ty2
         x = round((w*(t-ty1)/h)+tx1);
         I(t,x) = 0;
      end
   end
end
M = I;

⌨️ 快捷键说明

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