Home > 13-Two-View-Geometry > Functions > plot_line_into_image.m

plot_line_into_image

PURPOSE ^

plot a line into an image if possible with error bound

SYNOPSIS ^

function plot_line_into_image(Image,line,C,f1,f2)

DESCRIPTION ^

 plot a line into an image if possible with error bound

 Image  = Image
 line   = homogeneous line coordinates
 C      = covariance matrix of homogeneous coordinates

 plot_line_into_image(Image_r,lss);

 Wolfgang Förstner 10/2010
 wfoerstn@uni-bonn.de

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % plot a line into an image if possible with error bound
0002 %
0003 % Image  = Image
0004 % line   = homogeneous line coordinates
0005 % C      = covariance matrix of homogeneous coordinates
0006 %
0007 % plot_line_into_image(Image_r,lss);
0008 %
0009 % Wolfgang Förstner 10/2010
0010 % wfoerstn@uni-bonn.de
0011 
0012 function plot_line_into_image(Image,line,C,f1,f2)
0013 
0014 % default widths
0015 if nargin < 4
0016     f1 = 4;
0017     f2 = 2;
0018 end
0019 
0020 % normalized normal vector
0021 n = line(1:2)/norm(line(1:2));
0022 
0023 % size of image
0024 [N,M,~] = size(Image);
0025 
0026 % plot clipped line
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     % plot hyperbolic band
0033     L = 30;
0034     alpha = 1:-1/(L-1):0;
0035 
0036     % initiate reference point
0037     xah = [x1,y1,1]';
0038     sqa = sqrt(xah'*C*xah/norm(line(1:2))^2);
0039     % left and right point
0040     xal = [x1;y1]+n*sqa;
0041     xar = [x1;y1]-n*sqa;
0042     for l = 1:L-1
0043         % 2. reference point
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         % left right point
0049         xel = [xe;ye]+n*sqe;
0050         xer = [xe;ye]-n*sqe;
0051         % left right line
0052 
0053         % plot clipped line left and right
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         % transfer
0060         % left and right point
0061         xal = xel;
0062         xar = xer;
0063 
0064     end
0065 end

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005