0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 function plot_line_into_image(Image,line,C,f1,f2)
0013
0014
0015 if nargin < 4
0016 f1 = 4;
0017 f2 = 2;
0018 end
0019
0020
0021 n = line(1:2)/norm(line(1:2));
0022
0023
0024 [N,M,~] = size(Image);
0025
0026
0027 [x1,y1,x2,y2] = clipline(line(1:2),line(3),[0,M,0,N]);
0028 plot([x1,x2],[y1,y2],'-k','LineWidth',f1);
0029 plot([x1,x2],[y1,y2],'-y','LineWidth',f2);
0030
0031 if C(1,1) ~= 0
0032
0033 L = 30;
0034 alpha = 1:-1/(L-1):0;
0035
0036
0037 xah = [x1,y1,1]';
0038 sqa = sqrt(xah'*C*xah/norm(line(1:2))^2);
0039
0040 xal = [x1;y1]+n*sqa;
0041 xar = [x1;y1]-n*sqa;
0042 for l = 1:L-1
0043
0044 xe = alpha(l+1)*x1+(1-alpha(l+1))*x2;
0045 ye = alpha(l+1)*y1+(1-alpha(l+1))*y2;
0046 xeh = [xe,ye,1]';
0047 sqe = sqrt(xeh'*C*xeh/norm(line(1:2))^2);
0048
0049 xel = [xe;ye]+n*sqe;
0050 xer = [xe;ye]-n*sqe;
0051
0052
0053
0054 plot([xal(1),xel(1)],[xal(2),xel(2)],'-k','LineWidth',f1);
0055 plot([xal(1),xel(1)],[xal(2),xel(2)],'-y','LineWidth',f2);
0056 plot([xar(1),xer(1)],[xar(2),xer(2)],'-k','LineWidth',f1);
0057 plot([xar(1),xer(1)],[xar(2),xer(2)],'-y','LineWidth',f2);
0058
0059
0060
0061 xal = xel;
0062 xar = xer;
0063
0064 end
0065 end